From 5486935a01ef3ed58b5b43dea4598847d87f759d Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Sat, 17 May 2014 13:42:40 +0200 Subject: [PATCH] Remove traces of now unused host capabilities from scheduler This is take two of this patch. This time after preparing Baremetal and Ironic code to work with the HostManager changes introduced in this patch. Host capabilities updates are no longer used by the scheduler. All host state is instead fetched from the DB. Some left over fields are still kept by the host manager but contain no data. This change remove the last traces of host capabilities from the scheduler. Baremetal/Ironic host managers 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. This change works in tandem with prior updates to Baremetal/Ironic node detection logic to fix this problem. Important: This must not be approved until the Ironic patch in https://review.openstack.org/97447 has first landed! Change-Id: Id5f88c0aa1df9152ddb62904b0544801a8bcfd2a Closes-Bug: #1260265 --- nova/scheduler/host_manager.py | 26 ++++++-------------- nova/tests/virt/test_ironic_api_contracts.py | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index da62d102e380..68167f334b8b 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -109,10 +109,9 @@ class HostState(object): previously used and lock down access. """ - def __init__(self, host, node, capabilities=None, service=None): + def __init__(self, host, node, compute=None): self.host = host self.nodename = node - self.update_capabilities(capabilities, service) # Mutable available resources. # These will change as resources are virtually "consumed". @@ -147,15 +146,10 @@ class HostState(object): self.metrics = {} self.updated = None + if compute: + self.update_from_compute_node(compute) - def update_capabilities(self, capabilities=None, service=None): - # Read-only capability dicts - - if capabilities is None: - capabilities = {} - self.capabilities = ReadOnlyDict(capabilities) - if service is None: - service = {} + def update_service(self, service): self.service = ReadOnlyDict(service) def _update_metrics_from_compute_node(self, compute): @@ -325,8 +319,6 @@ class HostManager(object): host_state_cls = HostState def __init__(self): - # { (host, hypervisor_hostname) : { : { cap k : v }}} - self.service_states = {} self.host_state_map = {} self.filter_handler = filters.HostFilterHandler() self.filter_classes = self.filter_handler.get_matching_classes( @@ -454,17 +446,13 @@ class HostManager(object): host = service['host'] node = compute.get('hypervisor_hostname') state_key = (host, node) - capabilities = self.service_states.get(state_key, None) host_state = self.host_state_map.get(state_key) if host_state: - host_state.update_capabilities(capabilities, - dict(service.iteritems())) + host_state.update_from_compute_node(compute) else: - host_state = self.host_state_cls(host, node, - capabilities=capabilities, - service=dict(service.iteritems())) + host_state = self.host_state_cls(host, node, compute=compute) self.host_state_map[state_key] = host_state - host_state.update_from_compute_node(compute) + host_state.update_service(dict(service.iteritems())) seen_nodes.add(state_key) # remove compute nodes from host_state_map if they are not active diff --git a/nova/tests/virt/test_ironic_api_contracts.py b/nova/tests/virt/test_ironic_api_contracts.py index e025d358ca3e..6fcdf3d3b7fd 100644 --- a/nova/tests/virt/test_ironic_api_contracts.py +++ b/nova/tests/virt/test_ironic_api_contracts.py @@ -30,7 +30,7 @@ class IronicAPIContractsTestCase(test.NoDBTestCase): def test_HostState_signatures(self): self._check_method(host_manager.HostState.__init__, "HostState.__init__", - ['self', 'host', 'node', 'capabilities', 'service']) + ['self', 'host', 'node', 'compute']) def test_HostManager_signatures(self): self._check_method(host_manager.HostManager.__init__,