diff options
author | Hans Lindgren <hanlind@kth.se> | 2014-11-24 12:03:32 +0100 |
---|---|---|
committer | Sylvain Bauza <sbauza@redhat.com> | 2015-09-09 17:14:35 +0200 |
commit | 479005ce5a35039639fa809b1a4705c9d3dc28c4 (patch) | |
tree | 890ae54246732dfa2ca2eb8913c0db4627a58456 /nova/availability_zones.py | |
parent | e68db1157a2060dad5fea8ee1980fdc232754f4b (diff) | |
download | nova-479005ce5a35039639fa809b1a4705c9d3dc28c4.tar.gz |
Consolidate code to get the correct availability zone of an instance
This makes getting the availability zone of an instance use the same
code by placing it inside the helper get_instance_availability_zone().
Related-Bug: #1390033
Change-Id: I69b98eacbc8dc91e65611d6bf07272b517fe350d
Diffstat (limited to 'nova/availability_zones.py')
-rw-r--r-- | nova/availability_zones.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nova/availability_zones.py b/nova/availability_zones.py index 4f1775f29a..11b5aef7c7 100644 --- a/nova/availability_zones.py +++ b/nova/availability_zones.py @@ -167,9 +167,13 @@ def get_availability_zones(context, get_only_available=False, def get_instance_availability_zone(context, instance): """Return availability zone of specified instance.""" - host = str(instance.get('host')) + host = instance.get('host') if not host: - return None + # Likely hasn't reached a viable compute node yet so give back the + # desired availability_zone in the instance record if the boot request + # specified one. + az = instance.get('availability_zone') + return az cache_key = _make_cache_key(host) cache = _get_cache() |