summaryrefslogtreecommitdiffstats
path: root/nova/manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/manager.py')
-rw-r--r--nova/manager.py28
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)