diff --git a/nova/compute/manager.py b/nova/compute/manager.py index dcdf3f148e..24a040d7e7 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -217,7 +217,7 @@ def _get_image_meta(context, image_ref): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '2.8' + RPC_API_VERSION = '2.9' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -345,7 +345,7 @@ class ComputeManager(manager.SchedulerDependentManager): self.driver.filter_defer_apply_off() self._report_driver_status(context) - self._publish_service_capabilities(context) + self.publish_service_capabilities(context) def _get_power_state(self, context, instance): """Retrieve the power state for the given instance.""" diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index cb1ddede80..38d9b34268 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -136,6 +136,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): 2.6 - Remove migration_id, add migration to resize_instance 2.7 - Remove migration_id, add migration to confirm_resize 2.8 - Remove migration_id, add migration to finish_resize + 2.9 - Add publish_service_capabilities() ''' # @@ -529,6 +530,9 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): instance=instance_p), topic=_compute_topic(self.topic, ctxt, None, instance)) + def publish_service_capabilities(self, ctxt): + self.fanout_cast(ctxt, self.make_msg('publish_service_capabilities')) + class SecurityGroupAPI(nova.openstack.common.rpc.proxy.RpcProxy): '''Client side of the security group rpc API. diff --git a/nova/manager.py b/nova/manager.py index 275d98b61e..2a7570c3bb 100644 --- a/nova/manager.py +++ b/nova/manager.py @@ -225,8 +225,12 @@ class SchedulerDependentManager(Manager): self.last_capabilities = capabilities @periodic_task - def _publish_service_capabilities(self, context): - """Pass data back to the scheduler at a periodic interval.""" + def publish_service_capabilities(self, context): + """Pass data back to the scheduler. + + Called at a periodic interval. And also called via rpc soon after + the start of the scheduler. + """ if self.last_capabilities: LOG.debug(_('Notifying Schedulers of capabilities ...')) self.scheduler_rpcapi.update_service_capabilities(context, diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index 824dc9eb0d..4c3f8025a5 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -23,6 +23,7 @@ Scheduler Service import sys +from nova.compute import rpcapi as compute_rpcapi from nova.compute import utils as compute_utils from nova.compute import vm_states from nova import db @@ -258,3 +259,6 @@ class SchedulerManager(manager.Manager): @manager.periodic_task def _expire_reservations(self, context): QUOTAS.expire(context) + + def request_service_capabilities(self, context): + compute_rpcapi.ComputeAPI().publish_service_capabilities(context) diff --git a/nova/service.py b/nova/service.py index caff1672a1..ca128557f8 100644 --- a/nova/service.py +++ b/nova/service.py @@ -426,6 +426,9 @@ class Service(object): # Consume from all consumers in a thread self.conn.consume_in_thread() + if 'nova-scheduler' == self.binary: + self.manager.request_service_capabilities(ctxt) + if self.report_interval: pulse = utils.LoopingCall(self.report_state) pulse.start(interval=self.report_interval,