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


Python LOG.info方法代码示例

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


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

示例1: live_migration

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [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

示例2: finish_revert_migration

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def finish_revert_migration(self, instance, power_on=True):
        """

        :param instance:
        :param power_on:
        :return:
        """

        LOG.info(_("begin finish_revert_migration ..."))

        # 1. get flavor info from fc
        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        #ignore pylint:disable=W0612
        old_flavor, new_flavor = self._get_flavor_from_group(fc_vm.group)

        # 2. check cpu mem changes
        location = self._cluster_ops.\
            get_cluster_urn_by_nodename(instance['node'])
        data = self._generate_vm_spec_info(location=location,
                                           flavor=old_flavor)
        self.modify_vm(fc_vm, vm_config=data)
        LOG.info(_("modify cpu and mem success."))

        # 5. clear vm group info
        self._reset_vm_group(fc_vm)

        # 6. power on vm if needed
        if power_on:
            self.start_vm(instance)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:31,代码来源:computeops.py

示例3: attach_interface

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [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

示例4: _modify_boot_option_if_needed

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

        :param instance: OpenStack instance object
        :param fc_vm: FusionCompute vm object
        :return:
        """

        new_boot_option = utils.get_boot_option_from_metadata(
            instance.get('metadata'))

        old_boot_option = None
        if 'vmConfig' in fc_vm:
            vm_property = fc_vm['vmConfig'].get('properties')
            old_boot_option = vm_property.get('bootOption') if vm_property \
                              else None

        if new_boot_option and old_boot_option and \
           new_boot_option != old_boot_option:
            LOG.info(_("trying to modify boot option from %s to %s") %
                     (old_boot_option, new_boot_option))
            body = {
                'properties':{
                    'bootOption': new_boot_option
                }
            }
            try:
                self.modify_vm(instance, vm_config=body)
            except Exception as msg:
                LOG.error(_("modify boot option has exception: %s") % msg)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:32,代码来源:computeops.py

示例5: attach_volume

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def attach_volume(self, connection_info, instance, mountpoint):
        """
        Attach volume for vm
        :param connection_info:
        :param instance:
        :return:
        """
        LOG.info(_("trying to attach vol for vm: %s.") % instance['name'])
        # 0. set qos io
        self._volume_ops.set_qos_specs_to_volume(connection_info)

        # 1. volume can only be attached when vm is running or stopped
        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        if fc_vm.status not in [constant.VM_STATUS.RUNNING,
                                constant.VM_STATUS.STOPPED]:
            reason = _("vm status is not running or stopped !")
            raise fc_exc.InstanceAttachvolFailure(reason=reason)

        # 2. ignore this op when vm already has this volume
        vol_urn = self._get_vol_urn_from_connection(connection_info)
        if self._check_if_vol_in_instance(fc_vm, vol_urn) is True:
            LOG.info(_("vm %s already has vol %s, consider it success"),
                     fc_vm.name, vol_urn)
            return

        # 3. attach this volume
        self._volume_action(self._volume_ops.attach_volume,
                            vol_urn, fc_vm, mountpoint)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:30,代码来源:computeops.py

示例6: detach_volume

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def detach_volume(self, connection_info, instance):
        """
        Detach volume for vm
        :param connection_info:
        :param instance:
        :return:
        """
        LOG.info(_("trying to detach vol for vm: %s.") % instance['name'])

        # 1. volume can only be detached when vm is running or stopped
        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        if fc_vm.status not in [constant.VM_STATUS.RUNNING,
                                constant.VM_STATUS.STOPPED]:
            reason = _("vm status is not running or stopped !")
            raise fc_exc.InstanceDetachvolFailure(reason=reason)

        # 2. ignore this op when vm do not have this volume
        vol_urn = self._get_vol_urn_from_connection(connection_info)
        if self._check_if_vol_in_instance(fc_vm, vol_urn) is False:
            LOG.info(_("vol %s is not in vm %s, consider it success"),
                     vol_urn, fc_vm.name)
            return

        # 3. detach this volume
        self._volume_action(self._volume_ops.detach_volume, vol_urn, fc_vm)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:27,代码来源:computeops.py

示例7: request_msg

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def request_msg(self, method, path, data=None, headers=None, **kwargs):
        req_headers = self._update_and_get_headers(headers, False)

        # set default request time out
        kwargs['timeout'] = kwargs.get('timeout', self.__request_time_out)
        rsp = self._request(method, path, data, headers=req_headers, **kwargs)

        if rsp.status_code in self.STATUS_NO_AUTH:
            LOG.info('token may expired, fetch again.')
            req_headers = self._update_and_get_headers(headers, True)
            rsp = self._request(method, path, data, headers=req_headers,
                                **kwargs)

        #catch message sending exception
        self._raise_if_not_in_status_ok(rsp)
        ret_data = {'response': rsp, 'data': None}

        if rsp.text:
            try:
                ret_data['data'] = rsp.json()
            #ignore pylint:disable=W0703
            except Exception as excp:
                LOG.warn(_('failed to loads json response data, %s'), excp)
                ret_data['data'] = rsp.text

        if kwargs.get('need_response', False):
            return ret_data
        return ret_data['data']
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:30,代码来源:fcclient.py

示例8: __init__

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def __init__(self, virtapi):
        LOG.info(_("begin to init FusionComputeDriver ..."))
        super(FusionComputeDriver, self).__init__(virtapi)

        self._client = FCBaseClient(
            constant.CONF.fusioncompute.fc_ip,
            constant.CONF.fusioncompute.fc_user,
            crypt.decrypt(constant.CONF.fusioncompute.fc_pwd),
            constant.FC_DRIVER_JOINT_CFG["user_type"],
            ssl=True,
            port=constant.FC_DRIVER_JOINT_CFG["fc_port"],
            api_version=constant.FC_DRIVER_JOINT_CFG["api_version"],
            request_time_out=constant.FC_DRIVER_JOINT_CFG["request_time_out"],
        )
        self._client.set_default_site()

        # task ops is need by other ops, init it first
        self.task_ops = taskops.TaskOperation(self._client)
        FC_MGR.set_client(self._client)

        self.network_ops = networkops.NetworkOps(self._client, self.task_ops)
        self.volume_ops = volumeops.VolumeOps(self._client, self.task_ops)
        self.cluster_ops = fc_cluster.ClusterOps(self._client, self.task_ops)
        self.compute_ops = computeops.ComputeOps(
            self._client, self.task_ops, self.network_ops, self.volume_ops, self.cluster_ops
        )
开发者ID:nash-x,项目名称:hws,代码行数:28,代码来源:driver.py

示例9: change_instance_info

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

        LOG.info(_("trying to change instance display_name = %s"),
                 instance['display_name'])

        body = {'name':instance['display_name']}
        try:
            self.modify_vm(instance,vm_config=body)
        except Exception as msg:
            LOG.error(_("change_instance_info has exception, msg = %s")
                  % msg)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:13,代码来源:computeops.py

示例10: get_total_vm_numbers

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
 def get_total_vm_numbers(self, **kwargs):
     """
     Get total numbers in fc
     :return:
     """
     instances = self._query_vm(limit=1, offset=0, detail=0, **kwargs)
     if not instances or not instances.get('total'):
         return 0
     total = int(instances.get('total'))
     LOG.info(_("total instance number is %d."), total)
     return total
开发者ID:nkapotoxin,项目名称:fs_spc111t_plus_hc,代码行数:13,代码来源:fcinstance.py

示例11: _delete_vm_with_fc_vm

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def _delete_vm_with_fc_vm(self, fc_vm, destroy_disks=True):
        """
        delete vm with fc instance, inner function
        :param fc_vm:
        :param destroy_disks:
        :return:
        """
        reserve_disks = {'isReserveDisks': 0 if destroy_disks else 1}
        LOG.info(_('Deleting VM on FC, instance: %s reserve_disks %s'),
                 fc_vm.name, jsonutils.dumps(reserve_disks))

        self.delete(utils.build_uri_with_params(fc_vm.uri, reserve_disks))
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:14,代码来源:computeops.py

示例12: delete_vm

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [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

示例13: confirm_migration

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

        :param instance:
        :return:
        """

        LOG.info(_("begin confirm_migration ..."))

        # clear vm group info
        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        self._reset_vm_group(fc_vm)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:14,代码来源:computeops.py

示例14: change_instance_metadata

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

        :param instance:
        :return:
        """
        LOG.info(_("trying to change metadata for vm: %s.") % instance['name'])

        try:
            fc_vm = FC_MGR.get_vm_by_uuid(instance)
            self._modify_boot_option_if_needed(instance, fc_vm)
        #ignore pylint:disable=W0703
        except Exception as msg:
            LOG.error(_("change_instance_metadata has exception, msg = %s")
                      % msg)
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:17,代码来源:computeops.py

示例15: suspend_vm

# 需要导入模块: from nova.fusioncompute.virt.huaweiapi.utils import LOG [as 别名]
# 或者: from nova.fusioncompute.virt.huaweiapi.utils.LOG import info [as 别名]
    def suspend_vm(self, instance):
        """suspend vm on FC

        :param instance:nova.objects.instance.Instance
        :return:
        """

        LOG.info(_("trying to suspend vm: %s."), instance['name'])
        fc_vm = FC_MGR.get_vm_by_uuid(instance)
        if fc_vm.status == constant.VM_STATUS.RUNNING:
            self.post(fc_vm.get_vm_action_uri('suspend'),
                      excp=exception.InstanceFaultRollback)
            LOG.info(_("suspend vm %s success"), fc_vm.name)
        else:
            LOG.error(_("error vm status: %s.") % fc_vm.status)
            raise exception.InstanceFaultRollback
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:18,代码来源:computeops.py


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