diff options
-rw-r--r-- | nova/db/sqlalchemy/api.py | 1 | ||||
-rw-r--r-- | nova/service.py | 8 | ||||
-rw-r--r-- | nova/servicegroup/drivers/db.py | 13 |
3 files changed, 8 insertions, 14 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 970332896..4a752d177 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -448,6 +448,7 @@ def service_update(context, service_id, values): service_ref = service_get(context, service_id, session=session) service_ref.update(values) service_ref.save(session=session) + return service_ref ################### diff --git a/nova/service.py b/nova/service.py index 0fde14baa..de000bfa8 100644 --- a/nova/service.py +++ b/nova/service.py @@ -421,12 +421,11 @@ class Service(object): self.model_disconnected = False ctxt = context.get_admin_context() try: - service_ref = self.conductor_api.service_get_by_args(ctxt, - self.host, - self.binary) + self.service_ref = self.conductor_api.service_get_by_args(ctxt, + self.host, self.binary) self.service_id = service_ref['id'] except exception.NotFound: - self._create_service_ref(ctxt) + self.service_ref = self._create_service_ref(ctxt) if self.backdoor_port is not None: self.manager.backdoor_port = self.backdoor_port @@ -479,6 +478,7 @@ class Service(object): } service = self.conductor_api.service_create(context, svc_values) self.service_id = service['id'] + return service def __getattr__(self, key): manager = self.__dict__.get('manager', None) diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py index 075db3ed8..e304f0f20 100644 --- a/nova/servicegroup/drivers/db.py +++ b/nova/servicegroup/drivers/db.py @@ -76,17 +76,10 @@ class DbDriver(api.ServiceGroupDriver): ctxt = context.get_admin_context() state_catalog = {} try: - try: - service_ref = db.service_get(ctxt, service.service_id) - except exception.NotFound: - LOG.debug(_('The service database object disappeared, ' - 'Recreating it.')) - service._create_service_ref(ctxt) - service_ref = db.service_get(ctxt, service.service_id) + report_count = service.service_ref['report_count'] + 1 + state_catalog['report_count'] = report_count - state_catalog['report_count'] = service_ref['report_count'] + 1 - - db.service_update(ctxt, + service.service_ref = db.service_update(ctxt, service.service_id, state_catalog) # TODO(termie): make this pattern be more elegant. |