本文整理汇总了Python中tutil.execCmd函数的典型用法代码示例。如果您正苦于以下问题:Python execCmd函数的具体用法?Python execCmd怎么用?Python execCmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execCmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getVMs
def _getVMs(self):
master = self.getMasterUUID()
cmd = "xe vm-list dom-id=0 resident-on=%s params=uuid --minimal" % \
master
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD + 1)
masterVM = stdout.strip()
if not tutil.validateUUID(masterVM):
raise SMException("Got invalid UUID: %s" % masterVM)
slaveVM = None
host = self.getThisHost()
if host == master:
cmd = "xe host-list params=uuid --minimal"
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD + 1)
hosts = stdout.strip().split(",")
for h in hosts:
if h != master:
host = h
break
if host == master:
return (masterVM, None)
cmd = "xe vm-list dom-id=0 resident-on=%s params=uuid --minimal" % host
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD + 1)
slaveVM = stdout.strip()
if not tutil.validateUUID(slaveVM):
raise SMException("Got invalid UUID: %s" % slaveVM)
return (masterVM, slaveVM)
示例2: _unplugVBD
def _unplugVBD(self, vbd):
self.logger.log("Unplugging VBD %s" % vbd, 2)
cmd = "xe vbd-unplug uuid=%s" % vbd
try:
tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
except tutil.CommandException, inst:
if str(inst).find("device is not currently attached") == -1:
raise
示例3: mount
def mount(self, dev, mountDir):
if not tutil.pathExists(mountDir):
try:
os.makedirs(mountDir)
except OSError:
raise SMException("makedirs failed (for %s)" % mountDir)
if not tutil.pathExists(mountDir):
raise SMException("mount dir '%s' not created" % mountDir)
cmd = "mount %s %s" % (dev, mountDir)
tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
示例4: _createVBD
def _createVBD(self, vdi, vm, ro = False, vbdLetter = None,
unpluggable = True):
"""Creates a VBD for the specified VDI on the specified VM. If a device
is not supplied (vbdLetter), the first available one is used. Returns
the UUID of the VBD."""
mode = "rw"
if ro:
mode="ro"
if None == vbdLetter:
devices = self._vm_get_allowed_vbd_devices(vm)
assert len(devices) > 0 # FIXME raise exception instead
vbdLetter = devices[0]
cmd = "xe vbd-create vm-uuid=%s vdi-uuid=%s type=disk mode=%s "\
"device=%s unpluggable=%s" % (vm, vdi, mode, vbdLetter,
unpluggable)
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
# XXX xe vbd-create returns 0 if the device name is invalid
if not stdout:
raise SMException("No output from vbd-create")
vbdUuid = stdout.strip()
if not tutil.validateUUID(vbdUuid):
raise SMException("Got invalid UUID: %s" % vbdUuid)
return vbdUuid
示例5: _getInfoVDI
def _getInfoVDI(self, uuid):
"""Retrieves the parameters of the spcified VDI in the form of a
dictionary."""
cmd = "xe vdi-list uuid=%s params=all" % uuid
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD + 1)
return self._toDict(stdout)
示例6: _getPoolUUID
def _getPoolUUID(self):
cmd = "xe pool-list params=uuid --minimal"
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
poolUuid = stdout.strip()
if not tutil.validateUUID(poolUuid):
raise SMException("Got invalid UUID: %s" % poolUuid)
return poolUuid
示例7: _getInfoSR
def _getInfoSR(self, uuid):
cmd = "xe sr-list uuid=%s params=all" % uuid
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD + 1)
info = self._toDict(stdout)
if not info["sm-config"]:
info["sm-config"] = dict()
return info
示例8: _onMaster
def _onMaster(self, plugin, fn, args):
argsStr = ""
for key, val in args.iteritems():
argsStr += " args:%s=%s" % (key, val)
cmd = "xe host-call-plugin host-uuid=%s plugin=%s fn=%s %s" % \
(self.getMasterUUID(), plugin, fn, argsStr)
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
return stdout.strip()
示例9: _vdi_get_vbd
def _vdi_get_vbd(self, vdi_uuid):
"""Retrieves the UUID of the specified VDI, else None."""
out = tutil.execCmd('xe vbd-list vdi-uuid=' + vdi_uuid + ' --minimal',
0, self.logger, LOG_LEVEL_CMD).strip()
if '' != out:
return out
else:
return None
示例10: _getVDIs
def _getVDIs(self, sr):
cmd = "xe vdi-list sr-uuid=%s params=uuid --minimal" % sr
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_SUB)
stdout = stdout.strip()
if not stdout:
return []
vdiList = stdout.split(",")
return vdiList
示例11: _findSR
def _findSR(self, type):
cmd = "xe sr-list type=%s --minimal" % type
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
stdout = stdout.strip()
if not stdout:
return []
srList = stdout.split(",")
return srList
示例12: _getDefaultSR
def _getDefaultSR(self):
cmd = "xe pool-param-get param-name=default-SR uuid=%s --minimal" % \
self._getPoolUUID()
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
uuid = stdout.strip()
if tutil.validateUUID(uuid):
return uuid
return None
示例13: _getDom0UUID
def _getDom0UUID(self):
cmd = "xe vm-list dom-id=0 params=uuid --minimal"
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
if not stdout:
raise SMException("No output from vm-list")
dom0uuid = stdout.strip()
if not tutil.validateUUID(dom0uuid):
raise SMException("Got invalid UUID: %s" % dom0uuid)
return dom0uuid
示例14: _getInfoSR
def _getInfoSR(self, uuid):
"""Retrieves the parameters of the specified SR in the form of a
dictionary."""
cmd = "xe sr-list uuid=%s params=all" % uuid
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD + 1)
info = self._toDict(stdout)
if not info["sm-config"]:
info["sm-config"] = dict()
return info
示例15: _findSR
def _findSR(self, type):
"Retrieves all SRs of the specified type in the form of a list."
cmd = "xe sr-list type=%s --minimal" % type
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
stdout = stdout.strip()
if not stdout:
return []
srList = stdout.split(",")
return srList