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__,