def get_available_resource():
    """Retrieve resource info.

    This method is called when nova-compute launches, and
    as part of a periodic task.

    :returns: dictionary describing resources
    """

    host_info = vmutils.get_host_info()
    cpu_info = hostutils.get_cpus_info()
    local_gb, _, local_gb_used = _get_local_hdd_info_gb()

    resources = {
        "vcpus": host_info[constants.HOST_PROCESSOR_COUNT],
        "memory_mb": host_info[constants.HOST_MEMORY_SIZE],
        "memory_mb_used": (host_info[constants.HOST_MEMORY_SIZE] - host_info[constants.HOST_MEMORY_AVAILABLE]),
        "local_gb": local_gb,
        "local_gb_used": local_gb_used,
        "hypervisor_type": "vbox",
        "hypervisor_version": _get_hypervisor_version(),
        "hypervisor_hostname": platform.node(),
        "vcpus_used": 0,
        "cpu_info": jsonutils.dumps(cpu_info),
        "supported_instances": jsonutils.dumps(
            [(arch.I686, hv_type.VBOX, vm_mode.HVM), (arch.X86_64, hv_type.VBOX, vm_mode.HVM)]
        ),
        "numa_topology": None,
    }

    return resources
    def test_get_cpus_info(self, mock_host_info, mock_list):
        mock_host_info.return_value = fake.fake_host_info()
        mock_list.return_value = "{cpu_desc_key}: {cpu_model}".format(
            cpu_desc_key=constants.HOST_FIRST_CPU_DESCRIPTION,
            cpu_model=self._FAKE_MODEL)
        expected_topology = {
            'sockets': fake.FAKE_HOST_PROCESSOR_COUNT,
            'cores': fake.FAKE_HOST_PROCESSOR_CORE_COUNT,
            'threads': (fake.FAKE_HOST_PROCESSOR_COUNT /
                        fake.FAKE_HOST_PROCESSOR_CORE_COUNT)
        }
        cpu_info = hostutils.get_cpus_info()

        self.assertEqual(self._FAKE_VENDOR, cpu_info['vendor'])
        self.assertEqual(self._FAKE_MODEL, cpu_info['model'])
        self.assertEqual(expected_topology, cpu_info['topology'])
Example #3
0
    def test_get_cpus_info(self, mock_host_info, mock_list):
        mock_host_info.return_value = fake.fake_host_info()
        mock_list.return_value = "{cpu_desc_key}: {cpu_model}".format(
            cpu_desc_key=constants.HOST_FIRST_CPU_DESCRIPTION,
            cpu_model=self._FAKE_MODEL)
        expected_topology = {
            'sockets':
            fake.FAKE_HOST_PROCESSOR_COUNT,
            'cores':
            fake.FAKE_HOST_PROCESSOR_CORE_COUNT,
            'threads': (fake.FAKE_HOST_PROCESSOR_COUNT /
                        fake.FAKE_HOST_PROCESSOR_CORE_COUNT)
        }
        cpu_info = hostutils.get_cpus_info()

        self.assertEqual(self._FAKE_VENDOR, cpu_info['vendor'])
        self.assertEqual(self._FAKE_MODEL, cpu_info['model'])
        self.assertEqual(expected_topology, cpu_info['topology'])
Example #4
0
def get_available_resource():
    """Retrieve resource info.

    This method is called when nova-compute launches, and
    as part of a periodic task.

    :returns: dictionary describing resources
    """

    host_info = vmutils.get_host_info()
    cpu_info = hostutils.get_cpus_info()
    local_gb, _, local_gb_used = _get_local_hdd_info_gb()

    resources = {
        'vcpus':
        host_info[constants.HOST_PROCESSOR_COUNT],
        'memory_mb':
        host_info[constants.HOST_MEMORY_SIZE],
        'memory_mb_used': (host_info[constants.HOST_MEMORY_SIZE] -
                           host_info[constants.HOST_MEMORY_AVAILABLE]),
        'local_gb':
        local_gb,
        'local_gb_used':
        local_gb_used,
        'hypervisor_type':
        "vbox",
        'hypervisor_version':
        _get_hypervisor_version(),
        'hypervisor_hostname':
        platform.node(),
        'vcpus_used':
        0,
        'cpu_info':
        jsonutils.dumps(cpu_info),
        'supported_instances':
        jsonutils.dumps([(arch.I686, hv_type.VBOX, vm_mode.HVM),
                         (arch.X86_64, hv_type.VBOX, vm_mode.HVM)]),
        'numa_topology':
        None,
    }

    return resources