diff options
author | Hans Lindgren <hanlind@kth.se> | 2014-10-13 14:21:07 +0200 |
---|---|---|
committer | Hans Lindgren <hanlind@kth.se> | 2015-04-13 19:05:55 +0200 |
commit | 19455514d1366f60c37ebd5e27da675cc7459f80 (patch) | |
tree | 52feaceaf3104455359675ab3b919df5fbf33211 /nova/servicegroup | |
parent | 232c7afcf6903c582962c8390e095345c8de4cfa (diff) | |
download | nova-19455514d1366f60c37ebd5e27da675cc7459f80.tar.gz |
Convert service and servicegroup to objects
This converts service and servicegroup to use objects instead of
proxying through conductor.
Adds missing object registration to cert and console scripts.
Related to blueprint liberty-objects
Change-Id: I87b077699c2ecbc25a83e5844e8c69fe147cec01
Diffstat (limited to 'nova/servicegroup')
-rw-r--r-- | nova/servicegroup/drivers/db.py | 25 | ||||
-rw-r--r-- | nova/servicegroup/drivers/mc.py | 8 |
2 files changed, 8 insertions, 25 deletions
diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py index aa4aac038e..ef5c49f992 100644 --- a/nova/servicegroup/drivers/db.py +++ b/nova/servicegroup/drivers/db.py @@ -18,9 +18,9 @@ from oslo_log import log as logging from oslo_utils import timeutils import six -from nova import conductor from nova import context from nova.i18n import _, _LE +from nova import objects from nova.servicegroup import api from nova.servicegroup.drivers import base @@ -34,16 +34,6 @@ LOG = logging.getLogger(__name__) class DbDriver(base.Driver): def __init__(self, *args, **kwargs): - """Creates an instance of the DB-based servicegroup driver. - - Valid kwargs are: - - db_allowed - Boolean. False if direct db access is not allowed and - alternative data access (conductor) should be used - instead. - """ - self.db_allowed = kwargs.get('db_allowed', True) - self.conductor_api = conductor.API(use_local=self.db_allowed) self.service_down_time = CONF.service_down_time def join(self, member, group, service=None): @@ -94,22 +84,17 @@ class DbDriver(base.Driver): LOG.debug('DB_Driver: get_all members of the %s group', group_id) rs = [] ctxt = context.get_admin_context() - services = self.conductor_api.service_get_all_by_topic(ctxt, group_id) + services = objects.ServiceList.get_by_topic(ctxt, group_id) for service in services: if self.is_up(service): - rs.append(service['host']) + rs.append(service.host) return rs def _report_state(self, service): """Update the state of this service in the datastore.""" - ctxt = context.get_admin_context() - state_catalog = {} try: - report_count = service.service_ref['report_count'] + 1 - state_catalog['report_count'] = report_count - - service.service_ref = self.conductor_api.service_update(ctxt, - service.service_ref, state_catalog) + service.service_ref.report_count += 1 + service.service_ref.save() # TODO(termie): make this pattern be more elegant. if getattr(service, 'model_disconnected', False): diff --git a/nova/servicegroup/drivers/mc.py b/nova/servicegroup/drivers/mc.py index 8bbaa95446..676c39efa7 100644 --- a/nova/servicegroup/drivers/mc.py +++ b/nova/servicegroup/drivers/mc.py @@ -21,9 +21,9 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils -from nova import conductor from nova import context from nova.i18n import _, _LE +from nova import objects from nova.openstack.common import memorycache from nova.servicegroup import api from nova.servicegroup.drivers import base @@ -42,8 +42,6 @@ class MemcachedDriver(base.Driver): if not CONF.memcached_servers: raise RuntimeError(_('memcached_servers not defined')) self.mc = memorycache.get_client() - self.db_allowed = kwargs.get('db_allowed', True) - self.conductor_api = conductor.API(use_local=self.db_allowed) def join(self, member_id, group_id, service=None): """Join the given service with its group.""" @@ -80,10 +78,10 @@ class MemcachedDriver(base.Driver): group_id) rs = [] ctxt = context.get_admin_context() - services = self.conductor_api.service_get_all_by_topic(ctxt, group_id) + services = objects.ServiceList.get_by_topic(ctxt, group_id) for service in services: if self.is_up(service): - rs.append(service['host']) + rs.append(service.host) return rs def _report_state(self, service): |