本文整理汇总了Python中vdsm.commands.execCmd函数的典型用法代码示例。如果您正苦于以下问题:Python execCmd函数的具体用法?Python execCmd怎么用?Python execCmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execCmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_brctl
def check_brctl():
try:
execCmd([EXT_BRCTL, "show"])
except OSError as e:
if e.errno == errno.ENOENT:
raise SkipTest("Cannot run %r: %s\nDo you have bridge-utils "
"installed?" % (EXT_BRCTL, e))
raise
示例2: removeBridge
def removeBridge(self, bridge):
DynamicSourceRoute.addInterfaceTracking(bridge)
ifdown(bridge.name)
self._removeSourceRoute(bridge, StaticSourceRoute)
commands.execCmd([constants.EXT_BRCTL, 'delbr', bridge.name])
self.configApplier.removeBridge(bridge.name)
if bridge.port:
bridge.port.remove()
示例3: stop_devices
def stop_devices(device_ifcfgs):
for dev in reversed(_sort_device_ifcfgs(device_ifcfgs)):
ifdown(dev)
if os.path.exists("/sys/class/net/%s/bridge" % dev):
# ifdown is not enough to remove nicless bridges
commands.execCmd([constants.EXT_BRCTL, "delbr", dev])
if _is_bond_name(dev):
if _is_running_bond(dev):
with open(netinfo_bonding.BONDING_MASTERS, "w") as f:
f.write("-%s\n" % dev)
示例4: removeBridge
def removeBridge(self, bridge):
if not self.owned_device(bridge.name):
IfcfgAcquire.acquire_device(bridge.name)
DynamicSourceRoute.addInterfaceTracking(bridge)
ifdown(bridge.name)
self._removeSourceRoute(bridge, StaticSourceRoute)
commands.execCmd([constants.EXT_BRCTL, "delbr", bridge.name])
self.configApplier.removeBridge(bridge.name)
if bridge.port:
bridge.port.remove()
示例5: teardown
def teardown(self):
ovsdb = create()
bridges = ovsdb.list_bridge_info().execute()
with ovsdb.transaction() as t:
for bridge in bridges:
if bridge in TEST_BRIDGES:
t.add(ovsdb.del_br(bridge['name']))
if not self.ovs_init_state_is_up:
execCmd([OVS_CTL, 'stop'])
示例6: configureNic
def configureNic(self, nic, **opts):
DynamicSourceRoute.addInterfaceTracking(nic)
self.configApplier.setIfaceConfigAndUp(nic)
self._addSourceRoute(nic)
ethtool_opts = getEthtoolOpts(nic.name)
if ethtool_opts:
# We ignore ethtool's return code to maintain initscripts'
# behaviour.
execCmd(
[_ETHTOOL_BINARY.cmd, '-K', nic.name] + ethtool_opts.split())
示例7: volumeStatvfs
def volumeStatvfs(volumeName, host=GLUSTER_VOL_HOST,
port=GLUSTER_VOL_PORT,
protocol=GLUSTER_VOL_PROTOCOL):
module = "gluster.gfapi"
command = [constants.EXT_PYTHON, '-m', module, '-v', volumeName,
'-p', str(port), '-H', host, '-t', protocol, '-c', 'statvfs']
# to include /usr/share/vdsm in python path
env = os.environ.copy()
env['PYTHONPATH'] = "%s:%s" % (
env.get("PYTHONPATH", ""), constants.P_VDSM)
env['PYTHONPATH'] = ":".join(map(os.path.abspath,
env['PYTHONPATH'].split(":")))
rc, out, err = commands.execCmd(command, raw=True, env=env)
if rc != 0:
raise ge.GlfsStatvfsException(rc, [out], [err])
res = json.loads(out)
return os.statvfs_result((res['f_bsize'],
res['f_frsize'],
res['f_blocks'],
res['f_bfree'],
res['f_bavail'],
res['f_files'],
res['f_ffree'],
res['f_favail'],
res['f_flag'],
res['f_namemax']))
示例8: start
def start(self):
cmd = [_IPERF3_BINARY.cmd, '--server', '--bind', self._bind_to]
if self._net_ns is not None:
p = netns_exec(self._net_ns, cmd)
else:
p = execCmd(cmd, sync=False)
self._pid = p.pid
示例9: docker_net_inspect
def docker_net_inspect(self, network):
return commands.execCmd([
self._exes.docker.cmd,
'network',
'inspect',
network,
], raw=True)
示例10: testSudo
def testSudo(self, cmd):
checkSudo(['echo'])
rc, out, _ = commands.execCmd(cmd(('grep',
'Uid', '/proc/self/status')),
sudo=True)
self.assertEquals(rc, 0)
self.assertEquals(int(out[0].split()[2]), 0)
示例11: _systemctl
def _systemctl(*args):
cmd = [_SYSTEMCTL.cmd]
cmd.extend(args)
rc, out, err = commands.execCmd(cmd, raw=True)
if rc != 0:
raise cmdutils.Error(cmd=cmd, rc=rc, out=out, err=err)
return out
示例12: _echo
def _echo(self, text):
proc = commands.execCmd(["echo", "-n", "test"], sync=False)
def parse(rc, out, err):
return out
return utils.AsyncProcessOperation(proc, parse)
示例13: _execCmd
def _execCmd(command):
returnCode, output, error = execCmd(command)
if returnCode:
raise IPRoute2Error(error)
return output
示例14: _start_virt_v2v
def _start_virt_v2v(self):
return execCmd(self._command(),
sync=False,
deathSignal=signal.SIGTERM,
nice=NICENESS.HIGH,
ioclass=IOCLASS.IDLE,
env=self._environment())
示例15: testV2VOutput
def testV2VOutput(self):
cmd = [FAKE_VIRT_V2V.cmd,
'-v',
'-x',
'-ic', self.vpx_url,
'-o', 'vdsm',
'-of', 'raw',
'-oa', 'sparse',
'--vdsm-image-uuid', self.image_id_a,
'--vdsm-vol-uuid', self.volume_id_a,
'--vdsm-image-uuid', self.image_id_b,
'--vdsm-vol-uuid', self.volume_id_b,
'--password-file', '/tmp/mypass',
'--vdsm-vm-uuid', self.job_id,
'--vdsm-ovf-output', '/usr/local/var/run/vdsm/v2v',
'--machine-readable',
'-os', '/rhev/data-center/%s/%s' % (self.pool_id,
self.domain_id),
self.vm_name]
rc, output, error = execCmd(cmd, raw=True)
self.assertEqual(rc, 0)
with open('fake-virt-v2v.out', 'r') as f:
self.assertEqual(output, f.read())
with open('fake-virt-v2v.err', 'r') as f:
self.assertEqual(error, f.read())