summaryrefslogtreecommitdiff
path: root/nova/volume
diff options
context:
space:
mode:
authorHans Lindgren <hanlind@kth.se>2014-11-24 12:03:32 +0100
committerSylvain Bauza <sbauza@redhat.com>2015-09-09 17:14:35 +0200
commit479005ce5a35039639fa809b1a4705c9d3dc28c4 (patch)
tree890ae54246732dfa2ca2eb8913c0db4627a58456 /nova/volume
parente68db1157a2060dad5fea8ee1980fdc232754f4b (diff)
downloadnova-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/volume')
-rw-r--r--nova/volume/cinder.py8
1 files changed, 1 insertions, 7 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index 088013754f..94775cb20d 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -293,13 +293,7 @@ class API(object):
msg = _("volume %s already attached") % volume['id']
raise exception.InvalidVolume(reason=msg)
if instance and not CONF.cinder.cross_az_attach:
- # NOTE(sorrison): If instance is on a host we match against it's AZ
- # else we check the intended AZ
- if instance.get('host'):
- instance_az = az.get_instance_availability_zone(
- context, instance)
- else:
- instance_az = instance['availability_zone']
+ instance_az = az.get_instance_availability_zone(context, instance)
if instance_az != volume['availability_zone']:
msg = _("Instance %(instance)s and volume %(vol)s are not in "
"the same availability_zone. Instance is in "