コード例 #1
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
コード例 #2
0
ファイル: hostutils.py プロジェクト: yunbox/nova-virtualbox
def get_cpus_info():
    """Get the CPU information.

    :returns: A dictionary containing the main properties
    of the central processor in the hypervisor.
    """

    cpu_info = {}
    topology = {}
    host_info = vmutils.get_host_info()
    all_infos = manage.VBoxManage.list(constants.HOST_INFO)

    topology['sockets'] = host_info[constants.HOST_PROCESSOR_COUNT]
    topology['cores'] = host_info[constants.HOST_PROCESSOR_CORE_COUNT]
    topology['threads'] = topology['sockets'] / topology['cores']

    cpu_info['topology'] = topology
    cpu_info['arch'] = 'Unknown'
    cpu_info['model'] = None
    cpu_info['vendor'] = None
    cpu_info['features'] = []

    for line in all_infos.splitlines():
        if line.startswith(constants.HOST_FIRST_CPU_DESCRIPTION):
            cpu_info['model'] = line.split(':')[1].strip()
            cpu_info['vendor'] = cpu_info['model'].split()[0]
            break

    return cpu_info
コード例 #3
0
def get_cpus_info():
    """Get the CPU information.

    :returns: A dictionary containing the main properties
    of the central processor in the hypervisor.
    """

    cpu_info = {}
    topology = {}
    host_info = vmutils.get_host_info()
    all_infos = manage.VBoxManage.list(constants.HOST_INFO)

    topology['sockets'] = host_info[constants.HOST_PROCESSOR_COUNT]
    topology['cores'] = host_info[constants.HOST_PROCESSOR_CORE_COUNT]
    topology['threads'] = topology['sockets'] / topology['cores']

    cpu_info['topology'] = topology
    cpu_info['arch'] = 'Unknown'
    cpu_info['model'] = None
    cpu_info['vendor'] = None
    cpu_info['features'] = []

    for line in all_infos.splitlines():
        if line.startswith(constants.HOST_FIRST_CPU_DESCRIPTION):
            cpu_info['model'] = line.split(':')[1].strip()
            cpu_info['vendor'] = cpu_info['model'].split()[0]
            break

    return cpu_info
コード例 #4
0
    def test_get_host_info(self, mock_list):
        mock_list.return_value = fake.FakeVBoxManage.list_host_info()
        response = vmutils.get_host_info()

        self.assertEqual(fake.FAKE_HOST_PROCESSOR_COUNT,
                         response[constants.HOST_PROCESSOR_COUNT])
        self.assertEqual(fake.FAKE_HOST_PROCESSOR_CORE_COUNT,
                         response[constants.HOST_PROCESSOR_CORE_COUNT])
        self.assertEqual(fake.FAKE_HOST_MEMORY_AVAILABLE,
                         response[constants.HOST_MEMORY_AVAILABLE])
        self.assertEqual(fake.FAKE_HOST_MEMORY_SIZE,
                         response[constants.HOST_MEMORY_SIZE])
コード例 #5
0
    def test_get_host_info(self, mock_list):
        mock_list.return_value = fake.FakeVBoxManage.list_host_info()
        response = vmutils.get_host_info()

        self.assertEqual(fake.FAKE_HOST_PROCESSOR_COUNT,
                         response[constants.HOST_PROCESSOR_COUNT])
        self.assertEqual(fake.FAKE_HOST_PROCESSOR_CORE_COUNT,
                         response[constants.HOST_PROCESSOR_CORE_COUNT])
        self.assertEqual(fake.FAKE_HOST_MEMORY_AVAILABLE,
                         response[constants.HOST_MEMORY_AVAILABLE])
        self.assertEqual(fake.FAKE_HOST_MEMORY_SIZE,
                         response[constants.HOST_MEMORY_SIZE])
コード例 #6
0
ファイル: hostops.py プロジェクト: yunbox/nova-virtualbox
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
コード例 #7
0
    def test_get_host_info_default(self, mock_list):
        mock_list.return_value = fake.FakeVBoxManage.list_host_info(False)
        response = vmutils.get_host_info()

        self.assertEqual(0, response[constants.HOST_PROCESSOR_COUNT])
コード例 #8
0
    def test_get_host_info_default(self, mock_list):
        mock_list.return_value = fake.FakeVBoxManage.list_host_info(False)
        response = vmutils.get_host_info()

        self.assertEqual(0, response[constants.HOST_PROCESSOR_COUNT])