summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph W. Breu <breu@breu.org>2011-12-01 11:23:08 -0600
committerJoseph W. Breu <breu@breu.org>2011-12-02 16:41:20 -0600
commit85f9d927f5becfca94e90941a3f01f96c6dbf439 (patch)
tree8ce52a7fa1b117856c5fcb62093685ce5c32e94d
parent022295ecc2a936eab98b8a1900690ac0cd87b134 (diff)
downloadnova-85f9d927f5becfca94e90941a3f01f96c6dbf439.tar.gz
nova-85f9d927f5becfca94e90941a3f01f96c6dbf439.tar.xz
nova-85f9d927f5becfca94e90941a3f01f96c6dbf439.zip
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
-rw-r--r--nova/service.py9
1 files changed, 7 insertions, 2 deletions
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):