Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
 def get_cpu_info(self):
     """get vm cpu info"""
     cpu_info = {'quantity': self._instance['vcpus']}
     cpu_qos = utils.dict_filter_and_convert(self._extra_specs,
                                             constant.CPU_QOS_NOVA_KEY,
                                             constant.CPU_QOS_FC_KEY)
     cpu_info = utils.dict_add(cpu_info, cpu_qos)
     return cpu_info
Ejemplo n.º 4
0
    def _gen_old_flavor_for_fc(self, instance):
        """

        :param instance:
        :return:
        """
        flavor_dict = {
            'vcpus':instance['vmConfig']['cpu']['quantity'],
            'memory_mb':instance['vmConfig']['memory']['quantityMB']
        }

        cpu_qos = utils.dict_filter_and_convert(instance['vmConfig']['cpu'],
                                                constant.CPU_QOS_FC_KEY,
                                                constant.CPU_QOS_FC_KEY)
        flavor_dict = utils.dict_add(flavor_dict, cpu_qos)
        return flavor_dict
Ejemplo n.º 5
0
    def _gen_old_flavor_for_fc(self, instance):
        """

        :param instance:
        :return:
        """
        flavor_dict = {
            'vcpus': instance['vmConfig']['cpu']['quantity'],
            'memory_mb': instance['vmConfig']['memory']['quantityMB']
        }

        cpu_qos = utils.dict_filter_and_convert(instance['vmConfig']['cpu'],
                                                constant.CPU_QOS_FC_KEY,
                                                constant.CPU_QOS_FC_KEY)
        flavor_dict = utils.dict_add(flavor_dict, cpu_qos)
        return flavor_dict
Ejemplo n.º 6
0
    def _gen_new_flavor_for_fc(self, flavor):
        """

        :param flavor:
        :return:
        """
        flavor_dict = {
            'vcpus':flavor['vcpus'],
            'memory_mb':flavor['memory_mb']
        }
        extra_specs = flavor.get('extra_specs', None)
        if extra_specs:
            cpu_qos = utils.dict_filter_and_convert(extra_specs,
                                                    constant.CPU_QOS_NOVA_KEY,
                                                    constant.CPU_QOS_FC_KEY)
            flavor_dict = utils.dict_add(flavor_dict, cpu_qos)
        return flavor_dict
Ejemplo n.º 7
0
    def _gen_new_flavor_for_fc(self, flavor):
        """

        :param flavor:
        :return:
        """
        flavor_dict = {
            'vcpus': flavor['vcpus'],
            'memory_mb': flavor['memory_mb']
        }
        extra_specs = flavor.get('extra_specs', None)
        if extra_specs:
            cpu_qos = utils.dict_filter_and_convert(extra_specs,
                                                    constant.CPU_QOS_NOVA_KEY,
                                                    constant.CPU_QOS_FC_KEY)
            flavor_dict = utils.dict_add(flavor_dict, cpu_qos)
        return flavor_dict