From 85f9d927f5becfca94e90941a3f01f96c6dbf439 Mon Sep 17 00:00:00 2001 From: "Joseph W. Breu" Date: Thu, 1 Dec 2011 11:23:08 -0600 Subject: Add availabity_zone to the refresh list The availability_zone column for a service record is not updated if the availability_zone is changed after the record was created. This patch adds availability_zone to the update list in report_state if the availability_zone stored in the database does not match the local flag Change-Id: I869384af113517adfba3a675f757e51687b3c15e --- nova/service.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'nova') diff --git a/nova/service.py b/nova/service.py index 47c88eede..fe6bf8e59 100644 --- a/nova/service.py +++ b/nova/service.py @@ -259,6 +259,8 @@ class Service(object): def report_state(self): """Update the state of this service in the datastore.""" ctxt = context.get_admin_context() + zone = FLAGS.node_availability_zone + state_catalog = {} try: try: service_ref = db.service_get(ctxt, self.service_id) @@ -268,9 +270,12 @@ class Service(object): self._create_service_ref(ctxt) service_ref = db.service_get(ctxt, self.service_id) + state_catalog['report_count'] = service_ref['report_count'] + 1 + if zone != service_ref['availability_zone']: + state_catalog['availability_zone'] = zone + db.service_update(ctxt, - self.service_id, - {'report_count': service_ref['report_count'] + 1}) + self.service_id, state_catalog) # TODO(termie): make this pattern be more elegant. if getattr(self, 'model_disconnected', False): -- cgit