diff options
| author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-05-08 15:47:47 -0700 |
|---|---|---|
| committer | Phil Day <philip.day@hp.com> | 2013-06-26 21:08:13 +0100 |
| commit | 5ff0278561d4008bc710440129f4a7b5c38cdd98 (patch) | |
| tree | cd3ac4c33477a1ed089822514c07736d84bded85 /nova/api | |
| parent | 7696c3c11f0de855cbc53cc04ee7d2be07ae3b9c (diff) | |
Report the az based on the value in the instance table.
When attempting to find the availability zone of an instance
do so by first trying to locate the availability zone of the
host the instance is active on. If that fails then attempt
to use the value that is in the instances 'availability_zone'
key instead.
For the caching used in the availability_zones module there
was a new method added to get and reset the cache that is
useful for unit tests, since during each run of a test you
do not want to be affected by something in cache from a previous
test.
Fixes bug 1172246
Change-Id: I6f54a44cc87434120656ccc789cebcc08d434418
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/extended_availability_zone.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/contrib/extended_availability_zone.py b/nova/api/openstack/compute/contrib/extended_availability_zone.py index 00765e209..6e77cd6bd 100644 --- a/nova/api/openstack/compute/contrib/extended_availability_zone.py +++ b/nova/api/openstack/compute/contrib/extended_availability_zone.py @@ -20,7 +20,7 @@ from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil -from nova import availability_zones +from nova import availability_zones as avail_zone authorize = extensions.soft_extension_authorizer('compute', 'extended_availability_zone') @@ -29,8 +29,13 @@ authorize = extensions.soft_extension_authorizer('compute', class ExtendedAZController(wsgi.Controller): def _extend_server(self, context, server, instance): key = "%s:availability_zone" % Extended_availability_zone.alias - server[key] = availability_zones.get_instance_availability_zone( - context, instance) + az = avail_zone.get_instance_availability_zone(context, instance) + if not az and instance.get('availability_zone'): + # Likely hasn't reached a viable compute node yet so give back the + # desired availability_zone that *may* exist in the instance + # record itself. + az = instance['availability_zone'] + server[key] = az @wsgi.extends def show(self, req, resp_obj, id): |
