當前位置: 首頁>>代碼示例>>Python>>正文


Python processutils.ProcessExecutionError方法代碼示例

本文整理匯總了Python中oslo_concurrency.processutils.ProcessExecutionError方法的典型用法代碼示例。如果您正苦於以下問題:Python processutils.ProcessExecutionError方法的具體用法?Python processutils.ProcessExecutionError怎麽用?Python processutils.ProcessExecutionError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oslo_concurrency.processutils的用法示例。


在下文中一共展示了processutils.ProcessExecutionError方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_pci_resources

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def get_pci_resources(self):
        addresses = []
        try:
            output, status = utils.execute('lspci', '-D', '-nnmm')
            lines = output.split('\n')
            for line in lines:
                if not line:
                    continue
                columns = line.split()
                address = columns[0]
                addresses.append(address)
        except processutils.ProcessExecutionError as e:
            raise exception.CommandError(cmd='lspci',
                                         error=str(e))

        pci_info = []
        for addr in addresses:
            pci_info.append(self._get_pci_dev_info(addr))

        return jsonutils.dumps(pci_info) 
開發者ID:openstack,項目名稱:zun,代碼行數:22,代碼來源:host_capability.py

示例2: unplug_iovisor

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def unplug_iovisor(self, instance, vif):
        """Unplug vif from IOvisor

        Offboard an interface and deletes port from IOvisor
        """
        if_local_name = 'tap%s' % vif['id'][:11]
        iface_id = vif['id']
        try:
            utils.execute('ifc_ctl', 'gateway', 'ifdown',
                          if_local_name, 'access_vm',
                          vif['network']['label'] + "_" + iface_id,
                          vif['address'], run_as_root=True)
            utils.execute('ifc_ctl', 'gateway', 'del_port', if_local_name,
                          run_as_root=True)
            linux_net.delete_net_dev(if_local_name)
        except processutils.ProcessExecutionError:
            LOG.exception("Failed while unplugging vif", instance=instance) 
開發者ID:openstack,項目名稱:zun,代碼行數:19,代碼來源:vifs.py

示例3: ovs_appctl

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def ovs_appctl(self, action, *parameters):
        """Run 'ovs-appctl' with the specified action

         Its possible the command may fail due to timing if, for example,
         the command affects an interface and it the prior ifup command
         has not completed.  So retry the command and if a failures still
         occurs save the error for later handling.

         :param action: The ovs-appctl action.
         :param parameters: Parameters to pass to ovs-appctl.
         """
        msg = 'Running ovs-appctl %s %s' % (action, parameters)
        try:
            self.execute(msg, '/bin/ovs-appctl', action, *parameters,
                         delay_on_retry=True, attempts=5)
        except processutils.ProcessExecutionError as e:
            self.errors.append(e) 
開發者ID:openstack,項目名稱:os-net-config,代碼行數:19,代碼來源:__init__.py

示例4: get_pci_address

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def get_pci_address(ifname, noop):
    # TODO(skramaja): Validate if the given interface supports dpdk
    if not noop:
        try:
            out, err = processutils.execute('ethtool', '-i', ifname)
            if not err:
                for item in out.split('\n'):
                    if 'bus-info' in item:
                        return item.split(' ')[1]
        except processutils.ProcessExecutionError:
            # If ifname is already bound, then ethtool will not be able to
            # list the device, in which case, binding is already done, proceed
            # with scripts generation.
            return

    else:
        logger.info('Fetch the PCI address of the interface %s using '
                    'ethtool' % ifname) 
開發者ID:openstack,項目名稱:os-net-config,代碼行數:20,代碼來源:utils.py

示例5: _check_conf

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def _check_conf(self):
        """Run gdnsd to check its configuration
        """
        try:
            out, err = utils.execute(
                cfg.CONF[CFG_GROUP_NAME].gdnsd_cmd_name,
                '-D', '-x', 'checkconf', '-c', self._confdir_path,
                run_as_root=False,
            )
        except ProcessExecutionError as e:
            LOG.error("Command output: %(out)r Stderr: %(err)r",
                      {
                          'out': e.stdout,
                          'err': e.stderr
                      })
            raise exceptions.Backend("Configuration check failed") 
開發者ID:openstack,項目名稱:designate,代碼行數:18,代碼來源:impl_gdnsd.py

示例6: _real_umount

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def _real_umount(self, mountpoint, rootwrap_helper):
        # Unmount and delete a mountpoint.
        # Return mount state after umount (i.e. True means still mounted)
        LOG.debug('Unmounting %(mountpoint)s', {'mountpoint': mountpoint})

        try:
            processutils.execute('umount', mountpoint, run_as_root=True,
                                 attempts=3, delay_on_retry=True,
                                 root_helper=rootwrap_helper)
        except processutils.ProcessExecutionError as ex:
            LOG.error(_LE("Couldn't unmount %(mountpoint)s: %(reason)s"),
                      {'mountpoint': mountpoint, 'reason': ex})

        if not os.path.ismount(mountpoint):
            try:
                os.rmdir(mountpoint)
            except Exception as ex:
                LOG.error(_LE("Couldn't remove directory %(mountpoint)s: "
                              "%(reason)s"),
                          {'mountpoint': mountpoint,
                           'reason': ex})
            return False

        return True 
開發者ID:openstack,項目名稱:glance_store,代碼行數:26,代碼來源:fs_mount.py

示例7: is_luks

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def is_luks(root_helper, device, execute=None):
    """Checks if the specified device uses LUKS for encryption.

    :param device: the device to check
    :returns: true if the specified device uses LUKS; false otherwise
    """
    try:
        # check to see if the device uses LUKS: exit status is 0
        # if the device is a LUKS partition and non-zero if not
        if execute is None:
            execute = priv_rootwrap.execute
        execute('cryptsetup', 'isLuks', '--verbose', device,
                run_as_root=True, root_helper=root_helper,
                check_exit_code=True)
        return True
    except putils.ProcessExecutionError as e:
        LOG.warning("isLuks exited abnormally (status %(exit_code)s): "
                    "%(stderr)s",
                    {"exit_code": e.exit_code, "stderr": e.stderr})
        return False 
開發者ID:openstack,項目名稱:os-brick,代碼行數:22,代碼來源:luks.py

示例8: _is_crypt_device_available

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def _is_crypt_device_available(self, dev_name):
        if not os.path.exists('/dev/mapper/%s' % dev_name):
            return False

        try:
            self._execute('cryptsetup', 'status', dev_name, run_as_root=True)
        except processutils.ProcessExecutionError as e:
            # If /dev/mapper/<dev_name> is a non-crypt block device (such as a
            # normal disk or multipath device), exit_code will be 1. In the
            # case, we will omit the warning message.
            if e.exit_code != 1:
                LOG.warning('cryptsetup status %(dev_name)s exited '
                            'abnormally (status %(exit_code)s): %(err)s',
                            {"dev_name": dev_name, "exit_code": e.exit_code,
                             "err": e.stderr})
            return False
        return True 
開發者ID:openstack,項目名稱:os-brick,代碼行數:19,代碼來源:cryptsetup.py

示例9: deconfigure_scsi_device

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def deconfigure_scsi_device(self, device_number, target_wwn, lun):
        """Write the LUN to the port's unit_remove attribute.

        If auto-discovery of LUNs is disabled on s390 platforms
        luns need to be removed from the configuration through the
        unit_remove interface
        """
        LOG.debug("Deconfigure lun for s390: "
                  "device_number=%(device_num)s "
                  "target_wwn=%(target_wwn)s target_lun=%(target_lun)s",
                  {'device_num': device_number,
                   'target_wwn': target_wwn,
                   'target_lun': lun})
        zfcp_device_command = ("/sys/bus/ccw/drivers/zfcp/%s/%s/unit_remove" %
                               (device_number, target_wwn))
        LOG.debug("unit_remove call for s390 execute: %s", zfcp_device_command)
        try:
            self.echo_scsi_command(zfcp_device_command, lun)
        except putils.ProcessExecutionError as exc:
            LOG.warning("unit_remove call for s390 failed exit %(code)s, "
                        "stderr %(stderr)s",
                        {'code': exc.exit_code, 'stderr': exc.stderr}) 
開發者ID:openstack,項目名稱:os-brick,代碼行數:24,代碼來源:linuxfc.py

示例10: is_multipath_running

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def is_multipath_running(enforce_multipath, root_helper, execute=None):
        try:
            if execute is None:
                execute = priv_rootwrap.execute
            cmd = ('multipathd', 'show', 'status')
            out, _err = execute(*cmd, run_as_root=True,
                                root_helper=root_helper)
            # There was a bug in multipathd where it didn't return an error
            # code and just printed the error message in stdout.
            if out and out.startswith('error receiving packet'):
                raise putils.ProcessExecutionError('', out, 1, cmd, None)
        except putils.ProcessExecutionError as err:
            LOG.error('multipathd is not running: exit code %(err)s',
                      {'err': err.exit_code})
            if enforce_multipath:
                raise
            return False

        return True 
開發者ID:openstack,項目名稱:os-brick,代碼行數:21,代碼來源:linuxscsi.py

示例11: _get_system_uuid

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def _get_system_uuid(self):
        # RSD requires system_uuid to let Cinder RSD Driver identify
        # Nova node for later RSD volume attachment.
        try:
            out, err = self._execute('cat', '/sys/class/dmi/id/product_uuid',
                                     root_helper=self._root_helper,
                                     run_as_root=True)
        except putils.ProcessExecutionError:
            try:
                out, err = self._execute('dmidecode', '-ssystem-uuid',
                                         root_helper=self._root_helper,
                                         run_as_root=True)
                if not out:
                    LOG.warning('dmidecode returned empty system-uuid')
            except putils.ProcessExecutionError as e:
                LOG.debug("Unable to locate dmidecode. For Cinder RSD Backend,"
                          " please make sure it is installed: %s", e)
                out = ""
        return out.strip() 
開發者ID:openstack,項目名稱:os-brick,代碼行數:21,代碼來源:nvmeof.py

示例12: _try_disconnect_volume

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def _try_disconnect_volume(self, conn_nqn, ignore_errors=False):
        cmd = [
            'nvme',
            'disconnect',
            '-n',
            conn_nqn]
        try:
            self._execute(
                *cmd,
                root_helper=self._root_helper,
                run_as_root=True)

        except putils.ProcessExecutionError:
            LOG.error(
                "Failed to disconnect from NVMe nqn "
                "%(conn_nqn)s", {'conn_nqn': conn_nqn})
            if not ignore_errors:
                raise 
開發者ID:openstack,項目名稱:os-brick,代碼行數:20,代碼來源:nvmeof.py

示例13: check_valid_device

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def check_valid_device(self, path, run_as_root=True):
        cmd = ('dd', 'if=%(path)s' % {"path": path},
               'of=/dev/null', 'count=1')
        out, info = None, None
        try:
            out, info = self._execute(*cmd, run_as_root=run_as_root,
                                      root_helper=self._root_helper)
        except putils.ProcessExecutionError as e:
            LOG.error("Failed to access the device on the path "
                      "%(path)s: %(error)s.",
                      {"path": path, "error": e.stderr})
            return False
        # If the info is none, the path does not exist.
        if info is None:
            return False
        return True 
開發者ID:openstack,項目名稱:os-brick,代碼行數:18,代碼來源:base.py

示例14: test_connect_nvme_retry_success

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def test_connect_nvme_retry_success(
            self, mock_sleep, mock_execute, mock_devices,
            mock_blk):
        connection_properties = {'target_portal': 'portal',
                                 'target_port': 1,
                                 'nqn': 'nqn.volume_123',
                                 'device_path': '',
                                 'transport_type': 'rdma'}
        mock_devices.side_effect = [
            ['/dev/nvme0n1'],
            ['/dev/nvme0n1', '/dev/nvme0n2']]
        mock_blk.return_value = True
        device_info = self.connector.connect_volume(
            connection_properties)
        mock_execute.side_effect = [
            putils.ProcessExecutionError,
            putils.ProcessExecutionError,
            None]
        self.assertEqual('/dev/nvme0n2', device_info['path'])
        self.assertEqual('block', device_info['type']) 
開發者ID:openstack,項目名稱:os-brick,代碼行數:22,代碼來源:test_nvmeof.py

示例15: deactivate_lv

# 需要導入模塊: from oslo_concurrency import processutils [as 別名]
# 或者: from oslo_concurrency.processutils import ProcessExecutionError [as 別名]
def deactivate_lv(self, name):
        lv_path = self.vg_name + '/' + self._mangle_lv_name(name)
        cmd = ['lvchange', '-a', 'n']
        cmd.append(lv_path)
        try:
            self._execute(*cmd,
                          root_helper=self._root_helper,
                          run_as_root=True)
        except putils.ProcessExecutionError as err:
            LOG.exception('Error deactivating LV')
            LOG.error('Cmd     :%s', err.cmd)
            LOG.error('StdOut  :%s', err.stdout)
            LOG.error('StdErr  :%s', err.stderr)
            raise

        # Wait until lv is deactivated to return in
        # order to prevent a race condition.
        self._wait_for_volume_deactivation(name) 
開發者ID:openstack,項目名稱:os-brick,代碼行數:20,代碼來源:lvm.py


注:本文中的oslo_concurrency.processutils.ProcessExecutionError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。