def refresh_service(self):
cmd = [SVCADMCMD, "refresh", self.instanceName]
- p = subprocess.Popen(cmd, close_fds=True)
+ util.run_command(cmd)
def disable_service (self):
if self.svcstate == "disabled":
return
cmd = [SVCADMCMD, "disable", self.instanceName]
- p = subprocess.Popen(cmd, close_fds=True)
+ util.run_command(cmd)
self.svcstate = self.get_service_state()
def enable_service (self):
if (self.svcstate == "online" or self.svcstate == "degraded"):
return
cmd = [SVCADMCMD, "enable", self.instanceName]
- p = subprocess.Popen(cmd, close_fds=True)
+ util.run_command(cmd)
self.svcstate = self.get_service_state()
def mark_maintenance (self):
cmd = [SVCADMCMD, "mark", "maintenance", self.instanceName]
- subprocess.Popen(cmd, close_fds=True)
+ util.run_command(cmd)
def __str__(self):
ret = "SMF Instance:\n" +\
cmd = [ZFSCMD, "list", "-H", "-t", "filesystem", \
"-o", "name,mountpoint", "-s", "name"]
try:
- p = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- close_fds=True)
- outdata,errdata = p.communicate()
- err = p.wait()
+ outdata,errdata = util.run_command(cmd, True)
except OSError, message:
raise RuntimeError, "%s subprocess error:\n %s" % \
(cmd, str(message))
cmd = [ZFSCMD, "list", "-H", "-t", "volume", \
"-o", "name", "-s", "name"]
try:
- p = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- close_fds=True)
- outdata,errdata = p.communicate()
- err = p.wait()
- except OSError, message:
- raise RuntimeError, "%s subprocess error:\n %s" % \
- (cmd, str(message))
- if err != 0:
+ outdata,errdata = util.run_command(cmd, True)
+ except RuntimeError, message:
Datasets._volumeslock.release()
- raise RuntimeError, '%s failed with exit code %d\n%s' % \
- (str(cmd), err, errdata)
+ raise RuntimeError, str(message)
+
for line in outdata.rstrip().split('\n'):
Datasets.volumes.append(line.rstrip())
Datasets._volumeslock.release()
snaps = []
cmd = [ZFSCMD, "get", "-H", "-p", "-o", "value,name", "creation"]
try:
- p = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- close_fds=True)
- outdata,errdata = p.communicate()
- err= p.wait()
- except OSError, message:
+ outdata,errdata = util.run_command(cmd, True)
+ except RuntimeError, message:
Datasets.snapshotslock.release()
- raise RuntimeError, "%s subprocess error:\n %s" % \
- (cmd, str(message))
- if err != 0:
- Datasets.snapshotslock.release()
- raise RuntimeError, '%s failed with exit code %d\n%s' % \
- (str(cmd), err, errdata)
+ raise RuntimeError, str(message)
for dataset in outdata.rstrip().split('\n'):
if re.search("@", dataset):
insort(snaps, dataset.split())
# simple zfs get command on the snapshot
cmd = [ZFSCMD, "get", "-H", "-o", "name", "type", self.name]
try:
- p = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- close_fds=True)
- outdata,errdata = p.communicate()
- err = p.wait()
- except OSError, message:
- raise RuntimeError, "%s subprocess error:\n %s" % \
- (command, str(message))
- if err != 0:
- # Doesn't exist
- return False
+ outdata,errdata = util.run_command(cmd)
+ except RuntimeError, message:
+ raise RuntimeError, str(message)
result = outdata.rstrip()
if result == self.name: