Yaniv Bronhaim has uploaded a new change for review. Change subject: rename execCmd and startCmd to run_cmd and start_cmd ......................................................................
rename execCmd and startCmd to run_cmd and start_cmd Change-Id: I5e271c07f204c405483c24b03b2792a25bf4256d Signed-off-by: Yaniv Bronhaim <ybron...@redhat.com> --- M contrib/repoplot M lib/vdsm/commands.py M lib/vdsm/hooks.py M lib/vdsm/host/__init__.py M lib/vdsm/network/api.py M lib/vdsm/network/configurators/ifcfg.py M lib/vdsm/network/configurators/iproute2.py M lib/vdsm/network/ip/dhclient.py M lib/vdsm/network/ipwrapper.py M lib/vdsm/network/netconfpersistence.py M lib/vdsm/network/ovs/driver/vsctl.py M lib/vdsm/network/tc/_wrapper.py M lib/vdsm/numa.py M lib/vdsm/qemuimg.py M lib/vdsm/storage/blkdiscard.py M lib/vdsm/storage/clusterlock.py M lib/vdsm/storage/curlImgWrap.py M lib/vdsm/storage/devicemapper.py M lib/vdsm/storage/fuser.py M lib/vdsm/storage/hba.py M lib/vdsm/storage/misc.py M lib/vdsm/storage/mount.py M lib/vdsm/taskset.py M lib/vdsm/tool/configurators/certificates.py M lib/vdsm/tool/configurators/multipath.py M lib/vdsm/tool/configurators/passwd.py M lib/vdsm/tool/configurators/sanlock.py M lib/vdsm/tool/dummybr.py M lib/vdsm/tool/restore_nets.py M lib/vdsm/tool/service.py M lib/vdsm/tool/transient.py M lib/vdsm/tool/validate_ovirt_certs.py.in M lib/vdsm/udevadm.py M lib/vdsm/v2v.py M lib/vdsm/virtsparsify.py M tests/alignmentScanTests.py M tests/capsTests.py M tests/commands_test.py M tests/functional/networkTests.py M tests/functional/virtTests.py M tests/iscsiTests.py M tests/miscTests.py M tests/mkimageTests.py M tests/modprobe.py M tests/mountTests.py M tests/network/dhcp.py M tests/network/firewall.py M tests/network/nettestlib.py M tests/network/ovsnettestlib.py M tests/qemuimgTests.py M tests/utilsTests.py M tests/v2vTests.py M vdsm/API.py M vdsm/alignmentScan.py M vdsm/gluster/api.py M vdsm/gluster/cli.py M vdsm/gluster/gfapi.py M vdsm/gluster/storagedev.py M vdsm/hooking.py M vdsm/mkimage.py M vdsm/storage/blockSD.py M vdsm/storage/curl-img-wrap M vdsm/storage/hsm.py M vdsm/storage/iscsiadm.py M vdsm/storage/lvm.py M vdsm/storage/multipath.py M vdsm/storage/storage_mailbox.py M vdsm/supervdsm_api/udev.py M vdsm/vdsm M vdsm_hooks/ethtool_options/ethtool_options.py M vdsm_hooks/extra_ipv4_addrs/extra_ipv4_addrs.py M vdsm_hooks/fcoe/fcoe_before_network_setup.py M vdsm_hooks/hostusb/after_vm_destroy.py M vdsm_hooks/hostusb/before_vm_start.py M vdsm_hooks/hugepages/before_vm_migrate_destination.py M vdsm_hooks/hugepages/before_vm_start.py M vdsm_hooks/openstacknet/openstacknet_utils.py M vdsm_hooks/ovs/ovs_after_get_caps.py M vdsm_hooks/ovs/ovs_before_network_setup.py M vdsm_hooks/ovs/ovs_before_network_setup_ovs.py M vdsm_hooks/ovs/ovs_utils.py M vdsm_hooks/promisc/after_vm_start.py M vdsm_hooks/promisc/before_vm_destroy.py M vdsm_hooks/scratchpad/before_vm_start.py 84 files changed, 273 insertions(+), 272 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/60280/1 diff --git a/contrib/repoplot b/contrib/repoplot index c4dcc2b..eb6e738 100755 --- a/contrib/repoplot +++ b/contrib/repoplot @@ -211,10 +211,10 @@ # the start of the command. # # d9633df0-5f67-442a-861b-91d417b046f5::DEBUG::2016-02-09 - # 12:37:59,885::utils::669::root::(execCmd) /usr/bin/taskset --cpu-list + # 12:37:59,885::utils::669::root::(run_cmd) /usr/bin/taskset --cpu-list # 0-23 /usr/bin/nice -n 19 /usr/bin/ionice -c 3 /usr/bin/qemu-img # convert ... - (add_qemuimg_copy, "::root::(execCmd)", "disk_commands"), + (add_qemuimg_copy, "::root::(run_cmd)", "disk_commands"), # Match qemu-img convert used for copying images in 3.6. This matches # the end of the command. @@ -275,7 +275,7 @@ def add_command(commands, log): """ - Add commands start and stop events from execCmd calls + Add commands start and stop events from run_cmd calls """ if is_command_end(log): commands[log.thread].end(log.timestamp) diff --git a/lib/vdsm/commands.py b/lib/vdsm/commands.py index 6b734c7..188009a 100644 --- a/lib/vdsm/commands.py +++ b/lib/vdsm/commands.py @@ -40,12 +40,12 @@ BUFFSIZE = 1024 -def execCmd(command, sudo=False, cwd=None, data=None, raw=False, +def run_cmd(command, sudo=False, cwd=None, data=None, raw=False, printable=None, env=None, nice=None, ioclass=None, ioclassdata=None, setsid=False, execCmdLogger=logging.root, resetCpuAffinity=True): """ - Duplication of startCmd method without the use of deathSignal and sync + Duplication of start_cmd method without the use of deathSignal and sync parameters. Using simple_exec_cmd will execute the command by popen in sync to the call and return outputs. @@ -84,10 +84,10 @@ return p.returncode, out, err -def startCmd(command, sudo=False, cwd=None, data=None, raw=False, - printable=None, env=None, nice=None, ioclass=None, - ioclassdata=None, setsid=False, execCmdLogger=logging.root, - deathSignal=0, resetCpuAffinity=True): +def start_cmd(command, sudo=False, cwd=None, data=None, raw=False, + printable=None, env=None, nice=None, ioclass=None, + ioclassdata=None, setsid=False, execCmdLogger=logging.root, + deathSignal=0, resetCpuAffinity=True): """ Executes an external command, optionally via sudo. @@ -324,7 +324,7 @@ except OSError as ex: if ex.errno != errno.EPERM: raise - execCmd([constants.EXT_KILL, "-%d" % (signal.SIGTERM,), + run_cmd([constants.EXT_KILL, "-%d" % (signal.SIGTERM,), str(self.pid)], sudo=True) def wait(self, timeout=None, cond=None): @@ -353,7 +353,7 @@ def grepCmd(pattern, paths): cmd = [constants.EXT_GREP, '-E', '-H', pattern] cmd.extend(paths) - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) if rc == 0: matches = out # A list of matching lines elif rc == 1: @@ -368,8 +368,8 @@ """ Executes an external command, optionally via sudo with stop abilities. """ - proc = startCmd(command, cwd=cwd, data=data, nice=nice, ioclass=ioclass, - execCmdLogger=execCmdLogger, deathSignal=deathSignal) + proc = start_cmd(command, cwd=cwd, data=data, nice=nice, ioclass=ioclass, + execCmdLogger=execCmdLogger, deathSignal=deathSignal) if not proc.wait(cond=stop): proc.kill() diff --git a/lib/vdsm/hooks.py b/lib/vdsm/hooks.py index 03363ae..049f548 100644 --- a/lib/vdsm/hooks.py +++ b/lib/vdsm/hooks.py @@ -103,7 +103,7 @@ errorSeen = False for s in scripts: - rc, out, err = commands.execCmd([s], raw=True, + rc, out, err = commands.run_cmd([s], raw=True, env=scriptenv) logging.info(err) if rc != 0: diff --git a/lib/vdsm/host/__init__.py b/lib/vdsm/host/__init__.py index 27da570..a4a2721 100644 --- a/lib/vdsm/host/__init__.py +++ b/lib/vdsm/host/__init__.py @@ -23,7 +23,7 @@ import os import logging from vdsm.utils import memoized -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm import constants from vdsm import cpuarch @@ -39,7 +39,7 @@ else: arch = cpuarch.real() if cpuarch.is_x86(arch): - ret, out, err = execCmd([constants.EXT_DMIDECODE, + ret, out, err = run_cmd([constants.EXT_DMIDECODE, "-s", "system-uuid"], raw=True, diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py index 151b469..808ab965 100644 --- a/lib/vdsm/network/api.py +++ b/lib/vdsm/network/api.py @@ -277,5 +277,5 @@ def setSafeNetworkConfig(): """Declare current network configuration as 'safe'""" - commands.execCmd([constants.EXT_VDSM_STORE_NET_CONFIG, + commands.run_cmd([constants.EXT_VDSM_STORE_NET_CONFIG, config.get('vars', 'net_persistence')]) diff --git a/lib/vdsm/network/configurators/ifcfg.py b/lib/vdsm/network/configurators/ifcfg.py index d1ddd79..54c6a95 100644 --- a/lib/vdsm/network/configurators/ifcfg.py +++ b/lib/vdsm/network/configurators/ifcfg.py @@ -192,7 +192,7 @@ DynamicSourceRoute.addInterfaceTracking(bridge) ifdown(bridge.name) self._removeSourceRoute(bridge, StaticSourceRoute) - commands.execCmd([constants.EXT_BRCTL, 'delbr', bridge.name]) + commands.run_cmd([constants.EXT_BRCTL, 'delbr', bridge.name]) self.configApplier.removeBridge(bridge.name) if bridge.port: bridge.port.remove() @@ -414,7 +414,7 @@ def _persistentBackup(cls, filename): """ Persistently backup ifcfg-* config files """ if os.path.exists('/usr/libexec/ovirt-functions'): - commands.execCmd([constants.EXT_SH, '/usr/libexec/ovirt-functions', + commands.run_cmd([constants.EXT_SH, '/usr/libexec/ovirt-functions', 'unmount_config', filename]) logging.debug("unmounted %s using ovirt", filename) @@ -713,7 +713,7 @@ 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]) + commands.run_cmd([constants.EXT_BRCTL, 'delbr', dev]) if _is_bond_name(dev): if _is_running_bond(dev): with open(netinfo_bonding.BONDING_MASTERS, 'w') as f: @@ -781,7 +781,7 @@ def ifdown(iface): "Bring down an interface" - rc, _, _ = commands.execCmd([constants.EXT_IFDOWN, iface], raw=True) + rc, _, _ = commands.run_cmd([constants.EXT_IFDOWN, iface], raw=True) return rc @@ -798,7 +798,7 @@ cmd = cmdutils.systemd_run(cmd, scope=True, unit=uuid.uuid4(), slice=cgroup) - rc, out, err = commands.execCmd(cmd, raw=False) + rc, out, err = commands.run_cmd(cmd, raw=False) if rc != 0: # In /etc/sysconfig/network-scripts/ifup* the last line usually diff --git a/lib/vdsm/network/configurators/iproute2.py b/lib/vdsm/network/configurators/iproute2.py index 4a96966..9ab1f5b 100644 --- a/lib/vdsm/network/configurators/iproute2.py +++ b/lib/vdsm/network/configurators/iproute2.py @@ -31,7 +31,7 @@ from vdsm.constants import EXT_BRCTL from vdsm.network.netconfpersistence import RunningConfig from vdsm.utils import CommandPath -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from . import Configurator, getEthtoolOpts from ..errors import ConfigNetworkError, ERR_FAILED_IFUP, ERR_FAILED_IFDOWN @@ -149,7 +149,7 @@ if ethtool_opts: # We ignore ethtool's return code to maintain initscripts' # behaviour. - execCmd( + run_cmd( [_ETHTOOL_BINARY.cmd, '-K', nic.name] + ethtool_opts.split()) def removeBridge(self, bridge): @@ -266,7 +266,7 @@ self.ifup(iface) def addBridge(self, bridge): - rc, _, err = execCmd([EXT_BRCTL, 'addbr', bridge.name]) + rc, _, err = run_cmd([EXT_BRCTL, 'addbr', bridge.name]) if rc != 0: err_used_bridge = (_BRCTL_DEV_EXISTS % bridge.name == err[0] if err else False) @@ -278,7 +278,7 @@ bridge_stp.write('1') def addBridgePort(self, bridge): - rc, _, err = execCmd([EXT_BRCTL, 'addif', bridge.name, + rc, _, err = run_cmd([EXT_BRCTL, 'addif', bridge.name, bridge.port.name]) if rc != 0: raise ConfigNetworkError(ERR_FAILED_IFUP, err) @@ -289,7 +289,7 @@ f.write(value) def removeBridge(self, bridge): - rc, _, err = execCmd([EXT_BRCTL, 'delbr', bridge.name]) + rc, _, err = run_cmd([EXT_BRCTL, 'delbr', bridge.name]) if rc != 0: raise ConfigNetworkError(ERR_FAILED_IFDOWN, err) diff --git a/lib/vdsm/network/ip/dhclient.py b/lib/vdsm/network/ip/dhclient.py index 27ac95d..3ca9120 100644 --- a/lib/vdsm/network/ip/dhclient.py +++ b/lib/vdsm/network/ip/dhclient.py @@ -30,7 +30,7 @@ from vdsm.network import errors as ne from vdsm.network import ipwrapper from vdsm.network import netinfo -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import CommandPath, memoized, pgrep, kill_and_rm_pid DHCLIENT_BINARY = CommandPath('dhclient', '/sbin/dhclient') @@ -68,7 +68,7 @@ if self.duid_source_file and supports_duid_file(): cmd += ['-df', self.duid_source_file] cmd = cmdutils.systemd_run(cmd, scope=True, slice=self._cgroup) - return execCmd(cmd) + return run_cmd(cmd) def start(self, blocking): if blocking: diff --git a/lib/vdsm/network/ipwrapper.py b/lib/vdsm/network/ipwrapper.py index 7e07883..1cbf7b6 100644 --- a/lib/vdsm/network/ipwrapper.py +++ b/lib/vdsm/network/ipwrapper.py @@ -31,7 +31,7 @@ from netaddr import IPAddress from netaddr import IPNetwork -from vdsm.commands import execCmd, startCmd +from vdsm.commands import run_cmd, start_cmd from vdsm.config import config from vdsm.network.netlink import link from vdsm.utils import anyFnmatch @@ -471,7 +471,7 @@ def _execCmd(command): - returnCode, output, error = execCmd(command) + returnCode, output, error = run_cmd(command) if returnCode: raise IPRoute2Error(error) @@ -600,7 +600,7 @@ if sync: _execCmd(netns_command + command) else: - executer = execCmd if sync else startCmd + executer = run_cmd if sync else start_cmd return executer(netns_command + command, sync=sync) diff --git a/lib/vdsm/network/netconfpersistence.py b/lib/vdsm/network/netconfpersistence.py index 46d831a..e052d1c 100644 --- a/lib/vdsm/network/netconfpersistence.py +++ b/lib/vdsm/network/netconfpersistence.py @@ -207,7 +207,7 @@ super(RunningConfig, self).__init__(CONF_RUN_DIR) def store(self): - commands.execCmd([constants.EXT_VDSM_STORE_NET_CONFIG, + commands.run_cmd([constants.EXT_VDSM_STORE_NET_CONFIG, config.get('vars', 'net_persistence')]) return PersistentConfig() diff --git a/lib/vdsm/network/ovs/driver/vsctl.py b/lib/vdsm/network/ovs/driver/vsctl.py index 7f3d4af..1a14344 100644 --- a/lib/vdsm/network/ovs/driver/vsctl.py +++ b/lib/vdsm/network/ovs/driver/vsctl.py @@ -24,7 +24,7 @@ import logging import uuid -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.network import errors as ne from vdsm.network.errors import ConfigNetworkError from vdsm.utils import CommandPath @@ -60,7 +60,7 @@ exec_line = [_EXT_OVS_VSCTL] + ['--oneline', '--format=json'] + args logging.debug('Executing commands: %s' % ' '.join(exec_line)) - rc, out, err = execCmd(exec_line) + rc, out, err = run_cmd(exec_line) if rc != 0: raise ConfigNetworkError( ne.ERR_BAD_PARAMS, diff --git a/lib/vdsm/network/tc/_wrapper.py b/lib/vdsm/network/tc/_wrapper.py index c5a8e80..b8b5877 100644 --- a/lib/vdsm/network/tc/_wrapper.py +++ b/lib/vdsm/network/tc/_wrapper.py @@ -21,7 +21,7 @@ import os from vdsm.constants import EXT_TC -from vdsm.commands import execCmd +from vdsm.commands import run_cmd _TC_ERR_PREFIX = 'RTNETLINK answers: ' _errno_trans = dict(((os.strerror(code), code) for code in errno.errorcode)) @@ -29,7 +29,7 @@ def process_request(command): command.insert(0, EXT_TC) - retcode, out, err = execCmd(command, raw=True) + retcode, out, err = run_cmd(command, raw=True) if retcode != 0: if retcode == 2 and err: for err_line in err.splitlines(): diff --git a/lib/vdsm/numa.py b/lib/vdsm/numa.py index 7a31a99..0027732 100644 --- a/lib/vdsm/numa.py +++ b/lib/vdsm/numa.py @@ -170,7 +170,7 @@ def _run_command(args): cmd = [_SYSCTL.cmd] cmd.extend(args) - rc, out, err = commands.execCmd(cmd, raw=True) + rc, out, err = commands.run_cmd(cmd, raw=True) if rc != 0: raise cmdutils.Error(cmd, rc, out, err) diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py index c847caa..48f3485 100644 --- a/lib/vdsm/qemuimg.py +++ b/lib/vdsm/qemuimg.py @@ -70,7 +70,7 @@ cmd.extend(("-f", format)) cmd.append(image) - rc, out, err = commands.execCmd(cmd, raw=True) + rc, out, err = commands.run_cmd(cmd, raw=True) if rc != 0: raise QImgError(rc, out, err) @@ -122,7 +122,7 @@ if size is not None: cmd.append(str(size)) - rc, out, err = commands.execCmd(cmd, cwd=cwdPath) + rc, out, err = commands.run_cmd(cmd, cwd=cwdPath) if rc != 0: raise QImgError(rc, out, err) @@ -135,7 +135,7 @@ cmd.extend(("-f", format)) cmd.append(image) - rc, out, err = commands.execCmd(cmd, raw=True) + rc, out, err = commands.run_cmd(cmd, raw=True) # FIXME: handle different error codes and raise errors accordingly if rc != 0: @@ -269,7 +269,7 @@ cmd.extend(("-f", format)) cmd.extend((image, str(newSize))) - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise QImgError(rc, out, err) diff --git a/lib/vdsm/storage/blkdiscard.py b/lib/vdsm/storage/blkdiscard.py index bdc7835..bf5a0bf 100644 --- a/lib/vdsm/storage/blkdiscard.py +++ b/lib/vdsm/storage/blkdiscard.py @@ -31,7 +31,7 @@ cmd = [_blkdiscard.cmd] cmd.append(device) - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise cmdutils.Error(cmd, rc, out, err) diff --git a/lib/vdsm/storage/clusterlock.py b/lib/vdsm/storage/clusterlock.py index 5243a7c..09c7d01 100644 --- a/lib/vdsm/storage/clusterlock.py +++ b/lib/vdsm/storage/clusterlock.py @@ -97,7 +97,7 @@ def initLock(self): lockUtil = constants.EXT_SAFELEASE initCommand = [lockUtil, "release", "-f", self._leasesPath, "0"] - rc, out, err = misc.execCmd(initCommand, cwd=self.lockUtilPath) + rc, out, err = misc.run_cmd(initCommand, cwd=self.lockUtilPath) if rc != 0: self.log.warn("could not initialise spm lease (%s): %s", rc, out) raise se.ClusterLockInitError() @@ -143,7 +143,7 @@ cmd = [constants.EXT_SU, misc.IOUSER, '-s', constants.EXT_SH, '-c', acquireLockCommand] - (rc, out, err) = misc.execCmd(cmd, cwd=self.lockUtilPath, + (rc, out, err) = misc.run_cmd(cmd, cwd=self.lockUtilPath, sudo=True, ioclass=utils.IOCLASS.REALTIME, ioclassdata=0, setsid=True) @@ -163,7 +163,7 @@ releaseLockCommand = [freeLockUtil, self._sdUUID] self.log.info("Releasing cluster lock for domain %s" % self._sdUUID) - (rc, out, err) = misc.execCmd(releaseLockCommand, raw=True, + (rc, out, err) = misc.run_cmd(releaseLockCommand, raw=True, cwd=self.lockUtilPath) if rc != 0: # TODO: should raise diff --git a/lib/vdsm/storage/curlImgWrap.py b/lib/vdsm/storage/curlImgWrap.py index d3610d3..768b68b 100644 --- a/lib/vdsm/storage/curlImgWrap.py +++ b/lib/vdsm/storage/curlImgWrap.py @@ -54,7 +54,7 @@ cmd = [_curl.cmd] + CURL_OPTIONS + ["--head", url] cmd.extend(_headersToOptions(headers)) - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise CurlError(rc, out, err) @@ -67,7 +67,7 @@ cmd = [constants.EXT_CURL_IMG_WRAP, "--download"] cmd.extend(_headersToOptions(headers) + [path, url]) - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise CurlError(rc, out, err) @@ -77,7 +77,7 @@ cmd = [constants.EXT_CURL_IMG_WRAP, "--upload"] cmd.extend(_headersToOptions(headers) + [path, url]) - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise CurlError(rc, out, err) diff --git a/lib/vdsm/storage/devicemapper.py b/lib/vdsm/storage/devicemapper.py index 90ba81a..acdca0c 100644 --- a/lib/vdsm/storage/devicemapper.py +++ b/lib/vdsm/storage/devicemapper.py @@ -122,7 +122,7 @@ def _removeMapping(deviceName): cmd = [EXT_DMSETUP, "remove", deviceName] - rc = misc.execCmd(cmd)[0] + rc = misc.run_cmd(cmd)[0] if rc != 0: raise Exception("Could not remove mapping `%s`" % deviceName) @@ -153,7 +153,7 @@ def _getPathsStatus(): cmd = [EXT_DMSETUP, "status"] - rc, out, err = misc.execCmd(cmd) + rc, out, err = misc.run_cmd(cmd) if rc != 0: raise Exception("Could not get device statuses") diff --git a/lib/vdsm/storage/fuser.py b/lib/vdsm/storage/fuser.py index ec4aa48..fef04c0 100644 --- a/lib/vdsm/storage/fuser.py +++ b/lib/vdsm/storage/fuser.py @@ -31,7 +31,7 @@ cmd.append("-m") cmd.append(path) - (rc, out, err) = misc.execCmd(cmd, raw=True) + (rc, out, err) = misc.run_cmd(cmd, raw=True) if rc != 0: return [] diff --git a/lib/vdsm/storage/hba.py b/lib/vdsm/storage/hba.py index 674eb92..2caf549 100644 --- a/lib/vdsm/storage/hba.py +++ b/lib/vdsm/storage/hba.py @@ -70,7 +70,7 @@ """ timeout = config.getint('irs', 'scsi_rescan_maximal_timeout') - proc = commands.startCmd([constants.EXT_FC_SCAN], execCmdLogger=log) + proc = commands.start_cmd([constants.EXT_FC_SCAN], execCmdLogger=log) try: proc.wait(timeout) finally: diff --git a/lib/vdsm/storage/misc.py b/lib/vdsm/storage/misc.py index 5c466a8..fb26ad2 100644 --- a/lib/vdsm/storage/misc.py +++ b/lib/vdsm/storage/misc.py @@ -159,7 +159,7 @@ logSkipName="Storage.Misc.excCmd") -execCmd = partial(logskip("Storage.Misc.excCmd")(commands.execCmd), +run_cmd = partial(logskip("Storage.Misc.excCmd")(commands.run_cmd), execCmdLogger=execCmdLogger) @@ -209,7 +209,7 @@ cmd = [constants.EXT_DD, "iflag=%s" % DIRECTFLAG, "skip=%d" % iooffset, "bs=%d" % iounit, "if=%s" % name, "count=%s" % count] - (rc, out, err) = execCmd(cmd, raw=True) + (rc, out, err) = run_cmd(cmd, raw=True) if rc: raise se.MiscBlockReadException(name, offset, size) if not validateDDBytes(err.splitlines(), iounit * count): @@ -302,7 +302,7 @@ cmd.append("oflag=%s" % oflag) if not stop: - (rc, out, err) = execCmd(cmd, nice=utils.NICENESS.HIGH, + (rc, out, err) = run_cmd(cmd, nice=utils.NICENESS.HIGH, ioclass=utils.IOCLASS.IDLE) else: (rc, out, err) = watchCmd(cmd, stop=stop, diff --git a/lib/vdsm/storage/mount.py b/lib/vdsm/storage/mount.py index e83132c..2b1d7b9 100644 --- a/lib/vdsm/storage/mount.py +++ b/lib/vdsm/storage/mount.py @@ -301,7 +301,7 @@ def _runcmd(cmd, timeout): - p = commands.startCmd(cmd) + p = commands.start_cmd(cmd) if not p.wait(timeout): p.kill() raise OSError(errno.ETIMEDOUT, diff --git a/lib/vdsm/taskset.py b/lib/vdsm/taskset.py index 6ea19c5..cbe6647 100644 --- a/lib/vdsm/taskset.py +++ b/lib/vdsm/taskset.py @@ -42,7 +42,7 @@ """ command = [constants.EXT_TASKSET, '--pid', str(pid)] - rc, out, err = commands.execCmd(command, resetCpuAffinity=False) + rc, out, err = commands.run_cmd(command, resetCpuAffinity=False) if rc != 0: raise cmdutils.Error(command, rc, out, err) @@ -70,7 +70,7 @@ str(pid) )) - rc, out, err = commands.execCmd(command, resetCpuAffinity=False) + rc, out, err = commands.run_cmd(command, resetCpuAffinity=False) if rc != 0: raise cmdutils.Error(command, rc, out, err) diff --git a/lib/vdsm/tool/configurators/certificates.py b/lib/vdsm/tool/configurators/certificates.py index bdb686a..36fb17e 100644 --- a/lib/vdsm/tool/configurators/certificates.py +++ b/lib/vdsm/tool/configurators/certificates.py @@ -25,7 +25,7 @@ from . import YES, NO from vdsm.tool.validate_ovirt_certs import validate_ovirt_certs from vdsm.constants import P_VDSM_EXEC, SYSCONF_PATH -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import isOvirtNode PKI_DIR = os.path.join(SYSCONF_PATH, 'pki/vdsm') @@ -39,7 +39,7 @@ def _exec_vdsm_gencerts(): - rc, out, err = execCmd( + rc, out, err = run_cmd( ( os.path.join( P_VDSM_EXEC, diff --git a/lib/vdsm/tool/configurators/multipath.py b/lib/vdsm/tool/configurators/multipath.py index 00ec558..e8301b2 100644 --- a/lib/vdsm/tool/configurators/multipath.py +++ b/lib/vdsm/tool/configurators/multipath.py @@ -136,7 +136,7 @@ utils.persist(_CONF_FILE) # Flush all unused multipath device maps - commands.execCmd([constants.EXT_MULTIPATH, "-F"]) + commands.run_cmd([constants.EXT_MULTIPATH, "-F"]) try: service.service_reload("multipathd") diff --git a/lib/vdsm/tool/configurators/passwd.py b/lib/vdsm/tool/configurators/passwd.py index 62830df..637bf45 100644 --- a/lib/vdsm/tool/configurators/passwd.py +++ b/lib/vdsm/tool/configurators/passwd.py @@ -39,7 +39,7 @@ def isconfigured(): script = (str(_SASLDBLISTUSERS2), '-f', _LIBVIRT_SASLDB) - _, out, _ = commands.execCmd(script) + _, out, _ = commands.run_cmd(script) for user in out: if SASL_USERNAME in user: return YES @@ -48,7 +48,7 @@ def configure(): script = (str(_SASLPASSWD2), '-p', '-a', 'libvirt', SASL_USERNAME) - rc, _, err = commands.execCmd(script, data=libvirt_password()) + rc, _, err = commands.run_cmd(script, data=libvirt_password()) if rc != 0: raise RuntimeError("Set password failed: %s" % (err,)) if utils.isOvirtNode(): @@ -59,7 +59,7 @@ def removeConf(): if isconfigured() == YES: - rc, out, err = commands.execCmd( + rc, out, err = commands.run_cmd( ( str(_SASLPASSWD2), '-p', diff --git a/lib/vdsm/tool/configurators/sanlock.py b/lib/vdsm/tool/configurators/sanlock.py index 959fcc6..d257884 100644 --- a/lib/vdsm/tool/configurators/sanlock.py +++ b/lib/vdsm/tool/configurators/sanlock.py @@ -35,7 +35,7 @@ """ Configure sanlock process groups """ - rc, out, err = commands.execCmd( + rc, out, err = commands.run_cmd( ( '/usr/sbin/usermod', '-a', diff --git a/lib/vdsm/tool/dummybr.py b/lib/vdsm/tool/dummybr.py index a0f76ed..0fa63a4 100644 --- a/lib/vdsm/tool/dummybr.py +++ b/lib/vdsm/tool/dummybr.py @@ -28,7 +28,7 @@ def createEphemeralBridge(bridgeName): - rc, out, err = commands.execCmd([constants.EXT_BRCTL, 'addbr', bridgeName]) + rc, out, err = commands.run_cmd([constants.EXT_BRCTL, 'addbr', bridgeName]) if rc != 0: raise EnvironmentError( 'Failed to create ephemeral dummy bridge. Err: %s' % err diff --git a/lib/vdsm/tool/restore_nets.py b/lib/vdsm/tool/restore_nets.py index 80ea675..794b324 100644 --- a/lib/vdsm/tool/restore_nets.py +++ b/lib/vdsm/tool/restore_nets.py @@ -47,7 +47,7 @@ def exec_restore(cmd): - rc, out, err = commands.execCmd(cmd, raw=True) + rc, out, err = commands.run_cmd(cmd, raw=True) sys.stdout.write(out) sys.stderr.write(err) if rc != 0: diff --git a/lib/vdsm/tool/service.py b/lib/vdsm/tool/service.py index 67c5b41..22ea6ea 100644 --- a/lib/vdsm/tool/service.py +++ b/lib/vdsm/tool/service.py @@ -30,10 +30,10 @@ from . import expose, UsageError, ExtraArgsError from ..utils import CommandPath -from ..commands import execCmd as _execCmd +from ..commands import run_cmd as _execCmd -def execCmd(argv, raw=True, *args, **kwargs): +def run_cmd(argv, raw=True, *args, **kwargs): return _execCmd(argv, raw=raw, *args, **kwargs) @@ -108,7 +108,7 @@ @functools.wraps(systemctlFun) def wrapper(srvName): cmd = [_SYSTEMCTL.cmd, "--no-pager", "list-unit-files"] - rc, out, err = execCmd(cmd, raw=False) + rc, out, err = run_cmd(cmd, raw=False) if rc != 0: raise ServiceOperationError( "Error listing unit files", '\n'.join(out), '\n'.join(err)) @@ -123,32 +123,32 @@ @_systemctlNative def _systemctlStart(srvName): cmd = [_SYSTEMCTL.cmd, "start", srvName] - return execCmd(cmd) + return run_cmd(cmd) @_systemctlNative def _systemctlStop(srvName): cmd = [_SYSTEMCTL.cmd, "stop", srvName] - return execCmd(cmd) + return run_cmd(cmd) @_systemctlNative def _systemctlStatus(srvName): cmd = [_SYSTEMCTL.cmd, "status", srvName] - return execCmd(cmd) + return run_cmd(cmd) @_systemctlNative def _systemctlRestart(srvName): cmd = [_SYSTEMCTL.cmd, "restart", srvName] - return execCmd(cmd) + return run_cmd(cmd) @_systemctlNative def _systemctlReload(srvName): cmd = [_SYSTEMCTL.cmd, "reload", srvName] - return execCmd(cmd) + return run_cmd(cmd) @_systemctlNative def _systemctlDisable(srvName): cmd = [_SYSTEMCTL.cmd, "disable", srvName] - return execCmd(cmd) + return run_cmd(cmd) @_systemctlNative def _systemctlIsManaged(srvName): @@ -176,7 +176,7 @@ @functools.wraps(initctlFun) def wrapper(srvName): cmd = [_INITCTL.cmd, "usage", srvName] - rc, out, err = execCmd(cmd, raw=False) + rc, out, err = run_cmd(cmd, raw=False) if rc != 0: raise ServiceNotExistError("%s is not an Upstart service" % srvName) @@ -188,7 +188,7 @@ def _initctlStart(srvName): cmd = [_INITCTL.cmd, "start", srvName] alreadyRunRegex = r"\bis already running\b" - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) if rc != 0: # initctl returns an error if the job is already started # here we ignore it and return 0 if the job is already running @@ -199,7 +199,7 @@ def _initctlStop(srvName): cmd = [_INITCTL.cmd, "stop", srvName] alreadyStoppedRegex = r'\bUnknown instance\b' - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) if rc != 0: # initctl returns an error if the job is already stopped # here we ignore it and return 0 if the job is already stopped @@ -209,7 +209,7 @@ @_initctlNative def _initctlStatus(srvName): cmd = [_INITCTL.cmd, "status", srvName] - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) if rc == 0: # initctl rc is 0 even though the service is stopped rc = _isStopped(out) @@ -225,7 +225,7 @@ @_initctlNative def _initctlReload(srvName): cmd = [_INITCTL.cmd, "reload", srvName] - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) return (rc, out, err) @_initctlNative @@ -266,7 +266,7 @@ else: _sysvEnv = os.environ.copy() _sysvEnv['SYSTEMCTL_SKIP_REDIRECT'] = '1' - _execSysvEnv = functools.partial(execCmd, env=_sysvEnv) + _execSysvEnv = functools.partial(run_cmd, env=_sysvEnv) @_sysvNative def _serviceStart(srvName): @@ -322,7 +322,7 @@ @_sysvNative def _chkconfigDisable(srvName): cmd = [_CHKCONFIG.cmd, srvName, "off"] - return execCmd(cmd) + return run_cmd(cmd) _srvDisableAlts.append(_chkconfigDisable) @@ -335,7 +335,7 @@ @_sysvNative def _updatercDisable(srvName): cmd = [_UPDATERC.cmd, srvName, "disable"] - return execCmd(cmd) + return run_cmd(cmd) _srvDisableAlts.append(_updatercDisable) diff --git a/lib/vdsm/tool/transient.py b/lib/vdsm/tool/transient.py index 4d33f62..b55e12c 100644 --- a/lib/vdsm/tool/transient.py +++ b/lib/vdsm/tool/transient.py @@ -26,7 +26,7 @@ from .. import constants from ..config import config from . import expose, ExtraArgsError -from ..commands import execCmd +from ..commands import run_cmd from ..utils import CommandPath @@ -77,7 +77,7 @@ if len(transient_images) == 0: return # Nothing to do - cmd_ret, cmd_out, cmd_err = execCmd([_fuser.cmd] + list(transient_images)) + cmd_ret, cmd_out, cmd_err = run_cmd([_fuser.cmd] + list(transient_images)) # According to: "fuser returns a non-zero return code if none of the # specified files is accessed or in case of a fatal error. If at least # one access has been found, fuser returns zero." we can discard the diff --git a/lib/vdsm/tool/validate_ovirt_certs.py.in b/lib/vdsm/tool/validate_ovirt_certs.py.in index 53726d0..0c271c4 100644 --- a/lib/vdsm/tool/validate_ovirt_certs.py.in +++ b/lib/vdsm/tool/validate_ovirt_certs.py.in @@ -23,7 +23,7 @@ import shutil from . import expose, ExtraArgsError -from ..commands import execCmd +from ..commands import run_cmd try: from ovirtnode import ovirtfunctions @@ -40,7 +40,7 @@ def is_our_cafile(cacert): cmd = [EX_OPENSSL, 'verify', '-CAfile', cacert, PATH_VDSMCERT] - rc, out, err = execCmd(cmd, raw=True) + rc, out, err = run_cmd(cmd, raw=True) return out.rstrip('\n') == '%s: OK' % PATH_VDSMCERT diff --git a/lib/vdsm/udevadm.py b/lib/vdsm/udevadm.py index 86079c9..bdf1aea 100644 --- a/lib/vdsm/udevadm.py +++ b/lib/vdsm/udevadm.py @@ -101,6 +101,6 @@ def _run_command(args): cmd = [_UDEVADM.cmd] cmd.extend(args) - rc, out, err = commands.execCmd(cmd, raw=True) + rc, out, err = commands.run_cmd(cmd, raw=True) if rc != 0: raise cmdutils.Error(cmd, rc, out, err) diff --git a/lib/vdsm/v2v.py b/lib/vdsm/v2v.py index f5d8a7e..feccd4e 100644 --- a/lib/vdsm/v2v.py +++ b/lib/vdsm/v2v.py @@ -40,8 +40,8 @@ import libvirt -from vdsm.commands import execCmd -from vdsm.commands import startCmd +from vdsm.commands import run_cmd +from vdsm.commands import start_cmd from vdsm.common import zombiereaper from vdsm.constants import P_VDSM_RUN, EXT_KVM_2_OVIRT from vdsm.define import errCode, doneCode @@ -330,7 +330,7 @@ self._ssh_auth_re = re.compile(_SSH_AUTH_RE) def __enter__(self): - rc, out, err = execCmd([_SSH_AGENT.cmd], raw=True) + rc, out, err = run_cmd([_SSH_AGENT.cmd], raw=True) if rc != 0: raise V2VError('Error init ssh-agent, exit code: %r' ', out: %r, err: %r' % @@ -342,7 +342,7 @@ self._agent_pid = m.group(3) try: - rc, out, err = execCmd([_SSH_ADD.cmd], env=self._auth) + rc, out, err = run_cmd([_SSH_ADD.cmd], env=self._auth) except: self._kill_agent() raise @@ -357,7 +357,7 @@ (rc, out, err)) def __exit__(self, *args): - rc, out, err = execCmd([_SSH_ADD.cmd, '-d'], env=self._auth) + rc, out, err = run_cmd([_SSH_ADD.cmd, '-d'], env=self._auth) if rc != 0: logging.error('Error deleting ssh-add, exit code: %r' ', out: %r, err: %r' % @@ -366,7 +366,7 @@ self._kill_agent() def _kill_agent(self): - rc, out, err = execCmd([_SSH_AGENT.cmd, '-k'], + rc, out, err = run_cmd([_SSH_AGENT.cmd, '-k'], env={'SSH_AGENT_PID': self._agent_pid}) if rc != 0: logging.error('Error killing ssh-agent (PID=%r), exit code: %r' @@ -390,11 +390,11 @@ raise NotImplementedError("Subclass must implement this") def _start_helper(self): - return startCmd(self._command(), - deathSignal=signal.SIGTERM, - nice=NICENESS.HIGH, - ioclass=IOCLASS.IDLE, - env=self._environment()) + return start_cmd(self._command(), + deathSignal=signal.SIGTERM, + nice=NICENESS.HIGH, + ioclass=IOCLASS.IDLE, + env=self._environment()) def _get_disk_format(self): fmt = self._vminfo.get('format', 'raw').lower() diff --git a/lib/vdsm/virtsparsify.py b/lib/vdsm/virtsparsify.py index 014b9c5..01cefeb 100644 --- a/lib/vdsm/virtsparsify.py +++ b/lib/vdsm/virtsparsify.py @@ -50,7 +50,7 @@ cmd.extend((src_vol, dst_vol)) - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise cmdutils.Error(cmd, rc, out, err) diff --git a/tests/alignmentScanTests.py b/tests/alignmentScanTests.py index 076a559..7d516a6 100644 --- a/tests/alignmentScanTests.py +++ b/tests/alignmentScanTests.py @@ -23,7 +23,7 @@ import tempfile from nose.tools import eq_, raises from nose.plugins.skip import SkipTest -from vdsm.storage.misc import execCmd +from vdsm.storage.misc import run_cmd from testlib import VdsmTestCase as TestCaseBase from testValidation import brokentest, slowtest from alignmentScan import runScanArgs, scanImage, VirtAlignError @@ -33,7 +33,7 @@ open(imagepath, "wb").truncate(4 * 1024 ** 3) cmd = ["/sbin/sfdisk", "-uS", "--force", imagepath] cmd_input = "128,,\n" if aligned else "1,,\n" - rc, out, err = execCmd(cmd, data=cmd_input) + rc, out, err = run_cmd(cmd, data=cmd_input) assert rc == 0 diff --git a/tests/capsTests.py b/tests/capsTests.py index 82eb559..5ce505e 100644 --- a/tests/capsTests.py +++ b/tests/capsTests.py @@ -169,7 +169,7 @@ '17': [40, 40, 20, 10]} self.assertEqual(t, expectedDistanceInfo) - @MonkeyPatch(commands, 'execCmd', lambda x, raw: (0, ['0'], [])) + @MonkeyPatch(commands, 'run_cmd', lambda x, raw: (0, ['0'], [])) def testAutoNumaBalancingInfo(self): t = numa.autonuma_status() self.assertEqual(t, 0) diff --git a/tests/commands_test.py b/tests/commands_test.py index cb7dda2..a5dcf44 100644 --- a/tests/commands_test.py +++ b/tests/commands_test.py @@ -39,20 +39,20 @@ @permutations(CMD_TYPES) def testNormal(self, cmd): - rc, out, _ = commands.execCmd(cmd(('echo', 'hello world'))) + rc, out, _ = commands.run_cmd(cmd(('echo', 'hello world'))) self.assertEquals(rc, 0) self.assertEquals(out[0], 'hello world') @permutations(CMD_TYPES) def testIoClass(self, cmd): - rc, out, _ = commands.execCmd(cmd(('ionice',)), ioclass=2, + rc, out, _ = commands.run_cmd(cmd(('ionice',)), ioclass=2, ioclassdata=3) self.assertEquals(rc, 0) self.assertEquals(out[0].strip(), 'best-effort: prio 3') @permutations(CMD_TYPES) def testNice(self, cmd): - rc, out, _ = commands.execCmd(cmd(('cat', '/proc/self/stat')), nice=7) + rc, out, _ = commands.run_cmd(cmd(('cat', '/proc/self/stat')), nice=7) self.assertEquals(rc, 0) self.assertEquals(int(out[0].split()[18]), 7) @@ -60,13 +60,13 @@ def testSetSid(self, cmd): cmd_args = (constants.EXT_PYTHON, '-c', 'import os; print os.getsid(os.getpid())') - rc, out, _ = commands.execCmd(cmd(cmd_args), setsid=True) + rc, out, _ = commands.run_cmd(cmd(cmd_args), setsid=True) self.assertNotEquals(int(out[0]), os.getsid(os.getpid())) @permutations(CMD_TYPES) def testSudo(self, cmd): checkSudo(['echo']) - rc, out, _ = commands.execCmd(cmd(('grep', + rc, out, _ = commands.run_cmd(cmd(('grep', 'Uid', '/proc/self/status')), sudo=True) self.assertEquals(rc, 0) @@ -141,7 +141,7 @@ def run_dd(self, args): cmd = [constants.EXT_DD] cmd.extend(args) - rc, out, err = commands.execCmd(cmd, raw=True, data=self.data) + rc, out, err = commands.run_cmd(cmd, raw=True, data=self.data) if rc != 0: raise self.failureException("Process failed: rc=%d err=%r" % (rc, err)) diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py index 2da3b73..77432db 100644 --- a/tests/functional/networkTests.py +++ b/tests/functional/networkTests.py @@ -53,7 +53,7 @@ from vdsm.network import tc from vdsm import sysctl -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import CommandPath, RollbackContext, pgrep, running, memoized from hookValidation import ValidatesHook @@ -493,7 +493,7 @@ prevTxStat, prevTime = getStatsFromInterface(left) # running ARP from the interface - rc, out, err = execCmd([_ARPPING_COMMAND.cmd, '-D', '-I', left, + rc, out, err = run_cmd([_ARPPING_COMMAND.cmd, '-D', '-I', left, '-c', '1', IP_ADDRESS_IN_NETWORK]) if rc != 0: raise SkipTest('Could not run arping', out, err) @@ -698,13 +698,13 @@ self.assertEqual(status, errors.ERR_BAD_PARAMS, msg) def _setup_overExistingBridge(): - rc, _, err = execCmd([EXT_BRCTL, 'addbr', NETWORK_NAME]) + rc, _, err = run_cmd([EXT_BRCTL, 'addbr', NETWORK_NAME]) if rc != 0: raise errors.ConfigNetworkError(errors.ERR_FAILED_IFUP, err) def _teardown_overExistingBridge(): if os.path.exists('/sys/class/net/%s/bridge' % NETWORK_NAME): - rc, _, err = execCmd([EXT_BRCTL, 'delbr', NETWORK_NAME]) + rc, _, err = run_cmd([EXT_BRCTL, 'delbr', NETWORK_NAME]) if rc != 0: raise errors.ConfigNetworkError(errors.ERR_FAILED_IFDOWN, err) @@ -936,7 +936,7 @@ def add_tap_to_bridge(): tap = Tap(prefix='vnet') tap.addDevice() - rc, _, _ = execCmd([EXT_BRCTL, 'addif', NETWORK_NAME, tap.devName]) + rc, _, _ = run_cmd([EXT_BRCTL, 'addif', NETWORK_NAME, tap.devName]) self.assertEquals(rc, 0, 'brctl addif failed: rc=%s' % (rc,)) return tap @@ -967,9 +967,9 @@ if legacy_switch.ConfiguratorClass == Ifcfg: # verify that the ifcfg configuration files are also updated # with the new MTU - rc, _, _ = execCmd([EXT_IFDOWN, NETWORK_NAME]) + rc, _, _ = run_cmd([EXT_IFDOWN, NETWORK_NAME]) self.assertEquals(rc, 0, 'ifdown failed: rc=%s' % (rc,)) - rc, _, _ = execCmd([EXT_IFUP, NETWORK_NAME]) + rc, _, _ = run_cmd([EXT_IFUP, NETWORK_NAME]) self.assertEquals(rc, 0, 'ifup failed: rc=%s' % (rc,)) self.vdsm_net.refreshNetinfo() self.assertMtu(BIG, NETWORK_NAME, second) @@ -1536,7 +1536,7 @@ addrFlush(NET_CHANGED) linkSet(NET_MISSING, ['down']) - execCmd([EXT_BRCTL, 'delbr', NET_MISSING]) + run_cmd([EXT_BRCTL, 'delbr', NET_MISSING]) linkDel(BOND_MISSING) self.vdsm_net.refreshNetinfo() self.assertEqual( @@ -2308,7 +2308,7 @@ self.assertNetworkExists(NETWORK_NAME) # Remove the nic from the bridge - execCmd([EXT_BRCTL, 'delif', NETWORK_NAME, nic]) + run_cmd([EXT_BRCTL, 'delif', NETWORK_NAME, nic]) self.vdsm_net.refreshNetinfo() self.assertEqual(len( self.vdsm_net.netinfo.networks[NETWORK_NAME]['ports']), 0) @@ -3002,17 +3002,17 @@ with open(NET_CONF_PREF + bond_name + '.' + vlan_id, 'w') as f: f.write(IFCFG_VLAN_TEMPLATE % (bond_name, vlan_id)) - rc, _, err = execCmd([EXT_IFUP, bond_name]) + rc, _, err = run_cmd([EXT_IFUP, bond_name]) self.assertEqual(rc, SUCCESS, err) - rc, _, err = execCmd([EXT_IFUP, bond_name + '.' + vlan_id]) + rc, _, err = run_cmd([EXT_IFUP, bond_name + '.' + vlan_id]) self.assertEqual(rc, SUCCESS, err) try: yield finally: - rc, _, err = execCmd([EXT_IFDOWN, bond_name + '.' + vlan_id]) + rc, _, err = run_cmd([EXT_IFDOWN, bond_name + '.' + vlan_id]) self.assertEqual(rc, SUCCESS, err) - rc, _, err = execCmd([EXT_IFDOWN, bond_name]) + rc, _, err = run_cmd([EXT_IFDOWN, bond_name]) self.assertEqual(rc, SUCCESS, err) # The bond needs to be removed by force diff --git a/tests/functional/virtTests.py b/tests/functional/virtTests.py index 202ffa4..6fb1950 100644 --- a/tests/functional/virtTests.py +++ b/tests/functional/virtTests.py @@ -37,7 +37,7 @@ from vdsm import cpuarch from vdsm.utils import CommandPath from vdsm.virt import vmstatus -from vdsm.storage.misc import execCmd +from vdsm.storage.misc import run_cmd from utils import getProxy, SUCCESS @@ -98,7 +98,7 @@ logging.warning('Generating a temporary initramfs image') fd, path = tempfile.mkstemp() cmd = [_mkinitrd.cmd, "-f", path, _kernelVer] - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) os.chmod(path, 0o644) return path diff --git a/tests/iscsiTests.py b/tests/iscsiTests.py index 9755e0f..f738fd7 100644 --- a/tests/iscsiTests.py +++ b/tests/iscsiTests.py @@ -15,7 +15,7 @@ def fake_rescan(timeout): def func(): - proc = commands.startCmd(["sleep", str(timeout)]) + proc = commands.start_cmd(["sleep", str(timeout)]) return utils.AsyncProcessOperation(proc) return func diff --git a/tests/miscTests.py b/tests/miscTests.py index 658a965..8b15c6d 100644 --- a/tests/miscTests.py +++ b/tests/miscTests.py @@ -238,7 +238,7 @@ The Doctor: And where do you function? Striker: Eternity. The endless wastes of eternity. """ # (C) BBC - Doctor Who - p = commands.startCmd([EXT_CAT]) + p = commands.start_cmd([EXT_CAT]) self.log.info("Writing data to std out") p.stdin.write(data) p.stdin.flush() @@ -253,7 +253,7 @@ I'm pretty sure it wasn't the future. """ # (C) BBC - Doctor Who halfPoint = len(data) / 2 - p = commands.startCmd([EXT_CAT]) + p = commands.start_cmd([EXT_CAT]) self.log.info("Writing data to std out") p.stdin.write(data[:halfPoint]) self.log.info("Writing more data to std out") @@ -283,7 +283,7 @@ # (C) BBC - Doctor Who data = data * 100 - p = commands.startCmd([EXT_CAT]) + p = commands.start_cmd([EXT_CAT]) self.log.info("Writing data to std out") p.stdin.write(data) p.stdin.flush() @@ -292,7 +292,7 @@ def testWaitTimeout(self): ttl = 2 - p = commands.startCmd([EXT_SLEEP, str(ttl + 10)]) + p = commands.start_cmd([EXT_SLEEP, str(ttl + 10)]) startTime = time.time() p.wait(ttl) duration = time.time() - startTime @@ -302,7 +302,7 @@ def testWaitCond(self): ttl = 2 - p = commands.startCmd([EXT_SLEEP, str(ttl + 10)]) + p = commands.start_cmd([EXT_SLEEP, str(ttl + 10)]) startTime = time.time() p.wait(cond=lambda: time.time() - startTime > ttl) duration = time.time() - startTime @@ -313,7 +313,7 @@ def testCommunicate(self): data = ("The trouble with the world is that the stupid are cocksure " "and the intelligent are full of doubt") - p = commands.startCmd([EXT_DD], data=data) + p = commands.start_cmd([EXT_DD], data=data) p.stdin.close() self.assertEquals(p.stdout.read(len(data)).strip(), data) @@ -677,7 +677,7 @@ with tempfile.NamedTemporaryFile() as f: cmd = [EXT_DD, "bs=1", "if=/dev/urandom", 'of=%s' % f.name, 'count=%d' % count] - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) self.assertTrue(misc.validateDDBytes(err, count)) @@ -689,7 +689,7 @@ with tempfile.NamedTemporaryFile() as f: cmd = [EXT_DD, "bs=1", "if=/dev/urandom", 'of=%s' % f.name, 'count=%d' % count] - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) self.assertFalse(misc.validateDDBytes(err, count + 1)) @@ -940,42 +940,42 @@ def testExec(self): """ - Tests that execCmd execs and returns the correct ret code + Tests that run_cmd execs and returns the correct ret code """ - ret, out, err = commands.execCmd([EXT_ECHO]) + ret, out, err = commands.run_cmd([EXT_ECHO]) self.assertEquals(ret, 0) @MonkeyPatch(cmdutils, "_USING_CPU_AFFINITY", True) def testNoCommandWithAffinity(self): - rc, _, _ = commands.execCmd(["I.DONT.EXIST"]) + rc, _, _ = commands.run_cmd(["I.DONT.EXIST"]) self.assertNotEqual(rc, 0) @MonkeyPatch(cmdutils, "_USING_CPU_AFFINITY", False) def testNoCommandWithoutAffinity(self): - self.assertRaises(OSError, commands.execCmd, ["I.DONT.EXIST"]) + self.assertRaises(OSError, commands.run_cmd, ["I.DONT.EXIST"]) def testStdOut(self): """ - Tests that execCmd correctly returns the standard output of the prog it + Tests that run_cmd correctly returns the standard output of the prog it executes. """ line = "All I wanted was to have some pizza, hang out with dad, " + \ "and not let your weirdness mess up my day" # (C) Nickolodeon - Invader Zim - ret, stdout, stderr = commands.execCmd((EXT_ECHO, line)) + ret, stdout, stderr = commands.run_cmd((EXT_ECHO, line)) self.assertEquals(stdout[0], line) def testStdErr(self): """ - Tests that execCmd correctly returns the standard error of the prog it + Tests that run_cmd correctly returns the standard error of the prog it executes. """ line = "Hey Scully, is this display of boyish agility " + \ "turning you on at all?" # (C) Fox - The X Files code = "import sys; sys.stderr.write('%s')" % line - ret, stdout, stderr = commands.execCmd([EXT_PYTHON, "-c", code]) + ret, stdout, stderr = commands.run_cmd([EXT_PYTHON, "-c", code]) self.assertEquals(stderr[0], line) def testSudo(self): @@ -985,12 +985,12 @@ """ cmd = [EXT_WHOAMI] checkSudo(cmd) - ret, stdout, stderr = commands.execCmd(cmd, sudo=True) + ret, stdout, stderr = commands.run_cmd(cmd, sudo=True) self.assertEquals(stdout[0], SUDO_USER) def testNice(self): cmd = ["sleep", "10"] - proc = commands.startCmd(cmd, nice=10) + proc = commands.start_cmd(cmd, nice=10) def test(): nice = utils.pidStat(proc.pid).nice diff --git a/tests/mkimageTests.py b/tests/mkimageTests.py index d44054f..bd0e57c 100644 --- a/tests/mkimageTests.py +++ b/tests/mkimageTests.py @@ -37,7 +37,7 @@ from testValidation import checkSudo, ValidateRunningAsRoot from vdsm import udevadm -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import stopwatch from vdsm.storage import mount import mkimage @@ -143,7 +143,7 @@ return cmd = ['blkid', '-s', 'LABEL', imgPath] try: - (ret, out, err) = execCmd(cmd, raw=True) + (ret, out, err) = run_cmd(cmd, raw=True) except OSError: raise SkipTest("cannot execute blkid") diff --git a/tests/modprobe.py b/tests/modprobe.py index 6ee60d0..a1c9f9a 100644 --- a/tests/modprobe.py +++ b/tests/modprobe.py @@ -64,7 +64,7 @@ def _validate_module(name): if not os.path.exists('/sys/module/' + name): cmd_modprobe = [modprobe.cmd, name] - rc, out, err = commands.execCmd(cmd_modprobe, sudo=True) + rc, out, err = commands.run_cmd(cmd_modprobe, sudo=True) if rc != 0: raise SkipTest("This test requires %s module " "(failed to load module: rc=%s, out=%s, err=%s)" % diff --git a/tests/mountTests.py b/tests/mountTests.py index 0133a3f..fd108da 100644 --- a/tests/mountTests.py +++ b/tests/mountTests.py @@ -28,7 +28,7 @@ from vdsm import udevadm from vdsm.utils import stopwatch from vdsm.storage import mount -from vdsm.storage.misc import execCmd +from vdsm.storage.misc import run_cmd from nose.plugins.skip import SkipTest @@ -49,10 +49,10 @@ f.write('\0') try: - rc, out, err = execCmd(['/sbin/mkfs.ext2', "-F", path]) + rc, out, err = run_cmd(['/sbin/mkfs.ext2', "-F", path]) except OSError: try: - rc, out, err = execCmd(['/usr/sbin/mkfs.ext2', "-F", path]) + rc, out, err = run_cmd(['/usr/sbin/mkfs.ext2', "-F", path]) except OSError as e: if e.errno == errno.ENOENT: raise SkipTest("cannot execute mkfs.ext2") @@ -147,7 +147,7 @@ mountpoint = os.path.join(root_dir, 'mountpoint') with open(backing_image, 'w') as f: os.ftruncate(f.fileno(), 1024 ** 3) - rc, out, err = execCmd(['/sbin/mkfs.ext2', "-F", backing_image], + rc, out, err = run_cmd(['/sbin/mkfs.ext2', "-F", backing_image], raw=True) if rc != 0: raise RuntimeError("Error creating filesystem: %s" % err) diff --git a/tests/network/dhcp.py b/tests/network/dhcp.py index 044283e..e213183 100644 --- a/tests/network/dhcp.py +++ b/tests/network/dhcp.py @@ -24,7 +24,7 @@ from signal import SIGKILL, SIGTERM from time import sleep, time -from vdsm.commands import execCmd, startCmd +from vdsm.commands import run_cmd, start_cmd from vdsm.utils import CommandPath _DNSMASQ_BINARY = CommandPath('dnsmasq', '/usr/sbin/dnsmasq') @@ -72,7 +72,7 @@ command += ['--enable-ra'] command += ['--dhcp-range={0},slaac,2m'.format(ipv6_slaac_prefix)] - self.proc = startCmd(command) + self.proc = start_cmd(command) sleep(_START_CHECK_TIMEOUT) if self.proc.returncode: raise DhcpError('Failed to start dnsmasq DHCP server.\n%s\n%s' % @@ -118,7 +118,7 @@ def start(self): self._create_conf() - rc, out, err = execCmd(self._cmd) + rc, out, err = run_cmd(self._cmd) if rc: # == 2 logging.debug(''.join(err)) diff --git a/tests/network/firewall.py b/tests/network/firewall.py index e2f7999..5aa951a 100644 --- a/tests/network/firewall.py +++ b/tests/network/firewall.py @@ -23,7 +23,7 @@ from nose.plugins.skip import SkipTest -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import CommandPath _FIREWALLD_BINARY = CommandPath('firewall-cmd', '/bin/firewall-cmd') @@ -98,13 +98,13 @@ def _serviceRunning(name): - ret, _, _ = execCmd([_SERVICE_BINARY.cmd, name, 'status']) + ret, _, _ = run_cmd([_SERVICE_BINARY.cmd, name, 'status']) # return code 0 means service is running return not ret def _execCmdChecker(command): - ret, out, err = execCmd(command) + ret, out, err = run_cmd(command) if ret: raise FirewallError('Command {0} failed with {1}; {2}'.format( command, out, err)) diff --git a/tests/network/nettestlib.py b/tests/network/nettestlib.py index 9635f79..46cc79c 100644 --- a/tests/network/nettestlib.py +++ b/tests/network/nettestlib.py @@ -37,7 +37,7 @@ addrAdd, linkSet, linkAdd, linkDel, IPRoute2Error, netns_add, netns_delete, netns_exec) from vdsm.network.netlink import monitor -from vdsm.commands import execCmd, startCmd +from vdsm.commands import run_cmd, start_cmd from vdsm.utils import CommandPath, random_iface_name from . import dhcp @@ -55,7 +55,7 @@ def check_call(cmd): - rc, out, err = execCmd(cmd, raw=True) + rc, out, err = run_cmd(cmd, raw=True) if rc != 0: raise ExecError( 'Command %s returned non-zero exit status %s.' % (cmd, rc), @@ -259,7 +259,7 @@ if self._net_ns is not None: p = netns_exec(self._net_ns, cmd) else: - p = startCmd(cmd) + p = start_cmd(cmd) self._pid = p.pid def stop(self): @@ -287,14 +287,14 @@ str(self._threads), '--bind', self._bind_to, '--zerocopy', # use less cpu '--json'] - rc, self._raw_output, err = execCmd(cmd) + rc, self._raw_output, err = run_cmd(cmd) if rc == 1 and 'No route to host' in self.out['error']: # it seems that it takes some time for the routes to get updated # on the os so that we don't get this error, hence the horrific # sleep here. # TODO: Investigate, understand, and remove this sleep. time.sleep(3) - rc, self._raw_output, err = execCmd(cmd) + rc, self._raw_output, err = run_cmd(cmd) if rc: raise Exception('iperf3 client failed: cmd=%s, rc=%s, out=%s, ' 'err=%s' % (' '.join(cmd), rc, self._raw_output, @@ -353,7 +353,7 @@ def check_brctl(): try: - execCmd([EXT_BRCTL, "show"]) + run_cmd([EXT_BRCTL, "show"]) except OSError as e: if e.errno == errno.ENOENT: raise SkipTest("Cannot run %r: %s\nDo you have bridge-utils " diff --git a/tests/network/ovsnettestlib.py b/tests/network/ovsnettestlib.py index 7a20158..5f072a8 100644 --- a/tests/network/ovsnettestlib.py +++ b/tests/network/ovsnettestlib.py @@ -18,7 +18,7 @@ # from __future__ import absolute_import -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.network.ovs.driver import create @@ -31,12 +31,12 @@ class OvsService(object): def __init__(self): - rc, out, err = execCmd([OVS_CTL, 'status']) + rc, out, err = run_cmd([OVS_CTL, 'status']) self.ovs_init_state_is_up = (rc == 0) def setup(self): if not self.ovs_init_state_is_up: - execCmd([OVS_CTL, 'start']) + run_cmd([OVS_CTL, 'start']) def teardown(self): ovsdb = create() @@ -48,4 +48,4 @@ t.add(ovsdb.del_br(bridge['name'])) if not self.ovs_init_state_is_up: - execCmd([OVS_CTL, 'stop']) + run_cmd([OVS_CTL, 'stop']) diff --git a/tests/qemuimgTests.py b/tests/qemuimgTests.py index 0679bd8..ea1c0d7 100644 --- a/tests/qemuimgTests.py +++ b/tests/qemuimgTests.py @@ -93,21 +93,21 @@ out = "image: leaf.img\ninvalid file format line" return 0, out, "" - with MonkeyPatchScope([(commands, "execCmd", call)]): + with MonkeyPatchScope([(commands, "run_cmd", call)]): self.assertRaises(qemuimg.QImgError, qemuimg.info, 'leaf.img') @permutations((('format',), ('virtual-size',))) def test_missing_required_field_raises(self, field): data = self._fake_info() del data[field] - with MonkeyPatchScope([(commands, "execCmd", + with MonkeyPatchScope([(commands, "run_cmd", partial(fake_json_call, data))]): self.assertRaises(qemuimg.QImgError, qemuimg.info, 'leaf.img') def test_missing_compat_for_qcow2_raises(self): data = self._fake_info() del data['format-specific']['data']['compat'] - with MonkeyPatchScope([(commands, "execCmd", + with MonkeyPatchScope([(commands, "run_cmd", partial(fake_json_call, data))]): self.assertRaises(qemuimg.QImgError, qemuimg.info, 'leaf.img') @@ -118,7 +118,7 @@ def test_optional_fields(self, qemu_field, info_field): data = self._fake_info() del data[qemu_field] - with MonkeyPatchScope([(commands, "execCmd", + with MonkeyPatchScope([(commands, "run_cmd", partial(fake_json_call, data))]): info = qemuimg.info('unused') self.assertNotIn(info_field, info) @@ -131,7 +131,7 @@ "actual-size": 0, "dirty-flag": False } - with MonkeyPatchScope([(commands, "execCmd", + with MonkeyPatchScope([(commands, "run_cmd", partial(fake_json_call, data))]): info = qemuimg.info('unused') self.assertNotIn('compat', info) @@ -145,7 +145,7 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(commands, "execCmd", create)]): + with MonkeyPatchScope([(commands, "run_cmd", create)]): qemuimg.create('image') def test_zero_size(self): @@ -154,7 +154,7 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(commands, "execCmd", create)]): + with MonkeyPatchScope([(commands, "run_cmd", create)]): qemuimg.create('image', size=0) def test_qcow2_compat(self): @@ -166,7 +166,7 @@ return 0, '', '' with MonkeyPatchScope([(qemuimg, 'config', CONFIG), - (commands, 'execCmd', create)]): + (commands, 'run_cmd', create)]): qemuimg.create('image', format='qcow2') def test_invalid_config(self): @@ -256,7 +256,7 @@ self.assertEqual(int, type(info['offset'])) def test_offset_no_match(self): - with MonkeyPatchScope([(commands, "execCmd", + with MonkeyPatchScope([(commands, "run_cmd", partial(fake_json_call, {}))]): self.assertRaises(qemuimg.QImgError, qemuimg.check, 'unused') @@ -265,7 +265,7 @@ out = "image: leaf.img\ninvalid file format line" return 0, out, "" - with MonkeyPatchScope([(commands, "execCmd", call)]): + with MonkeyPatchScope([(commands, "run_cmd", call)]): self.assertRaises(qemuimg.QImgError, qemuimg.check, 'unused') diff --git a/tests/utilsTests.py b/tests/utilsTests.py index f3439d5..6ef4e8b 100644 --- a/tests/utilsTests.py +++ b/tests/utilsTests.py @@ -92,7 +92,7 @@ class TerminatingTests(TestCaseBase): def setUp(self): - self.proc = commands.startCmd([EXT_SLEEP, "2"]) + self.proc = commands.start_cmd([EXT_SLEEP, "2"]) self.proc_path = "/proc/%d" % self.proc.pid self.kill_proc = self.proc.kill self.assertTrue(os.path.exists(self.proc_path)) @@ -226,7 +226,7 @@ @MonkeyPatch(cmdutils, "_USING_CPU_AFFINITY", False) def test_without_affinity(self): args = ["sleep", "3"] - sproc = commands.startCmd(args) + sproc = commands.start_cmd(args) stats = utils.pidStat(sproc.pid) pid = int(stats.pid) # procName comes in the format of (procname) @@ -241,7 +241,7 @@ def test(self): sleepProcs = [] for i in range(3): - sleepProcs.append(commands.startCmd([EXT_SLEEP, "3"], sudo=False)) + sleepProcs.append(commands.start_cmd([EXT_SLEEP, "3"], sudo=False)) pids = utils.pgrep(EXT_SLEEP) for proc in sleepProcs: @@ -256,7 +256,7 @@ class GetCmdArgsTests(TestCaseBase): def test(self): args = [EXT_SLEEP, "4"] - sproc = commands.startCmd(args) + sproc = commands.start_cmd(args) try: cmd_args = utils.getCmdArgs(sproc.pid) # let's ignore optional taskset at the beginning @@ -268,7 +268,7 @@ def testZombie(self): args = [EXT_SLEEP, "0"] - sproc = commands.startCmd(args) + sproc = commands.start_cmd(args) sproc.kill() try: test = lambda: self.assertEquals(utils.getCmdArgs(sproc.pid), @@ -287,7 +287,7 @@ """Tests if CommandPath can find the executable like the 'which' unix tool""" cp = utils.CommandPath('sh', 'utter nonsense') - _, stdout, _ = commands.execCmd(['which', 'sh']) + _, stdout, _ = commands.run_cmd(['which', 'sh']) self.assertIn(cp.cmd, stdout) def testMissing(self): @@ -353,7 +353,7 @@ class AsyncProcessOperationTests(TestCaseBase): def _echo(self, text): - proc = commands.startCmd(["echo", "-n", "test"]) + proc = commands.start_cmd(["echo", "-n", "test"]) def parse(rc, out, err): return out @@ -361,11 +361,11 @@ return utils.AsyncProcessOperation(proc, parse) def _sleep(self, t): - proc = commands.startCmd(["sleep", str(t)]) + proc = commands.start_cmd(["sleep", str(t)]) return utils.AsyncProcessOperation(proc) def _fail(self, t): - proc = commands.startCmd(["sleep", str(t)]) + proc = commands.start_cmd(["sleep", str(t)]) def parse(rc, out, err): raise Exception("TEST!!!") @@ -633,7 +633,7 @@ @MonkeyPatch(cmdutils, '_USING_CPU_AFFINITY', False) def testResetAffinityByDefault(self): try: - proc = commands.startCmd((EXT_SLEEP, '30s')) + proc = commands.start_cmd((EXT_SLEEP, '30s')) self.assertEquals(taskset.get(proc.pid), taskset.get(os.getpid())) @@ -647,7 +647,7 @@ self.assertEquals(taskset.get(os.getpid()), self.CPU_SET) try: - proc = commands.startCmd((EXT_SLEEP, '30s')) + proc = commands.start_cmd((EXT_SLEEP, '30s')) self.assertEquals(taskset.get(proc.pid), online_cpus()) finally: @@ -660,8 +660,8 @@ self.assertEquals(taskset.get(os.getpid()), self.CPU_SET) try: - proc = commands.startCmd((EXT_SLEEP, '30s'), - resetCpuAffinity=False) + proc = commands.start_cmd((EXT_SLEEP, '30s'), + resetCpuAffinity=False) self.assertEquals(taskset.get(proc.pid), self.CPU_SET) finally: diff --git a/tests/v2vTests.py b/tests/v2vTests.py index b7bfc54..24443c1 100644 --- a/tests/v2vTests.py +++ b/tests/v2vTests.py @@ -31,7 +31,7 @@ from vdsm import v2v from vdsm import libvirtconnection from vdsm.password import ProtectedPassword -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import CommandPath @@ -538,7 +538,7 @@ self.domain_id), self.vm_name] - rc, output, error = execCmd(cmd, raw=True) + rc, output, error = run_cmd(cmd, raw=True) self.assertEqual(rc, 0) with open('fake-virt-v2v.out', 'r') as f: diff --git a/vdsm/API.py b/vdsm/API.py index fe9e429..1dc0f5e 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -715,7 +715,7 @@ def _createSysprepFloppyFromInf(self, infFileBinary, floppyImage): try: - rc, out, err = commands.execCmd([constants.EXT_MK_SYSPREP_FLOPPY, + rc, out, err = commands.run_cmd([constants.EXT_MK_SYSPREP_FLOPPY, floppyImage], sudo=True, data=infFileBinary.data) @@ -1217,7 +1217,7 @@ action can be one of (status, on, off, reboot).""" def fence(script, inp): - rc, out, err = commands.execCmd([script], data=inp) + rc, out, err = commands.run_cmd([script], data=inp) self.log.debug('rc %s inp %s out %s err %s', rc, hidePasswd(inp), out, err) return rc, out, err diff --git a/vdsm/alignmentScan.py b/vdsm/alignmentScan.py index 0957c05..c92302b 100644 --- a/vdsm/alignmentScan.py +++ b/vdsm/alignmentScan.py @@ -21,7 +21,7 @@ from collections import namedtuple from vdsm.utils import CommandPath -from vdsm.storage.misc import execCmd +from vdsm.storage.misc import run_cmd ScanOutput = namedtuple( 'ScanOutput', @@ -43,7 +43,7 @@ # TODO: remove the environment variable when the issue in # virt-alignment-scan/libvirt is resolved # http://bugzilla.redhat.com/1151838 - return execCmd(cmd, env={'LIBGUESTFS_BACKEND': 'direct'}) + return run_cmd(cmd, env={'LIBGUESTFS_BACKEND': 'direct'}) def scanImage(image_path): diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py index b6f11c3..2d8eaa7 100644 --- a/vdsm/gluster/api.py +++ b/vdsm/gluster/api.py @@ -227,7 +227,7 @@ err=['Mount Point creation failed', str(e)]) command = [constants.EXT_MOUNT, META_VOL_MOUNT_POINT] - rc, out, err = commands.execCmd(command) + rc, out, err = commands.run_cmd(command) if rc: raise ge.GlusterMetaVolumeMountFailedException( rc, out, err) @@ -237,7 +237,7 @@ @gluster_mgmt_api def snapshotScheduleDisable(): command = [_snapSchedulerPath.cmd, "disable_force"] - rc, out, err = commands.execCmd(command) + rc, out, err = commands.run_cmd(command) if rc not in [0, SNAP_SCHEDULER_ALREADY_DISABLED_RC]: raise ge.GlusterDisableSnapshotScheduleFailedException( rc) @@ -276,7 +276,7 @@ @gluster_mgmt_api def processesStop(): command = ["/bin/sh", _stopAllProcessesPath.cmd] - rc, out, err = commands.execCmd(command) + rc, out, err = commands.run_cmd(command) if rc: raise ge.GlusterProcessesStopFailedException(rc) diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py index 87ee752..39f24fa 100644 --- a/vdsm/gluster/cli.py +++ b/vdsm/gluster/cli.py @@ -99,12 +99,12 @@ def _execGluster(cmd): - return commands.execCmd(cmd) + return commands.run_cmd(cmd) def _execGlusterXml(cmd): cmd.append('--xml') - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if rc != 0: raise ge.GlusterCmdExecFailedException(rc, out, err) try: diff --git a/vdsm/gluster/gfapi.py b/vdsm/gluster/gfapi.py index 83a5c57..60d7b02 100644 --- a/vdsm/gluster/gfapi.py +++ b/vdsm/gluster/gfapi.py @@ -226,7 +226,7 @@ env['PYTHONPATH'] = ":".join(map(os.path.abspath, env['PYTHONPATH'].split(":"))) - rc, out, err = commands.execCmd(command, raw=True, env=env) + rc, out, err = commands.run_cmd(command, raw=True, env=env) if rc != 0: raise ge.GlfsStatvfsException(rc, [out], [err]) res = json.loads(out) @@ -257,7 +257,7 @@ env['PYTHONPATH'] = ":".join(map(os.path.abspath, env['PYTHONPATH'].split(":"))) - rc, out, err = commands.execCmd(command, raw=True, env=env) + rc, out, err = commands.run_cmd(command, raw=True, env=env) if rc != 0: raise ge.GlusterVolumeEmptyCheckFailedException(rc, [out], [err]) return out.upper() == "TRUE" diff --git a/vdsm/gluster/storagedev.py b/vdsm/gluster/storagedev.py index ca1ee01..b37871f 100644 --- a/vdsm/gluster/storagedev.py +++ b/vdsm/gluster/storagedev.py @@ -154,7 +154,7 @@ for dev in deviceList: # bz#1178705: Blivet always creates pv with 1MB dataalignment # Workaround: Till blivet fixes the issue, we use lvm pvcreate - rc, out, err = commands.execCmd([_pvCreateCommandPath.cmd, + rc, out, err = commands.run_cmd([_pvCreateCommandPath.cmd, '--dataalignment', '%sk' % alignment, dev.path]) @@ -168,7 +168,7 @@ # bz#1198568: Blivet always creates vg with 1MB stripe size # Workaround: Till blivet fixes the issue, use vgcreate command devices = ','.join([device.path for device in deviceList]) - rc, out, err = commands.execCmd([_vgCreateCommandPath.cmd, + rc, out, err = commands.run_cmd([_vgCreateCommandPath.cmd, '-s', '%sk' % stripeSize, vgName, devices]) if rc: @@ -196,7 +196,7 @@ # to use lvconvert to achive that. # bz#1179826: blivet doesn't support lvconvert functionality. # Workaround: Till the bz gets fixed, lvconvert command is used - rc, out, err = commands.execCmd([_lvconvertCommandPath.cmd, + rc, out, err = commands.run_cmd([_lvconvertCommandPath.cmd, '--chunksize', '%sK' % alignment, '--thinpool', vgPoolName, '--poolmetadata', @@ -206,7 +206,7 @@ if rc: raise ge.GlusterHostStorageDeviceLVConvertFailedException( vg.path, alignment, rc, out, err) - rc, out, err = commands.execCmd([_lvchangeCommandPath.cmd, + rc, out, err = commands.run_cmd([_lvchangeCommandPath.cmd, '--zero', 'n', vgPoolName]) if rc: raise ge.GlusterHostStorageDeviceLVChangeFailedException( @@ -308,7 +308,7 @@ # bz#1230495: lvm devices are invisible and appears only after vgscan # Workaround: Till the bz gets fixed, We use vgscan to refresh LVM devices - rc, out, err = commands.execCmd([_vgscanCommandPath.cmd]) + rc, out, err = commands.run_cmd([_vgscanCommandPath.cmd]) if rc: raise ge.GlusterHostStorageDeviceVGScanFailedException(rc, out, err) fstab.FsTab().add(thinlv.path, mountPoint, diff --git a/vdsm/hooking.py b/vdsm/hooking.py index 5f294bd..555463b 100644 --- a/vdsm/hooking.py +++ b/vdsm/hooking.py @@ -42,13 +42,13 @@ import sys from xml.dom import minidom -from vdsm.commands import execCmd -from vdsm.commands import startCmd +from vdsm.commands import run_cmd +from vdsm.commands import start_cmd from vdsm.utils import tobool # make pyflakes happy -execCmd -startCmd +run_cmd +start_cmd tobool diff --git a/vdsm/mkimage.py b/vdsm/mkimage.py index a737e1a..6479079 100644 --- a/vdsm/mkimage.py +++ b/vdsm/mkimage.py @@ -30,7 +30,7 @@ from vdsm.constants import EXT_MKFS_MSDOS, EXT_MKISOFS, \ DISKIMAGE_USER, DISKIMAGE_GROUP from vdsm.constants import P_VDSM_RUN -from vdsm.commands import execCmd +from vdsm.commands import run_cmd from vdsm.utils import rmFile from vdsm.storage import mount from vdsm.storage.fileUtils import resolveUid, resolveGid @@ -101,7 +101,7 @@ command = [EXT_MKFS_MSDOS, '-C', floppy, '1440'] if volumeName is not None: command.extend(['-n', volumeName]) - rc, out, err = execCmd(command, raw=True) + rc, out, err = run_cmd(command, raw=True) if rc: raise OSError(errno.EIO, "could not create floppy file: " "code %s, out %s\nerr %s" % (rc, out, err)) @@ -143,7 +143,7 @@ fd = os.open(isopath, os.O_CREAT | os.O_RDONLY | os.O_EXCL, mode) os.close(fd) - rc, out, err = execCmd(command, raw=True) + rc, out, err = run_cmd(command, raw=True) if rc: # clean up after ourselves in case of error removeFs(isopath) diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py index 687dcaa..a73a85a 100644 --- a/vdsm/storage/blockSD.py +++ b/vdsm/storage/blockSD.py @@ -1222,7 +1222,7 @@ masterfsdev = lvm.lvPath(self.sdUUID, MASTERLV) cmd = [constants.EXT_FSCK, "-p", masterfsdev] - (rc, out, err) = misc.execCmd(cmd, sudo=True) + (rc, out, err) = misc.run_cmd(cmd, sudo=True) # fsck exit codes # 0 - No errors @@ -1248,7 +1248,7 @@ # If there is a journal already tune2fs will do nothing, indicating # this condition only with exit code. However, we do not really care. cmd = [constants.EXT_TUNE2FS, "-j", masterfsdev] - misc.execCmd(cmd, sudo=True) + misc.run_cmd(cmd, sudo=True) masterMount = mount.Mount(masterfsdev, masterDir) @@ -1260,7 +1260,7 @@ cmd = [constants.EXT_CHOWN, "%s:%s" % (constants.METADATA_USER, constants.METADATA_GROUP), masterDir] - (rc, out, err) = misc.execCmd(cmd, sudo=True) + (rc, out, err) = misc.run_cmd(cmd, sudo=True) if rc != 0: self.log.error("failed to chown %s", masterDir) @@ -1418,7 +1418,7 @@ Create a special file system to store VM data """ cmd = [constants.EXT_MKFS, "-q", "-j", "-E", "nodiscard", dev] - rc = misc.execCmd(cmd, sudo=True)[0] + rc = misc.run_cmd(cmd, sudo=True)[0] if rc != 0: raise se.MkfsError(dev) diff --git a/vdsm/storage/curl-img-wrap b/vdsm/storage/curl-img-wrap index 544b4df..ee71e63 100755 --- a/vdsm/storage/curl-img-wrap +++ b/vdsm/storage/curl-img-wrap @@ -30,7 +30,7 @@ # This utility is not using any particular advanced multi-process tool (e.g. # CPopen) because its only scope is to pipe and launch the processes and at # the end collect the statuses. The reliability is demanded to the calling -# process (e.g. execCmd in curlImgWrap.py). +# process (e.g. run_cmd in curlImgWrap.py). import os diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index 7d834c3..86fcf96 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -407,7 +407,7 @@ """ Check lvm locking type. """ - rc, out, err = misc.execCmd([constants.EXT_LVM, "dumpconfig", + rc, out, err = misc.run_cmd([constants.EXT_LVM, "dumpconfig", "global/locking_type"], sudo=True) if rc != 0: diff --git a/vdsm/storage/iscsiadm.py b/vdsm/storage/iscsiadm.py index a0c6b6c..3d952af 100644 --- a/vdsm/storage/iscsiadm.py +++ b/vdsm/storage/iscsiadm.py @@ -24,7 +24,8 @@ from threading import Lock from vdsm import constants -from vdsm.commands import execCmd, startCmd +from vdsm.commands import start_cmd +from vdsm.commands import run_cmd from vdsm.utils import AsyncProcessOperation # iscsiadm exit statuses @@ -116,7 +117,7 @@ if i < (len(printCmd) - 1): printCmd[i + 1] = "****" - executer = execCmd if sync else startCmd + executer = run_cmd if sync else start_cmd executer(cmd, printable=printCmd, sudo=True) diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py index 3d3c31a..113434f 100644 --- a/vdsm/storage/lvm.py +++ b/vdsm/storage/lvm.py @@ -285,7 +285,7 @@ def cmd(self, cmd, devices=tuple()): finalCmd = self._addExtraCfg(cmd, devices) - rc, out, err = misc.execCmd(finalCmd, sudo=True) + rc, out, err = misc.run_cmd(finalCmd, sudo=True) if rc != 0: # Filter might be stale self.invalidateFilter() @@ -295,7 +295,7 @@ # the devlist is sorted there is no fear # of two identical filters looking differently if newCmd != finalCmd: - return misc.execCmd(newCmd, sudo=True) + return misc.run_cmd(newCmd, sudo=True) return rc, out, err @@ -1105,7 +1105,7 @@ gName = grp.getgrgid(st.st_gid).gr_name if ":".join((uName, gName)) != USER_GROUP: cmd = [constants.EXT_CHOWN, USER_GROUP, lv_path] - if misc.execCmd(cmd, sudo=True)[0] != 0: + if misc.run_cmd(cmd, sudo=True)[0] != 0: log.warning("Could not change ownership of one or more " "volumes in vg (%s) - %s", vgName, lvName) else: diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py index 77c54a7..4a72aba 100644 --- a/vdsm/storage/multipath.py +++ b/vdsm/storage/multipath.py @@ -75,7 +75,7 @@ hba.rescan() # Now let multipath daemon pick up new devices - misc.execCmd([constants.EXT_MULTIPATH], sudo=True) + misc.run_cmd([constants.EXT_MULTIPATH], sudo=True) # Scanning SCSI interconnects starts a storm of udev events. Wait until all # events are processed, ensuring detection of new devices and creation or @@ -132,7 +132,7 @@ log.debug("Resizing map %r", name) cmd = [_MULTIPATHD.cmd, "resize", "map", name] with utils.stopwatch("Resized map %r" % name, log=log): - rc, out, err = commands.execCmd(cmd, raw=True, execCmdLogger=log) + rc, out, err = commands.run_cmd(cmd, raw=True, execCmdLogger=log) # multipathd reports some errors using non-zero exit code and stderr # (need to be root), but the command may return 0, and the result is # reported using stdout. @@ -172,7 +172,7 @@ "--export", "--replace-whitespace", "--device=" + blkdev] - (rc, out, err) = misc.execCmd(cmd) + (rc, out, err) = misc.run_cmd(cmd) if rc == 0: for line in out: if line.startswith("ID_SERIAL="): diff --git a/vdsm/storage/storage_mailbox.py b/vdsm/storage/storage_mailbox.py index 64cccac..2e4e477 100644 --- a/vdsm/storage/storage_mailbox.py +++ b/vdsm/storage/storage_mailbox.py @@ -81,7 +81,7 @@ def _mboxExecCmd(*args, **kwargs): - return misc.execCmd(*args, **kwargs) + return misc.run_cmd(*args, **kwargs) class SPM_Extend_Message: @@ -370,7 +370,7 @@ def _checkForMail(self): # self.log.debug("HSM_MailMonitor - checking for mail") # self.log.debug("Running command: " + str(self._inCmd)) - (rc, in_mail, err) = misc.execCmd(self._inCmd, raw=True) + (rc, in_mail, err) = misc.run_cmd(self._inCmd, raw=True) if rc: raise RuntimeError("_handleResponses.Could not read mailbox - rc " "%s" % rc) @@ -728,7 +728,7 @@ cmd = self._inCmd + ['bs=' + str(self._outMailLen)] # self.log.debug("SPM_MailMonitor - reading incoming mail, " # "command: " + str(cmd)) - (rc, in_mail, err) = misc.execCmd(cmd, raw=True) + (rc, in_mail, err) = misc.run_cmd(cmd, raw=True) if rc: raise IOError(errno.EIO, "_handleRequests._checkForMail - " "Could not read mailbox: %s" % self._inbox) diff --git a/vdsm/supervdsm_api/udev.py b/vdsm/supervdsm_api/udev.py index faf0cae..2a8ea83 100644 --- a/vdsm/supervdsm_api/udev.py +++ b/vdsm/supervdsm_api/udev.py @@ -82,7 +82,7 @@ _log.debug('Changing ownership (to root:disk) of device %s', udev_path) cmd = [EXT_CHOWN, 'root:disk', udev_path] - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if err: raise OSError(errno.EINVAL, 'Could not change ownership' 'out %s\nerr %s' % (out, err)) @@ -206,7 +206,7 @@ 'bus: %s, device:: %s', bus, device) device_path = _USB_DEVICE_PATH % (int(bus), int(device)) cmd = [EXT_CHOWN, 'root:root', device_path] - rc, out, err = commands.execCmd(cmd) + rc, out, err = commands.run_cmd(cmd) if err: raise OSError(errno.EINVAL, 'Could not change ownership' 'out %s\nerr %s' % (out, err)) diff --git a/vdsm/vdsm b/vdsm/vdsm index 89ab5c8..4006c96 100755 --- a/vdsm/vdsm +++ b/vdsm/vdsm @@ -212,7 +212,7 @@ # is read properly cmd = [constants.EXT_CHOWN, "%s:%s" % (constants.VDSM_USER, constants.QEMU_PROCESS_GROUP), dst.name] - rc, _, stderr = commands.execCmd(cmd, sudo=True) + rc, _, stderr = commands.run_cmd(cmd, sudo=True) if rc != 0: raise FatalError("Vdsm user could not manage to run sudo operation: " diff --git a/vdsm_hooks/ethtool_options/ethtool_options.py b/vdsm_hooks/ethtool_options/ethtool_options.py index fb0e7e2..cb9157f 100644 --- a/vdsm_hooks/ethtool_options/ethtool_options.py +++ b/vdsm_hooks/ethtool_options/ethtool_options.py @@ -150,7 +150,7 @@ """Takes an iterable of the tokenized ethtool command line arguments and applies them to the network devices""" command = [ETHTOOL_BINARY.cmd] + options - rc, _, err = hooking.execCmd(command) + rc, _, err = hooking.run_cmd(command) if rc != 0: raise EthtoolError('Failed to set ethtool opts (%s) for network %s. ' 'Err: %s' % (' '.join(options), network, err)) diff --git a/vdsm_hooks/extra_ipv4_addrs/extra_ipv4_addrs.py b/vdsm_hooks/extra_ipv4_addrs/extra_ipv4_addrs.py index c316990..c9fc816 100644 --- a/vdsm_hooks/extra_ipv4_addrs/extra_ipv4_addrs.py +++ b/vdsm_hooks/extra_ipv4_addrs/extra_ipv4_addrs.py @@ -56,7 +56,7 @@ if options is not None: top_dev = _top_dev(network, attrs) for cmd in _generate_commands(options, top_dev): - hooking.execCmd(cmd, sudo=True) + hooking.run_cmd(cmd, sudo=True) def _generate_commands(options, top_level_device): diff --git a/vdsm_hooks/fcoe/fcoe_before_network_setup.py b/vdsm_hooks/fcoe/fcoe_before_network_setup.py index c507c07..5d5f759 100755 --- a/vdsm_hooks/fcoe/fcoe_before_network_setup.py +++ b/vdsm_hooks/fcoe/fcoe_before_network_setup.py @@ -201,11 +201,11 @@ # TODO If services are failed to start restore previous configuration # and notify user - ret, _, err = hooking.execCmd(['/bin/systemctl', 'restart', 'lldpad']) + ret, _, err = hooking.run_cmd(['/bin/systemctl', 'restart', 'lldpad']) if ret: hooking.log('Failed to restart lldpad service. err = %s' % (err)) - ret, _, err = hooking.execCmd(['/bin/systemctl', 'restart', 'fcoe']) + ret, _, err = hooking.run_cmd(['/bin/systemctl', 'restart', 'fcoe']) if ret: hooking.log('Failed to restart fcoe service. err = %s' % (err)) diff --git a/vdsm_hooks/hostusb/after_vm_destroy.py b/vdsm_hooks/hostusb/after_vm_destroy.py index 2603066..118cbae 100755 --- a/vdsm_hooks/hostusb/after_vm_destroy.py +++ b/vdsm_hooks/hostusb/after_vm_destroy.py @@ -46,7 +46,7 @@ # remove the 0x from the vendor and product id devid = vendorid[2:] + ':' + productid[2:] command = ['lsusb', '-d', devid] - retcode, out, err = hooking.execCmd(command, raw=True) + retcode, out, err = hooking.run_cmd(command, raw=True) if retcode != 0: sys.stderr.write('hostusb: cannot find usb device: %s\n' % devid) sys.exit(2) @@ -62,7 +62,7 @@ # we don't use os.chown because we need sudo owner = str(uid) + ':' + str(gid) command = ['/bin/chown', owner, devpath] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('hostusb after_vm_destroy: error chown %s to %s, ' 'err = %s\n' % (devpath, owner, err)) diff --git a/vdsm_hooks/hostusb/before_vm_start.py b/vdsm_hooks/hostusb/before_vm_start.py index 5403515..721fb99 100755 --- a/vdsm_hooks/hostusb/before_vm_start.py +++ b/vdsm_hooks/hostusb/before_vm_start.py @@ -65,7 +65,7 @@ # remove the 0x from the vendor and product id devid = vendorid[2:] + ':' + productid[2:] command = ['lsusb', '-d', devid] - retcode, out, err = hooking.execCmd(command, raw=True) + retcode, out, err = hooking.run_cmd(command, raw=True) if retcode != 0: sys.stderr.write('hostusb: cannot find usb device: %s\n' % devid) sys.exit(2) @@ -83,7 +83,7 @@ # we don't use os.chown because we need sudo owner = str(uid) + ':' + str(gid) command = ['/bin/chown', owner, devpath] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('hostusb: error chown %s to %s, err = %s\n' % (devpath, owner, err)) diff --git a/vdsm_hooks/hugepages/before_vm_migrate_destination.py b/vdsm_hooks/hugepages/before_vm_migrate_destination.py index bdcd8d9..769abda 100755 --- a/vdsm_hooks/hugepages/before_vm_migrate_destination.py +++ b/vdsm_hooks/hugepages/before_vm_migrate_destination.py @@ -16,7 +16,7 @@ totalPages = pages + currPages # command: sysctl vm.nr_hugepages=256 command = ['sysctl', 'vm.nr_hugepages=%d' % totalPages] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('hugepages before_vm_migraton_destination: error in ' 'command: %s, err = %s\n' % (' '.join(command), err)) @@ -35,7 +35,7 @@ if pages > 0: # command: sysctl vm.nr_hugepages=0 command = ['sysctl', 'vm.nr_hugepages=%d' % (currPages - pages)] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('hugepages before_vm_migraton_destination: error ' 'in command: %s, err = %s\n' % diff --git a/vdsm_hooks/hugepages/before_vm_start.py b/vdsm_hooks/hugepages/before_vm_start.py index 37b655e..37ec2aa 100755 --- a/vdsm_hooks/hugepages/before_vm_start.py +++ b/vdsm_hooks/hugepages/before_vm_start.py @@ -41,7 +41,7 @@ totalPages = pages + currPages # command: sysctl vm.nr_hugepages=256 command = ['sysctl', 'vm.nr_hugepages=%d' % totalPages] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('hugepages: error in command: %s, err = %s\n' % (' '.join(command), err)) @@ -60,7 +60,7 @@ if pages > 0: # command: sysctl vm.nr_hugepages=0 command = ['sysctl', 'vm.nr_hugepages=%d' % (currPages - pages)] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('hugepages: error in command: %s, err = %s\n' % (' '.join(command), err)) diff --git a/vdsm_hooks/openstacknet/openstacknet_utils.py b/vdsm_hooks/openstacknet/openstacknet_utils.py index 15263da..db65f2d 100644 --- a/vdsm_hooks/openstacknet/openstacknet_utils.py +++ b/vdsm_hooks/openstacknet/openstacknet_utils.py @@ -41,7 +41,7 @@ def executeOrExit(command): - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: raise RuntimeError("Failed to execute %s, due to: %s" % (command, err)) @@ -59,7 +59,7 @@ def deviceExists(dev): command = [EXT_IP, 'link', 'show', 'dev', dev] - retcode, out, err = hooking.execCmd(command, raw=True) + retcode, out, err = hooking.run_cmd(command, raw=True) return retcode == 0 diff --git a/vdsm_hooks/ovs/ovs_after_get_caps.py b/vdsm_hooks/ovs/ovs_after_get_caps.py index c626f13..dd56991 100755 --- a/vdsm_hooks/ovs/ovs_after_get_caps.py +++ b/vdsm_hooks/ovs/ovs_after_get_caps.py @@ -26,7 +26,7 @@ mtus) from vdsm.network.netinfo.bonding import parse_bond_options -from hooking import execCmd +from hooking import run_cmd import hooking from ovs_utils import (iter_ovs_nets, iter_ovs_bonds, EXT_OVS_APPCTL, @@ -37,7 +37,7 @@ if iface != BRIDGE_NAME: return 'off' - rc, out, err = execCmd([EXT_OVS_VSCTL, 'get', 'Bridge', BRIDGE_NAME, + rc, out, err = run_cmd([EXT_OVS_VSCTL, 'get', 'Bridge', BRIDGE_NAME, 'stp_enable'], sudo=True) if rc != 0: hooking.exit_hook('\n'.join(err)) @@ -48,7 +48,7 @@ def _list_ports(bridge): - rc, out, err = execCmd([EXT_OVS_VSCTL, 'list-ports', bridge], sudo=True) + rc, out, err = run_cmd([EXT_OVS_VSCTL, 'list-ports', bridge], sudo=True) if rc != 0: hooking.exit_hook('\n'.join(err)) return out @@ -156,7 +156,7 @@ TODO: since openvswitch 2.3.1, active slave is also listed in header of command output. """ - rc, out, err = execCmd([EXT_OVS_APPCTL, 'bond/show', bonding], + rc, out, err = run_cmd([EXT_OVS_APPCTL, 'bond/show', bonding], sudo=True) if rc != 0: hooking.exit_hook('\n'.join(err)) @@ -230,8 +230,8 @@ 'slave eth1: enabled\n', '\tmay_enable: true\n'] return 0, ovs_appctl_output, [] - global execCmd - execCmd = fake_execCmd + global run_cmd + run_cmd = fake_execCmd active_slave = _get_active_slave('bond1') assert active_slave == 'eth0' diff --git a/vdsm_hooks/ovs/ovs_before_network_setup.py b/vdsm_hooks/ovs/ovs_before_network_setup.py index 6740ff8..40020d1 100755 --- a/vdsm_hooks/ovs/ovs_before_network_setup.py +++ b/vdsm_hooks/ovs/ovs_before_network_setup.py @@ -38,7 +38,7 @@ from vdsm.network.ipwrapper import linkSet from vdsm.network.netconfpersistence import RunningConfig -from hooking import execCmd +from hooking import run_cmd import hooking from ovs_utils import (is_ovs_network, is_ovs_bond, iter_ovs_nets, @@ -213,7 +213,7 @@ def _execCmd(cmd, exit=True): print('> ' + ' '.join(cmd)) - rc, out, err = execCmd(cmd) + rc, out, err = run_cmd(cmd) if rc == 0: for l in out: print(l) diff --git a/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py b/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py index 7bcee58..fa75c4f 100644 --- a/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py +++ b/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py @@ -68,7 +68,7 @@ commands = [EXT_OVS_VSCTL, '--', '--may-exist', 'add-br', BRIDGE_NAME] + commands log('Executing commands: %s' % ' '.join(commands)) - rc, _, err = hooking.execCmd(commands) + rc, _, err = hooking.run_cmd(commands) if rc != 0: raise Exception('Executing commands failed: %s' % '\n'.join(err)) diff --git a/vdsm_hooks/ovs/ovs_utils.py b/vdsm_hooks/ovs/ovs_utils.py index 808d793..15974b9 100644 --- a/vdsm_hooks/ovs/ovs_utils.py +++ b/vdsm_hooks/ovs/ovs_utils.py @@ -19,7 +19,7 @@ # import six -from hooking import execCmd +from hooking import run_cmd import hooking from vdsm.network.netinfo.bonding import parse_bond_options @@ -70,7 +70,7 @@ def destroy_ovs_bridge(): commands = [EXT_OVS_VSCTL, '--if-exists', 'del-br', BRIDGE_NAME] - rc, _, err = execCmd(commands) + rc, _, err = run_cmd(commands) if rc != 0: raise Exception('\n'.join(err)) @@ -81,7 +81,7 @@ def ovs_bridge_exists(bridge): commands = [EXT_OVS_VSCTL, 'br-exists', bridge] - rc, _, err = execCmd(commands) + rc, _, err = run_cmd(commands) if rc == 0: return True elif rc == 2: diff --git a/vdsm_hooks/promisc/after_vm_start.py b/vdsm_hooks/promisc/after_vm_start.py index ea62347..e0877df 100755 --- a/vdsm_hooks/promisc/after_vm_start.py +++ b/vdsm_hooks/promisc/after_vm_start.py @@ -39,7 +39,7 @@ ''' command = ['/sbin/tc', 'qdisc', 'add', 'dev', networkName, 'ingress'] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) @@ -48,7 +48,7 @@ command = ['/sbin/tc', 'filter', 'add', 'dev', networkName, 'parent', 'ffff:', 'protocol', 'ip', 'u32', 'match', 'u8', '0', '0', 'action', 'mirred', 'egress', mode, 'dev', ifaceName] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) @@ -56,14 +56,14 @@ command = ['/sbin/tc', 'qdisc', 'replace', 'dev', networkName, 'parent', 'root', 'prio'] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) sys.exit(2) command = ['/sbin/tc', 'qdisc', 'show', 'dev', networkName] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) @@ -76,7 +76,7 @@ command = ['/sbin/tc', 'filter', 'add', 'dev', networkName, 'parent', devId, 'protocol', 'ip', 'u32', 'match', 'u8', '0', '0', 'action', 'mirred', 'egress', mode, 'dev', ifaceName] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) @@ -84,7 +84,7 @@ # add promisc mode to the bridge command = ['/sbin/ifconfig', networkName, 'promisc'] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) diff --git a/vdsm_hooks/promisc/before_vm_destroy.py b/vdsm_hooks/promisc/before_vm_destroy.py index d041c19..86f3247 100755 --- a/vdsm_hooks/promisc/before_vm_destroy.py +++ b/vdsm_hooks/promisc/before_vm_destroy.py @@ -16,20 +16,20 @@ ''' command = ['/sbin/tc', 'qdisc', 'del', 'dev', networkName, 'root'] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) command = ['/sbin/tc', 'qdisc', 'del', 'dev', networkName, 'ingress'] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) # remove promisc mode flag from the bridge command = ['/sbin/ifconfig', networkName, '-promisc'] - retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) + retcode, out, err = hooking.run_cmd(command, sudo=True, raw=True) if retcode != 0: sys.stderr.write('promisc: error executing command "%s" error: %s' % (command, err)) diff --git a/vdsm_hooks/scratchpad/before_vm_start.py b/vdsm_hooks/scratchpad/before_vm_start.py index ef851a4..59cb710 100755 --- a/vdsm_hooks/scratchpad/before_vm_start.py +++ b/vdsm_hooks/scratchpad/before_vm_start.py @@ -34,7 +34,7 @@ Create image file ''' command = ['/usr/bin/qemu-img', 'create', '-f', 'raw', path, size] - retcode, out, err = hooking.execCmd(command, raw=True) + retcode, out, err = hooking.run_cmd(command, raw=True) if retcode != 0: sys.stderr.write('scratchpad: error running command %s, err = %s\n' % (' '.join(command), err)) -- To view, visit https://gerrit.ovirt.org/60280 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5e271c07f204c405483c24b03b2792a25bf4256d Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <ybron...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org