From f1bbc53206fc80941da27bfc28d1d71ed95d5511 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 8 Oct 2014 15:33:32 +0100 Subject: [PATCH] ironic: 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, including arch, model, vendor, feature flags and topology. Instead Ironic simply returns a dummy string "baremetal cpu". Just delete the 'cpu_info' data entirely since there is nothing sensible that the Ironic driver can return for this field, given its 1:M compute<->hypervisor relationship. The IronicHostManager was apparently looking for this string "baremetal cpu" to distinguish Ironic compute hosts from non-Ironic compute hosts. This is rather crazy when we have an explicit "hypervisor_type" field available, so replace that check. Cleanup before Blueprint: resource-objects Change-Id: I7cb4f74e588c18879a2a747f158049d83359ee4c --- nova/scheduler/ironic_host_manager.py | 2 +- nova/tests/unit/scheduler/test_ironic_host_manager.py | 2 +- nova/virt/ironic/driver.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nova/scheduler/ironic_host_manager.py b/nova/scheduler/ironic_host_manager.py index faee26a8f4f1..59f3839a4c13 100644 --- a/nova/scheduler/ironic_host_manager.py +++ b/nova/scheduler/ironic_host_manager.py @@ -104,7 +104,7 @@ class IronicHostManager(host_manager.HostManager): def host_state_cls(self, host, node, **kwargs): """Factory function/property to create a new HostState.""" compute = kwargs.get('compute') - if compute and compute.get('cpu_info') == 'baremetal cpu': + if compute and compute.get('hypervisor_type') == 'ironic': return IronicNodeState(host, node, **kwargs) else: return host_manager.HostState(host, node, **kwargs) diff --git a/nova/tests/unit/scheduler/test_ironic_host_manager.py b/nova/tests/unit/scheduler/test_ironic_host_manager.py index 50ec038cb3f5..472e9dbf6efa 100644 --- a/nova/tests/unit/scheduler/test_ironic_host_manager.py +++ b/nova/tests/unit/scheduler/test_ironic_host_manager.py @@ -108,7 +108,7 @@ class IronicHostManagerChangedNodesTestCase(test.NoDBTestCase): @mock.patch.object(ironic_host_manager.IronicNodeState, '__init__') def test_create_ironic_node_state(self, init_mock): init_mock.return_value = None - compute = {'cpu_info': 'baremetal cpu'} + compute = {'hypervisor_type': 'ironic'} host_state = self.host_manager.host_state_cls('fake-host', 'fake-node', compute=compute) self.assertIs(ironic_host_manager.IronicNodeState, type(host_state)) diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py index c10df8b2627c..2136246779c1 100644 --- a/nova/virt/ironic/driver.py +++ b/nova/virt/ironic/driver.py @@ -254,7 +254,11 @@ class IronicDriver(virt_driver.ComputeDriver): 'hypervisor_hostname': str(node.uuid), 'hypervisor_type': self._get_hypervisor_type(), 'hypervisor_version': self._get_hypervisor_version(), - 'cpu_info': 'baremetal cpu', + # The Ironic 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, 'vcpus': vcpus, 'vcpus_used': vcpus_used, 'local_gb': local_gb,