From 6e31461553cb3d82ea0fdc4355f25b96ee1e8b7e Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 8 Oct 2014 14:46:42 +0100 Subject: [PATCH] vmware: delete cpu_info data from get_available_resource The 'cpu_info' field in the dict from get_available_resource is supposed to provide information on the physical CPU model used in the host. The topology was supposed to provide the total socket count, the cores per socket and the threads per core. The data provided by the VMWare driver did not remotely match this definition. Instead the topology returned the total socket count across the entire set of hypervisor hosts, the total core count and the total thread count. The vendor/model information was also not the same, instead of being a single name it returned a list of names from each hypervisor host. Just delete the 'cpu_info' data entirely since there is nothing sensible that the VMWare driver can return for this field, given its 1:M compute<->hypervisor relationship. Cleanup before Blueprint: resource-objects Change-Id: I2071a60d6ad8e1208ac56af8b95b2daa63582bb6 --- nova/compute/resource_tracker.py | 7 +++++++ nova/tests/unit/virt/vmwareapi/test_driver_api.py | 7 +------ nova/tests/unit/virt/vmwareapi/test_vm_util.py | 14 +++----------- nova/virt/vmwareapi/driver.py | 6 +++++- nova/virt/vmwareapi/host.py | 6 +----- nova/virt/vmwareapi/vm_util.py | 9 +++------ 6 files changed, 20 insertions(+), 29 deletions(-) diff --git a/nova/compute/resource_tracker.py b/nova/compute/resource_tracker.py index d136238653..9d49eaf0a1 100644 --- a/nova/compute/resource_tracker.py +++ b/nova/compute/resource_tracker.py @@ -322,6 +322,13 @@ class ResourceTracker(object): return resources['host_ip'] = CONF.my_ip + # We want the 'cpu_info' to be None from the POV of the + # virt driver, but the DB requires it to be non-null so + # just force it to empty string + if ("cpu_info" not in resources or + resources["cpu_info"] is None): + resources["cpu_info"] = '' + # TODO(berrange): remove this once all virt drivers are updated # to report topology if "numa_topology" not in resources: diff --git a/nova/tests/unit/virt/vmwareapi/test_driver_api.py b/nova/tests/unit/virt/vmwareapi/test_driver_api.py index b43afbddfa..f20ee4bb10 100644 --- a/nova/tests/unit/virt/vmwareapi/test_driver_api.py +++ b/nova/tests/unit/virt/vmwareapi/test_driver_api.py @@ -28,7 +28,6 @@ from eventlet import greenthread import mock from mox3 import mox from oslo.config import cfg -from oslo.serialization import jsonutils from oslo.utils import timeutils from oslo.utils import units from oslo.vmware import exceptions as vexc @@ -2192,10 +2191,6 @@ class VMwareAPIVCDriverTestCase(VMwareAPIVMTestCase): def test_get_available_resource(self): stats = self.conn.get_available_resource(self.node_name) - cpu_info = {"model": ["Intel(R) Xeon(R)", "Intel(R) Xeon(R)"], - "vendor": ["Intel", "Intel"], - "topology": {"cores": 16, - "threads": 32}} self.assertEqual(stats['vcpus'], 32) self.assertEqual(stats['local_gb'], 1024) self.assertEqual(stats['local_gb_used'], 1024 - 500) @@ -2204,7 +2199,7 @@ class VMwareAPIVCDriverTestCase(VMwareAPIVMTestCase): self.assertEqual(stats['hypervisor_type'], 'VMware vCenter Server') self.assertEqual(stats['hypervisor_version'], 5001000) self.assertEqual(stats['hypervisor_hostname'], self.node_name) - self.assertEqual(stats['cpu_info'], jsonutils.dumps(cpu_info)) + self.assertIsNone(stats['cpu_info']) self.assertEqual(stats['supported_instances'], '[["i686", "vmware", "hvm"], ["x86_64", "vmware", "hvm"]]') diff --git a/nova/tests/unit/virt/vmwareapi/test_vm_util.py b/nova/tests/unit/virt/vmwareapi/test_vm_util.py index 82328ee133..0da9d83aed 100644 --- a/nova/tests/unit/virt/vmwareapi/test_vm_util.py +++ b/nova/tests/unit/virt/vmwareapi/test_vm_util.py @@ -100,22 +100,14 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): session = fake.FakeSession() with mock.patch.object(session, '_call_method', fake_call_method): result = vm_util.get_stats_from_cluster(session, "cluster1") - cpu_info = {} mem_info = {} if connection_state == "connected" and not maintenance_mode: - cpu_info['vcpus'] = 32 - cpu_info['cores'] = 16 - cpu_info['vendor'] = ["Intel", "Intel"] - cpu_info['model'] = ["Intel(R) Xeon(R)", - "Intel(R) Xeon(R)"] + vcpus = 32 else: - cpu_info['vcpus'] = 16 - cpu_info['cores'] = 8 - cpu_info['vendor'] = ["Intel"] - cpu_info['model'] = ["Intel(R) Xeon(R)"] + vcpus = 16 mem_info['total'] = 5120 mem_info['free'] = 3072 - expected_stats = {'cpu': cpu_info, 'mem': mem_info} + expected_stats = {'vcpus': vcpus, 'mem': mem_info} self.assertEqual(expected_stats, result) def test_get_stats_from_cluster_hosts_connected_and_active(self): diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py index 1fd92c56a6..9e0cc25a2a 100644 --- a/nova/virt/vmwareapi/driver.py +++ b/nova/virt/vmwareapi/driver.py @@ -430,7 +430,11 @@ class VMwareVCDriver(driver.ComputeDriver): 'hypervisor_type': host_stats['hypervisor_type'], 'hypervisor_version': host_stats['hypervisor_version'], 'hypervisor_hostname': host_stats['hypervisor_hostname'], - 'cpu_info': jsonutils.dumps(host_stats['cpu_info']), + # The VMWare driver manages multiple hosts, so there are + # likely many different CPU models in use. As such it is + # impossible to provide any meaningful info on the CPU + # model of the "host" + 'cpu_info': None, 'supported_instances': jsonutils.dumps( host_stats['supported_instances']), 'numa_topology': None, diff --git a/nova/virt/vmwareapi/host.py b/nova/virt/vmwareapi/host.py index 051f714e44..9cd3f25f1b 100644 --- a/nova/virt/vmwareapi/host.py +++ b/nova/virt/vmwareapi/host.py @@ -66,11 +66,7 @@ class VCState(object): stats = vm_util.get_stats_from_cluster(self._session, self._cluster) about_info = self._session._call_method(vim_util, "get_about_info") data = {} - data["vcpus"] = stats['cpu']['vcpus'] - data["cpu_info"] = {"vendor": stats['cpu']['vendor'], - "model": stats['cpu']['model'], - "topology": {"cores": stats['cpu']['cores'], - "threads": stats['cpu']['vcpus']}} + data["vcpus"] = stats['vcpus'] data["disk_total"] = capacity / units.Gi data["disk_available"] = freespace / units.Gi data["disk_used"] = data["disk_total"] - data["disk_available"] diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index 8c6bab1691..858b074754 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -964,7 +964,7 @@ def get_vm_state_from_name(session, vm_name): def get_stats_from_cluster(session, cluster): """Get the aggregate resource stats of a cluster.""" - cpu_info = {'vcpus': 0, 'cores': 0, 'vendor': [], 'model': []} + vcpus = 0 mem_info = {'total': 0, 'free': 0} # Get the Host and Resource Pool Managed Object Refs prop_dict = session._call_method(vim_util, "get_dynamic_properties", @@ -985,10 +985,7 @@ def get_stats_from_cluster(session, cluster): runtime_summary.connectionState == "connected"): # Total vcpus is the sum of all pCPUs of individual hosts # The overcommitment ratio is factored in by the scheduler - cpu_info['vcpus'] += hardware_summary.numCpuThreads - cpu_info['cores'] += hardware_summary.numCpuCores - cpu_info['vendor'].append(hardware_summary.vendor) - cpu_info['model'].append(hardware_summary.cpuModel) + vcpus += hardware_summary.numCpuThreads res_mor = prop_dict.get('resourcePool') if res_mor: @@ -1000,7 +997,7 @@ def get_stats_from_cluster(session, cluster): # overallUsage is the hypervisor's view of memory usage by VM's consumed = int(res_usage.overallUsage / units.Mi) mem_info['free'] = mem_info['total'] - consumed - stats = {'cpu': cpu_info, 'mem': mem_info} + stats = {'vcpus': vcpus, 'mem': mem_info} return stats