diff options
author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-03-17 06:35:00 -0700 |
---|---|---|
committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-03-17 06:35:00 -0700 |
commit | 40c27fc4ad4653155b676079f2e2677d18aee9ef (patch) | |
tree | 27e4f7df372017f1d1583b1255a76238387a5f5f /nova/manager.py | |
parent | 6f72ba3d88f31e6336725bcffe47fa2bd5f1dba0 (diff) | |
parent | 699abfe9e645ddbc854b42725247ab8fcd61517e (diff) | |
download | nova-40c27fc4ad4653155b676079f2e2677d18aee9ef.tar.gz nova-40c27fc4ad4653155b676079f2e2677d18aee9ef.tar.xz nova-40c27fc4ad4653155b676079f2e2677d18aee9ef.zip |
merge with trunk. moved scheduler_manager into manager. fixed tests
Diffstat (limited to 'nova/manager.py')
-rw-r--r-- | nova/manager.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/nova/manager.py b/nova/manager.py index 3d38504bd..f384e3f0f 100644 --- a/nova/manager.py +++ b/nova/manager.py @@ -53,8 +53,9 @@ This module provides Manager, a base class for managers. from nova import utils from nova import flags +from nova import log as logging from nova.db import base - +from nova.scheduler import api FLAGS = flags.FLAGS @@ -74,3 +75,28 @@ class Manager(base.Base): """Do any initialization that needs to be run if this is a standalone service. Child classes should override this method.""" pass + + +class SchedulerDependentManager(Manager): + """Periodically send capability updates to the Scheduler services. + Services that need to update the Scheduler of their capabilities + should derive from this class. Otherwise they can derive from + manager.Manager directly. Updates are only sent after + update_service_capabilities is called with non-None values.""" + def __init__(self, host=None, db_driver=None, service_name="undefined"): + self.last_capabilities = None + self.service_name = service_name + super(SchedulerDependentManager, self).__init__(host, db_driver) + + def update_service_capabilities(self, capabilities): + """Remember these capabilities to send on next periodic update.""" + self.last_capabilities = capabilities + + def periodic_tasks(self, context=None): + """Pass data back to the scheduler at a periodic interval""" + if self.last_capabilities: + logging.debug(_("Notifying Schedulers of capabilities ...")) + api.API.update_service_capabilities(context, self.service_name, + self.host, self.last_capabilities) + + super(SchedulerDependentManager, self).periodic_tasks(context) |