3
# Copyright 2014 Red Hat, Inc.
4
# Copyright 2013 Hewlett-Packard Development Company, L.P.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
"""Short term workaround for friction in the Nova compute manager with Ironic.
21
https://etherpad.openstack.org/p/ironic-nova-friction contains current design
22
work. The goal here is to generalise the areas where n-c talking to a clustered
23
hypervisor has issues, and long term fold them into the main ComputeManager.
26
from nova.compute import manager
30
class ClusteredComputeManager(manager.ComputeManager):
33
"""Initialization for a clustered compute service."""
34
self.driver.init_host(host=self.host)
36
# context = nova.context.get_admin_context()
37
# instances = instance_obj.InstanceList.get_by_host(
38
# context, self.host, expected_attrs=['info_cache'])
40
# defer_iptables_apply is moot for clusters - no local iptables
41
# if CONF.defer_iptables_apply:
42
# self.driver.filter_defer_apply_on()
44
self.init_virt_events()
47
# evacuation is moot for a clustered hypervisor
48
# # checking that instance was not already evacuated to other host
49
# self._destroy_evacuated_instances(context)
50
# Don't run _init_instance until we solve the partitioning problem
51
# - with N n-cpu's all claiming the same hostname, running
52
# _init_instance here would lead to race conditions where each runs
53
# _init_instance concurrently.
54
# for instance in instances:
55
# self._init_instance(context, instance)
57
# defer_iptables_apply is moot for clusters - no local iptables
58
# if CONF.defer_iptables_apply:
59
# self.driver.filter_defer_apply_off()
61
def pre_start_hook(self):
62
"""After the service is initialized, but before we fully bring
63
the service up by listening on RPC queues, make sure to update
64
our available resources (and indirectly our available nodes).
66
# This is an optimisation to immediately advertise resources but
67
# the periodic task will update them eventually anyway, so ignore
68
# errors as they may be transient (e.g. the scheduler isn't
69
# available...). XXX(lifeless) this applies to all ComputeManagers
70
# and once I feature freeze is over we should push that to nova
73
self.update_available_resource(nova.context.get_admin_context())