本文整理汇总了Python中tutil.execCmd函数的典型用法代码示例。如果您正苦于以下问题:Python execCmd函数的具体用法?Python execCmd怎么用?Python execCmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execCmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:euanh,项目名称:sm,代码行数:29,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:8,代码来源:storagemanager.py
示例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)
开发者ID:euanh,项目名称:sm,代码行数:10,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:26,代码来源:storagemanager.py
示例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)
开发者ID:euanh,项目名称:sm,代码行数:7,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:7,代码来源:storagemanager.py
示例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
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:7,代码来源:storagemanager.py
示例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()
开发者ID:euanh,项目名称:sm,代码行数:8,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:8,代码来源:storagemanager.py
示例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
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:8,代码来源:storagemanager.py
示例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
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:8,代码来源:storagemanager.py
示例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
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:8,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:9,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:10,代码来源:storagemanager.py
示例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
开发者ID:euanh,项目名称:sm,代码行数:10,代码来源:storagemanager.py
示例16: _getVHDParentNoCheck
def _getVHDParentNoCheck(self, sr, path):
cmd = "vhd-util read -p -n %s" % path
text = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_SUB)
for line in text.split('\n'):
if line.find("decoded name :") != -1:
val = line.split(':')[1].strip()
vdi = val.replace("--", "-")[-40:]
if vdi[1:].startswith("LV-"):
vdi = vdi[1:]
return os.path.join(self.getPathSR(sr), vdi)
return None
开发者ID:euanh,项目名称:sm,代码行数:11,代码来源:storagemanager.py
示例17: _getVDIs
def _getVDIs(self, sr):
"""Retrieves the UUIDs of all the VDIs on the specified SR, in the form
of a list."""
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
开发者ID:euanh,项目名称:sm,代码行数:11,代码来源:storagemanager.py
示例18: _createSR
def _createSR(self, type, size):
cmd = "xe sr-create name-label='%s' physical-size=%d \
content-type=user device-config:device=%s type=%s" % \
(self.SR_LABEL, size, self.targetDevice, type)
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
if not stdout:
raise SMException("No output from sr-create")
srUuid = stdout.strip()
if not tutil.validateUUID(srUuid):
raise SMException("Got invalid UUID: %s" % srUuid)
return srUuid
开发者ID:euanh,项目名称:sm,代码行数:11,代码来源:storagemanager.py
示例19: _vdi_get_parent
def _vdi_get_parent(self, vdi_uuid):
"""Retrieves the parent UUID of the VDI."""
# XXX It is expected to be a VHD VDI.
out = tutil.execCmd('xe vdi-param-get uuid=' + vdi_uuid \
+ ' param-name=sm-config', 0, self.logger,
LOG_LEVEL_CMD)
assert re.match('vhd-parent: ' + tutil.uuidre + '; vdi_type: vhd\n',
out)
return re.search(tutil.uuidre, out).group(0)
开发者ID:euanh,项目名称:sm,代码行数:12,代码来源:storagemanager.py
示例20: _cloneVDI
def _cloneVDI(self, vdi):
cmd = "xe vdi-clone uuid=%s" % vdi
for i in range(CMD_NUM_RETRIES):
try:
stdout = tutil.execCmd(cmd, 0, self.logger, LOG_LEVEL_CMD)
break
except tutil.CommandException, inst:
if str(inst).find("VDI_IN_USE") != -1:
self.logger.log("Command failed, retrying", LOG_LEVEL_CMD)
time.sleep(CMD_RETRY_PERIOD)
else:
raise
开发者ID:euanh,项目名称:sm,代码行数:12,代码来源:storagemanager.py
注:本文中的tutil.execCmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论