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:
parent
656884d60b
commit
9373b141c7
@ -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):
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user