From 9373b141c79f8fc69fc21442e29c5c4a25ec0a52 Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Tue, 10 Jun 2014 12:39:53 +0200 Subject: [PATCH] Add missing stats to IronicNodeState This is the second in a series of patches to prepare Ironic for the removal of capabilities in Nova HostManager. IronicHostManager used to rely on capabilities info to decide which host state class to use, VM or baremetal. This has been broken since host capabilities reporting were removed in Nova, resulting in Nova HostState class always being used. Before IronicNodeState class can be used again, it must be updated to store host stats as this is needed by ComputeCapabilitiesFilter to correctly filter hosts or this filter will return no hosts. Change-Id: I1661107883722bf14a488842373fd3027dc7a62c Partial-Bug: #1260265 --- ironic/nova/scheduler/ironic_host_manager.py | 4 ++++ ironic/nova/tests/scheduler/test_ironic_host_manager.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ironic/nova/scheduler/ironic_host_manager.py b/ironic/nova/scheduler/ironic_host_manager.py index d31411ea48..ff4375f6b6 100644 --- a/ironic/nova/scheduler/ironic_host_manager.py +++ b/ironic/nova/scheduler/ironic_host_manager.py @@ -22,6 +22,7 @@ subdivided into multiple instances. """ from oslo.config import cfg +from nova.openstack.common import jsonutils from nova.openstack.common import log as logging from nova.openstack.common import timeutils from nova.scheduler import host_manager @@ -70,6 +71,9 @@ class IronicNodeState(host_manager.HostState): self.vcpus_total = compute['vcpus'] self.vcpus_used = compute['vcpus_used'] + stats = compute.get('stats', '{}') + self.stats = jsonutils.loads(stats) + self.updated = compute['updated_at'] def consume_from_instance(self, instance): diff --git a/ironic/nova/tests/scheduler/test_ironic_host_manager.py b/ironic/nova/tests/scheduler/test_ironic_host_manager.py index 560bc0e669..c8de6dd365 100644 --- a/ironic/nova/tests/scheduler/test_ironic_host_manager.py +++ b/ironic/nova/tests/scheduler/test_ironic_host_manager.py @@ -128,6 +128,8 @@ class IronicHostManagerChangedNodesTestCase(test.NoDBTestCase): self.assertEqual(10240, host.free_disk_mb) self.assertEqual(1, host.vcpus_total) self.assertEqual(0, host.vcpus_used) + self.assertEqual(jsonutils.loads(self.compute_node['stats']), + host.stats) def test_consume_identical_instance_from_compute(self): host = ironic_host_manager.IronicNodeState("fakehost", "fakenode")