当前位置: 首页>>代码示例>>Python>>正文


Python wok_log.error函数代码示例

本文整理汇总了Python中wok.utils.wok_log.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _validate_device

def _validate_device(interface):
    """
    validate the device id. Valid device Ids should have
    <single digitnumber>.<single digitnumber>.<4 digit hexadecimalnumber>
    or <4 digit hexadecimal number>
    :param interface: device id
    """
    wok_log.info('Validating network interface %s' % interface)
    pattern_with_dot = r'^\d\.\d\.[0-9a-fA-F]{4}$'
    if interface and not str(interface).isspace():
        interface = str(interface).strip()
        if ENCCW in interface:
            interface = interface.strip(ENCCW)
        out = re.search(pattern_with_dot, interface)
        if out is None:
            wok_log.error("Invalid interface id. interface: %s" % interface)
            raise InvalidParameter("GS390XINVINPUT",
                                   {'reason': 'invalid interface id: %s'
                                              % interface})
        wok_log.info('Successfully validated network interface')
    else:
        wok_log.error("interface id is empty. interface: %s" % interface)
        raise InvalidParameter("GS390XINVINPUT",
                               {'reason': 'device id is required. '
                                          'device id: %s' % interface})
开发者ID:pawankg,项目名称:gingers390x,代码行数:25,代码来源:nwdevices.py

示例2: lookup

    def lookup(self, name):
        try:
            return utils._pvdisplay_out(name)

        except OperationFailed:
            wok_log.error("Unable to fetch details of PV")
            raise NotFoundError("GINPV00004E", {'name': name})
开发者ID:harche,项目名称:ginger,代码行数:7,代码来源:physical_vol.py

示例3: lookup

    def lookup(self, name):
        try:
            return utils._vgdisplay_out(name)

        except OperationFailed:
            wok_log.error('failed to fetch vg info')
            raise NotFoundError("GINVG00003E", {'name': name})
开发者ID:atreyeemukhopadhyay,项目名称:ginger,代码行数:7,代码来源:vol_group.py

示例4: parse_hdds

        def parse_hdds(temperature_unit):
            # hddtemp will strangely convert a non-number (see error case
            #   below) to 32 deg F. So just always ask for C and convert later.
            out, error, rc = run_command(['hddtemp'])
            if rc:
                wok_log.error("Error retrieving HD temperatures: rc %s."
                              "output: %s" % (rc, error))
                return None

            hdds = OrderedDict()

            for hdd in out.splitlines():
                hdd_name = ''
                hdd_temp = 0.0
                try:
                    hdd_items = hdd.split(':')
                    hdd_name, hdd_temp = hdd_items[0], hdd_items[2]
                    hdd_temp = re.sub('°[C|F]', '', hdd_temp).strip()
                except Exception as e:
                    wok_log.error('Sensors hdd parse error: %s' % e.message)
                    continue
                try:
                    # Try to convert the number to a float. If it fails,
                    # don't add this disk to the list.
                    hdd_temp = float(hdd_temp)
                    if(temperature_unit == 'F'):
                        hdd_temp = 9.0/5.0 * hdd_temp + 32
                    hdds[hdd_name] = hdd_temp
                except ValueError:
                    # If no sensor data, parse float will fail. For example:
                    # "/dev/sda: IBM IPR-10 5D831200: S.M.A.R.T. not available"
                    wok_log.warning("Sensors hdd: %s" % hdd)
            hdds['unit'] = temperature_unit
            return hdds
开发者ID:atreyeemukhopadhyay,项目名称:ginger,代码行数:34,代码来源:sensors.py

示例5: __exit__

 def __exit__(self, type, value, tb):
     self._lock.release()
     if type is not None and issubclass(type, sqlite3.DatabaseError):
             # Logs the error and return False, which makes __exit__ raise
             # exception again
             wok_log.error(traceback.format_exc())
             return False
开发者ID:biancafc,项目名称:wok,代码行数:7,代码来源:objectstore.py

示例6: _get_deviceinfo

def _get_deviceinfo(lscss_out, device):
    """
    :param lscss_out: out of lscss command
    :param device: device id for which we need info to be returned
    :return: device info dict for the device from lscss output
    """
    device_pattern = r'(' + re.escape(device) + r')\s+' \
        r'(\d\.\d\.[0-9a-fA-F]{4})\s+' \
        r'(\w+\/\w+)\s+' \
        r'(\w+\/\w+)\s' \
        r'(\s{3}|yes)\s+' \
        r'([0-9a-fA-F]{2})\s+' \
        r'([0-9a-fA-F]{2})\s+' \
        r'([0-9a-fA-F]{2})\s+' \
        r'(\w+\s\w+)'
    if device:
        device = utils.get_row_data(lscss_out, HEADER_PATTERN, device_pattern)
        msg = 'The device is %s' % device
        wok_log.debug(msg)
        try:
            device_info = _format_lscss(device)
            return device_info
        except KeyError as e:
            wok_log.error('lscss column key not found')
            raise e
    else:
        return device
开发者ID:kimchi-project,项目名称:gingers390x,代码行数:27,代码来源:storagedevices.py

示例7: delete

    def delete(self, vm_name, dev_name):
        try:
            bus_type = self.lookup(vm_name, dev_name)['bus']
            dom = VMModel.get_vm(vm_name, self.conn)
        except NotFoundError:
            raise

        if (bus_type not in HOTPLUG_TYPE and
                DOM_STATE_MAP[dom.info()[0]] != 'shutoff'):
            raise InvalidOperation('KCHVMSTOR0011E')

        try:
            disk = get_device_node(dom, dev_name)
            path = get_vm_disk_info(dom, dev_name)['path']
            if path is None or len(path) < 1:
                path = self.lookup(vm_name, dev_name)['path']
            # This has to be done before it's detached. If it wasn't
            #   in the obj store, its ref count would have been updated
            #   by get_disk_used_by()
            if path is not None:
                used_by = get_disk_used_by(self.objstore, self.conn, path)
            else:
                wok_log.error("Unable to decrement volume used_by on"
                              " delete because no path could be found.")
            dom.detachDeviceFlags(etree.tostring(disk),
                                  get_vm_config_flag(dom, 'all'))
        except Exception as e:
            raise OperationFailed("KCHVMSTOR0010E", {'error': e.message})

        if used_by is not None and vm_name in used_by:
            used_by.remove(vm_name)
            set_disk_used_by(self.objstore, path, used_by)
        else:
            wok_log.error("Unable to update %s:%s used_by on delete."
                          % (vm_name, dev_name))
开发者ID:MalleshKoti,项目名称:kimchi,代码行数:35,代码来源:vmstorages.py

示例8: stop

 def stop(self, params=None):
     cmd = ['systemctl', 'stop', 'sepctl']
     output, error, rc = run_command(cmd)
     if rc != 0:
         wok_log.error('Error stopping SEP service: %s - %s - %s' % (cmd,
                       rc, error))
         raise OperationFailed('GINSEP0009E', {'error': error})
开发者ID:MalleshKoti,项目名称:ginger,代码行数:7,代码来源:ibm_sep.py

示例9: _get_subscriber

    def _get_subscriber(self):

        activation_info = []
        entry = {}
        cmd = ['/opt/ibm/seprovider/bin/getSubscriber']
        output, error, rc = run_command(cmd)

        # no subscriber: return empty
        if rc == 1:
            return activation_info

        # error: report
        if rc != 0:
            wok_log.error('SEP execution error: %s - %s - %s' % (cmd, rc,
                          error))
            raise OperationFailed('GINSEP0007E')

        if len(output) > 1:

            # iterate over lines and parse to dict
            for line in output.splitlines():
                if len(line) > 0:
                    entry = SUBSCRIBER.search(line).groupdict()
                    activation_info.append(entry["hostname"])

        return activation_info
开发者ID:MalleshKoti,项目名称:ginger,代码行数:26,代码来源:ibm_sep.py

示例10: lookup

    def lookup(self, subscription):
        """
        Returns a dictionary with all SEP information.
        """
        cmd = ['/opt/ibm/seprovider/bin/getSubscriber']
        output, error, rc = run_command(cmd)

        # error: report
        if rc != 0:
            wok_log.error('SEP execution error: %s - %s - %s' % (cmd, rc,
                          error))
            raise OperationFailed('GINSEP0005E', {'error': error})

        if len(output) > 1:

            # iterate over lines and parse to dict
            for line in output.splitlines():
                if len(line) > 0:
                    entry = SUBSCRIBER.search(line).groupdict()

                    # subscriber found
                    if entry["hostname"] == subscription:
                        return entry

        raise NotFoundError("GINSEP0006E", {'hostname': subscription})
开发者ID:MalleshKoti,项目名称:ginger,代码行数:25,代码来源:ibm_sep.py

示例11: start

 def start(self, params=None):
     cmd = ['systemctl', 'start', 'sepctl']
     output, error, rc = run_command(cmd)
     if rc != 0:
         wok_log.error('SEP service initialization error: %s - %s - %s'
                       % (cmd, rc, error))
         raise OperationFailed('GINSEP0008E', {'error': error})
开发者ID:MalleshKoti,项目名称:ginger,代码行数:7,代码来源:ibm_sep.py

示例12: get_disk_used_by

def get_disk_used_by(objstore, conn, path):
    try:
        with objstore as session:
            try:
                used_by = session.get("storagevolume", path)["used_by"]
            except (KeyError, NotFoundError):
                wok_log.info("Volume %s not found in obj store." % path)
                used_by = []
                # try to find this volume in existing vm
                vms_list = VMsModel.get_vms(conn)
                for vm in vms_list:
                    dom = VMModel.get_vm(vm, conn)
                    storages = get_vm_disks(dom)
                    for disk in storages.keys():
                        d_info = get_vm_disk_info(dom, disk)
                        if path == d_info["path"]:
                            used_by.append(vm)
                try:
                    session.store("storagevolume", path, {"used_by": used_by}, get_kimchi_version())
                except Exception as e:
                    # Let the exception be raised. If we allow disks'
                    #   used_by to be out of sync, data corruption could
                    #   occour if a disk is added to two guests
                    #   unknowingly.
                    wok_log.error("Unable to store storage volume id in" " objectstore due error: %s", e.message)
                    raise OperationFailed("KCHVOL0017E", {"err": e.message})
    except Exception as e:
        # This exception is going to catch errors returned by 'with',
        # specially ones generated by 'session.store'. It is outside
        # to avoid conflict with the __exit__ function of 'with'
        raise OperationFailed("KCHVOL0017E", {"err": e.message})
    return used_by
开发者ID:madhawa,项目名称:kimchi,代码行数:32,代码来源:diskutils.py

示例13: get_list

 def get_list(self, _configured=None):
     """
     :param _configured: True will list only the network devices
     which are configured. znetconf -c will be used
     False will list only network devices which are not configured yet.
     znetconf -u will be used
     If not given then it will fetch both the list of devices.
     :return: network OSA device info list.
     """
     wok_log.info('Fetching network devices. _configured '
                  '= %s' % _configured)
     if _configured is None:
         devices = _get_configured_devices()
         devices.extend(_get_unconfigured_devices())
     elif _configured in ['True', 'true']:
         devices = _get_configured_devices()
     elif _configured in ['False', 'false']:
         devices = _get_unconfigured_devices()
     else:
         wok_log.error("Invalid _configured given. _configured: %s"
                       % _configured)
         raise InvalidParameter("GS390XINVTYPE",
                                {'supported_type': 'True/False'})
     wok_log.info('Successfully retrieved network devices')
     return devices
开发者ID:pawankg,项目名称:gingers390x,代码行数:25,代码来源:nwdevices.py

示例14: _create_ifcfg_file

def _create_ifcfg_file(interface):
    """
    method to create ifcfg-enccw<device_id> file in
    /etc/sysconfig/network-scripts/ folder and change
    persmission of that file to 644 to be in sync with
    other files in directory

    :param interface: network device id
    :return: None
    """
    wok_log.info('creating ifcfg file for %s', interface)
    ifcfg_file_path = '/' + ifcfg_path.replace('<deviceid>', interface)
    try:
        ifcfg_file = open(ifcfg_file_path, 'w+')
        ifcfg_file.close()
        os.system('chmod 644 ' + ifcfg_file_path)
        wok_log.info('created file %s for network device %s'
                     % (ifcfg_file_path, interface))
    except Exception as e:
        wok_log.error('failed to create file %s for network device %s. '
                      'Error: %s' % (ifcfg_file_path, interface, e.__str__()))
        raise OperationFailed("GS390XIONW005E",
                              {'ifcfg_file_path': ifcfg_file_path,
                               'device': interface,
                               'error': e.__str__()})
开发者ID:pawankg,项目名称:gingers390x,代码行数:25,代码来源:nwdevices.py

示例15: get_mlx5_nic_type

def get_mlx5_nic_type(mlx5_iface):
    """Checks lspci output to see if mlx5_iface is a physical or
    virtual nic interface.

    This is the lspci output this function is expecting for a mlx5 virtual
    nic interface:

    'Ethernet controller: Mellanox Technologies MT27700 Family
     [ConnectX-4 Virtual Function]'

    Verification will be done by checking for the 'Virtual Function'
    string in the output. Any other lspci output format or any other
    error will make this function return the default value 'physical'.

    Args:
        mlx5_iface (str): interface loaded by the mlx5_core driver.

    Returns:
        str: 'virtual' if mlx5_iface is a virtual function/nic,
            'physical' otherwise.

    """
    bus_id = get_mlx5_nic_bus_id(mlx5_iface)

    lspci_cmd = ['lspci', '-s', bus_id]
    out, err, r_code = run_command(lspci_cmd)

    if r_code == 0 and 'Virtual Function' in out:
        return 'virtual'

    if r_code != 0:
        wok_log.error('Error while getting nic type of '
                      'interface: %s' % err)

    return 'physical'
开发者ID:open-power-host-os,项目名称:gingerbase,代码行数:35,代码来源:netinfo.py


注:本文中的wok.utils.wok_log.error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。