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


Python LOG.debug方法代码示例

本文整理汇总了Python中nova.fusioncompute.virt.huaweiapi.utils.LOG.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.debug方法的具体用法?Python LOG.debug怎么用?Python LOG.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nova.fusioncompute.virt.huaweiapi.utils.LOG的用法示例。


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

示例1: ensure_network

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def ensure_network(self, network_info):
        """
            Ensure network resource on FC

        :param network_info: network_info from nova, dictionary type
        :return:
        """
        # NOTE: physical network only visible to admin user
        context = nova_ctxt.get_admin_context()

        network = self._get_network_from_neutron(context, network_info)
        LOG.debug(_('get network info from neutron: %s'), network)

        if network['provider:network_type'] == constant.TYPE_VXLAN:
            dvs_name = constant.CONF.fusioncompute.vxlan_dvs_name
        else:
            dvs_name = network['provider:physical_network']
        dvs_id = self._get_dvs_id_by_physnet_name(dvs_name)
        if not dvs_id:
            raise fc_exc.DVSwitchNotFound(
                dvs_id=network['provider:physical_network'])

        pg_adpt = PortGroupQueryAdapter(network, dvs_id)
        pg_data = self.query_port_group(pg_adpt)
        if not pg_data:
            try:
                pg_adpt = PortGroupCreateAdapter(network, dvs_id)
                pg_data = self.create_port_group(dvs_id, pg_adpt)
            except Exception as e:
                # race condition
                LOG.warn(_('create pg failed (%s), will check it again'), e)
                pg_adpt = PortGroupQueryAdapter(network, dvs_id)
                pg_data = self.query_port_group(pg_adpt)

        return pg_data['urn'] if pg_data else None
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:37,代码来源:networkops.py

示例2: _request

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def _request(self, method, path, data=None, headers=None, **kwargs):
        """
        send request msg
        :param method:
        :param path:
        :param data:
        :param headers:
        :param kwargs:
        :return:
        """

        url = self._to_url(path)

        if not data:
            data = jsonutils.dumps({})
        elif isinstance(data, dict) or isinstance(data, list):
            data = jsonutils.dumps(data)

        try:
            data_for_log = copy.deepcopy(jsonutils.loads(data))
            utils.drop_password_key(data_for_log)
            LOG.debug(_('request: %s %s %s'), method, url,
                jsonutils.dumps(data_for_log))
        except Exception:
            LOG.debug(_('request: %s %s'), method, url)

        rsp = requests.request(method, url, data=data, headers=headers,
                               verify=False, **kwargs)
        return rsp
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:31,代码来源:restclient.py

示例3: create_drs_rules

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def create_drs_rules(self, cluster, rule_name, rule_type):
        """

        :param cluster:
        :param rule_name:
        :param rule_type:
        :return:
        """

        rule = self._get_drs_rules_from_cluster(cluster, rule_name, rule_type)
        if rule:
            LOG.debug(_("drs rules %s already exists"), rule_name)
            return

        body = {
            'drsSetting':{
                'drsRules':[{
                    'operationType': constant.DRS_RULES_OP_TYPE_MAP['create'],
                    'ruleName': rule_name,
                    'ruleType': rule_type
                    }]
            }
        }
        self._modify_cluster(cluster, body)
        LOG.debug(_("create drs rules %s succeed"), rule_name)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:27,代码来源:cluster.py

示例4: get_cpu_usage

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def get_cpu_usage(self, monitor_period, cluster_urn):
        end_time = self.get_fc_current_time()
        start_time = end_time - (monitor_period*2)

        body = [
            {
                "startTime": str(start_time),
                "endTime": str(end_time),
                "interval": str(monitor_period),
                "metricId": "cpu_usage",
                "urn": cluster_urn
            }
        ]

        LOG.debug("get_cpu_usage body:%s", json.dumps(body))
        response = self.fc_client.post(self.site.metric_curvedata_uri,
                                       data=body)
        LOG.debug("get_cpu_usage body:%s response:%s",
                  json.dumps(body), json.dumps(response))
        if response:
            if len(response["items"]) > 0:
                metric_value = response["items"][0]["metricValue"]
                if len(metric_value) > 0:
                    value = metric_value[0]["value"]
                    if len(metric_value) is 2:
                        if metric_value[1]["value"] is not None:
                            value = metric_value[1]["value"]
                    return value
        return None
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:31,代码来源:cluster.py

示例5: _generate_vm_spec_info

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def _generate_vm_spec_info(self, location=None, flavor=None):
        """
        Generate the vm spec info for cole migration
        :param location:
        :param flavor:
        :return:
        """

        data = {}
        if location:
            data['location'] = location
        if flavor:
            if flavor.get('vcpus'):
                data['cpu'] = {
                    'quantity':flavor.get('vcpus')
                }

            if flavor.get('memory_mb'):
                data['memory'] = {
                    'quantityMB':flavor.get('memory_mb')
                }

            cpu_qos = utils.dict_filter_and_convert(flavor,
                                                    constant.CPU_QOS_FC_KEY,
                                                    constant.CPU_QOS_FC_KEY)
            if data.get('cpu', None):
                data['cpu'] = utils.dict_add(data['cpu'], cpu_qos)
            else:
                data['cpu'] = cpu_qos

        LOG.debug(_("vm spec data: %s.") % jsonutils.dumps(data))
        return data
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:34,代码来源:computeops.py

示例6: get_disks_info

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def get_disks_info(self):
        """get image disk detail info"""

        LOG.debug(_('prepare volume'))

        disks_info = []

        # sys vol info
        sys_disk_info = {
            'sequenceNum': 1,
            'quantityGB': self._instance['root_gb'],
            'isThin': constant.FC_DRIVER_JOINT_CFG['volume_is_thin']
        }
        disks_info.append(sys_disk_info)

        # user vol info
        for disk in self._volume_ops.ensure_volume(self._block_device_info):
            user_disk_info = {
                'pciType': disk['pci'],
                'volumeUrn': disk['urn'],
                'sequenceNum':
                    constant.MOUNT_DEVICE_SEQNUM_MAP[disk['mount_device']],
                'isThin': constant.FC_DRIVER_JOINT_CFG['volume_is_thin']
            }
            disks_info.append(user_disk_info)

        return disks_info
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:29,代码来源:vmcreation.py

示例7: attach_interface

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def attach_interface(self, instance, vif):
        """
        Send message to fusion compute virtual machine

        :param instance:
        :param vif:
        :return: response : {"taskUrn": string, "taskUri": string}
        """
        LOG.debug(_("trying to attach interface, vm name: %s,"
                    "vm uuid: %s, vif info: %s"), instance['name'],
                  instance['uuid'], vif)

        pg_urn = self._network_ops.ensure_network(vif['network'])
        vsp_body = {
            'name': vif['id'],
            'portId': vif['id'],
            'portGroupUrn': pg_urn,
            'mac': vif['address']
        }
        LOG.info("the vsp information is %s", vsp_body)

        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        attach_interface_uri = fc_vm.get_vm_action_uri('nics')

        response = self.post(attach_interface_uri,
                             data=vsp_body,
                             excp=exception.InterfaceAttachFailed)
        LOG.info('send attach interface finished, return is: %s',
                 jsonutils.dumps(response))
        return response
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:32,代码来源:computeops.py

示例8: modify_drs_rules

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def modify_drs_rules(self, cluster, rule_name, rule_type, vms):
        """

        :param cluster:
        :param rule_name:
        :param rule_type:
        :param vms:
        :return:
        """

        rule = self._get_drs_rules_from_cluster(cluster, rule_name, rule_type)
        if rule is None:
            msg = _("Can not find drs rules: name=%s, type=%d") % \
                  (rule_name, rule_type)
            raise fc_exc.AffinityGroupException(reason=msg)

        body = {
            'drsSetting':{
                'drsRules':[{
                    'operationType': constant.DRS_RULES_OP_TYPE_MAP['modify'],
                    'ruleIndex': rule['ruleIndex'],
                    'ruleName': rule_name,
                    'ruleType': rule_type,
                    'vms': vms
                    }]
            }
        }
        self._modify_cluster(cluster, body)
        LOG.debug(_("modify drs rules %s succeed"), rule_name)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:31,代码来源:cluster.py

示例9: detach_interface

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def detach_interface(self, instance, vif):
        """
        Send message to fusion compute virtual machine

        :param instance:
        :param vif:
        :return: response : {"taskUrn": string, "taskUri": string}
        if the nic does not exited, return {} else {"taskUrn": string,
        "taskUri": string}
        """
        LOG.debug(_("trying to detach interface for vm name: %s,"
                    "vm uuid: %s, vif information is %s"), instance['name'],
                  instance['uuid'], vif)

        response = {}
        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        nics = fc_vm["vmConfig"]["nics"]
        LOG.info("nics in FusionCompute is %s", nics)
        nic_uri = None
        for nic in nics:
            if nic['name'] == vif['id']:
                nic_uri = nic['uri']
                break

        if nic_uri:
            detach_interface_uri = (nic_uri.replace("nics", "virtualNics"))
            LOG.info("detach_interface_uri is %s", detach_interface_uri)
            response = self.delete(detach_interface_uri,
                                   excp=exception.InstanceInvalidState)
        else:
            LOG.warn(_("detach interface for vm name: %s, not exist nic."),
                     instance['name'])
        LOG.info(_('send detach interface finished, return is: %s'),
                 jsonutils.dumps(response))
        return response
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:37,代码来源:computeops.py

示例10: live_migration

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def live_migration(self, instance_ref, nodename):
        """Live migration of an instance to another host.

        :param instance_ref:
            nova.db.sqlalchemy.models.Instance object
            instance object that is migrated.
        :param nodename: destination node name

        """
        LOG.info(_("trying to migrate vm: %s.") % instance_ref['name'])

        # get destination cluster urn
        cluster_urn = self._cluster_ops.get_cluster_urn_by_nodename(nodename)
        if not cluster_urn:
            raise fc_exc.ClusterNotFound(cluster_name=nodename)
        LOG.debug(_("get cluster urn: %s."), cluster_urn)

        # generate migrate url and post msg to FC
        body = {
            'location': cluster_urn
        }
        fc_vm = FC_MGR.get_vm_by_uuid(instance_ref)
        self.post(fc_vm.get_vm_action_uri('migrate'), data=body,
                  excp=exception.MigrationError)
        LOG.info(_("migrate vm %s success" % fc_vm.name))
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:27,代码来源:computeops.py

示例11: _set_qos_specs_to_volume

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
        def _set_qos_specs_to_volume(self, connection_info):
            """

            :param connection_info
            :return:
            """
            qos_para = {'maxReadBytes': 0,
                        'maxWriteBytes': 0,
                        'maxReadRequest': 0,
                        'maxWriteRequest': 0}
            key_cvt_map = {'read_bytes_sec': 'maxReadBytes',
                           'write_bytes_sec': 'maxWriteBytes',
                           'read_iops_sec': 'maxReadRequest',
                           'write_iops_sec': 'maxWriteRequest'}
            tune_opts = ['read_bytes_sec', 'write_bytes_sec',
                         'read_iops_sec', 'write_iops_sec']
            tune_cvt_opts = ['read_bytes_sec', 'write_bytes_sec']
            # Extract rate_limit control parameters
            if connection_info is None or 'data' not in connection_info:
                return

            specs = connection_info['data']['qos_specs']
            vol_urn = connection_info.get('vol_urn')

            if vol_urn is None:
                return

            # because the volume can be detached and attach to another instance
            # qos maybe disassociated from volume type
            # between the up two operations
            # so if specs is none,set default value to FC.
            if specs is not None:
                if isinstance(specs, dict):
                    for key, value in specs.iteritems():
                        if key in tune_opts:
                            # convert byte to KB for FC,0 is no limited,
                            # the value is at least 1
                            output_value = value

                            if key in tune_cvt_opts:
                                addition = 0
                                if output_value.isdigit():
                                    if long(value) % 1024 != 0:
                                        addition = 1
                                    output_value = long(value) / 1024 \
                                                   + addition

                            qos_para[key_cvt_map[key]] = output_value
                else:
                    LOG.debug(_('Unknown content in connection_info '
                                'qos_specs: %s'), specs)
                    return

            qos_specs_uri = utils.generate_uri_from_urn(vol_urn) \
                            + constant.VOL_URI_MAP['modio']

            # Send Qos IO Specs to VRM with put method
            self.put(qos_specs_uri, data=qos_para,
                     excp=fc_exc.SetQosIoFailure)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:61,代码来源:volumeops.py

示例12: _get_volume_meta_data

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
 def _get_volume_meta_data(self, context, volume_id):
     """
     from cinder get volume metadata
     :param volume_id:
     :return:
     """
     LOG.debug(_('get_volume_meta_data enter, volume_id:%s.'), volume_id)
     return self._volume_api.get(context, volume_id)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:10,代码来源:volumeops.py

示例13: check_input

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
 def check_input(self):
     """
     check function input params
     :return:
     """
     os_option = self.get_os_options()
     LOG.debug(_('os option: %s .'), jsonutils.dumps(os_option))
     if not (os_option['osType'] and os_option['osVersion']):
         LOG.error('Invalid os option for vm %s!', self._instance['name'])
         raise fc_exc.InvalidOsOption()
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:12,代码来源:vmcreation.py

示例14: get_available_nodes

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def get_available_nodes(self, refresh=True):
        """Returns nodenames of all nodes managed by the compute service."""

        # default is refresh to ensure it is latest
        if refresh:
            self.cluster_ops.update_resources()

        node_list = self.cluster_ops.resources
        LOG.debug(_("The available nodes are: %s") % node_list)
        return node_list
开发者ID:nash-x,项目名称:hws,代码行数:12,代码来源:driver.py

示例15: delete_vm

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import debug [as 别名]
    def delete_vm(self, context, instance, block_device_info=None,
                  destroy_disks=True):
        """Delete VM on FC

        :param context:
        :param instance:
        :param block_device_info:
        :param destroy_disks:
        :return:
        """

        # if revert resize, only stop vm. when resize operation
        # task state will be resize_reverting or resize_confirming
        if instance and (instance.get('task_state') == 'resize_reverting'
                         or instance.get('task_state') == 'resize_confirming'):
            LOG.info(_('revert resize now, here only stop vm.'))
            try:
                self.stop_vm(instance)
            except Exception as e:
                LOG.warn(_('stop vm failed, trigger rollback'))
                raise exception.InstanceFaultRollback(inner_exception=e)
            return

        try:
            fc_vm = FC_MGR.get_vm_by_uuid(instance)
        except exception.InstanceNotFound:
            LOG.warn(_('instance exist no more. ignore this deleting.'))
            return

        # detach volume created by cinder
        if block_device_info:
            LOG.info(_('now will stop vm before detach cinder volumes.'))
            self.stop_vm(instance)
            for vol in block_device_info['block_device_mapping']:
                self.detach_volume(vol['connection_info'], instance)

        # if vm is in fault-resuming or unknown status, stop it before delete
        if fc_vm.status == constant.VM_STATUS.UNKNOWN \
        or fc_vm.status == constant.VM_STATUS.FAULTRESUMING:
            LOG.debug(_("vm %s status is fault-resuming or unknown, "
                        "stop it before delete."), fc_vm.uri)
            self.stop_vm(instance)

        self._delete_vm_with_fc_vm(fc_vm, destroy_disks)

        # update affinity group info if needed
        try:
            self._update_drs_rules(instance)
            self._update_affinity_groups(context, instance)
        #ignore pylint:disable=W0703
        except Exception as excp:
            utils.log_exception(excp)
            LOG.error(_('update affinity group info failed !'))
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:55,代码来源:computeops.py


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