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
This commit is contained in:
Hans Lindgren 2014-06-10 12:39:53 +02:00
parent 656884d60b
commit 9373b141c7
2 changed files with 6 additions and 0 deletions

View File

@ -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):

View File

@ -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")