diff options
author | Liam Kelleher <liam.kelleher@hp.com> | 2013-02-11 15:51:53 +0000 |
---|---|---|
committer | Liam Kelleher <liam.kelleher@hp.com> | 2013-02-14 17:29:18 +0000 |
commit | 1504cbc5d4a27695fa663f0b0f3f7b48745bdb45 (patch) | |
tree | f7c111b87437e99fe79ead9429bf265dda83eee9 /nova/volume | |
parent | 4ffddcfa6385703ce9a02f624999f05b388778e6 (diff) | |
download | nova-1504cbc5d4a27695fa663f0b0f3f7b48745bdb45.tar.gz nova-1504cbc5d4a27695fa663f0b0f3f7b48745bdb45.tar.xz nova-1504cbc5d4a27695fa663f0b0f3f7b48745bdb45.zip |
Add option to allow cross AZ attach configurable
Make check_attach() optionally check if the volume and instance
are in the same availability zone and if cross AZ attach
is configured as not allowed report error.
This does not change the current default behaviour.
DocImpact: Adds a new Nova Config option
Change-Id: Ib0e085888b1c6620869261d87cd964de302accb3
Diffstat (limited to 'nova/volume')
-rw-r--r-- | nova/volume/cinder.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 05918f83d..b58e63011 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -51,6 +51,10 @@ cinder_opts = [ cfg.BoolOpt('cinder_api_insecure', default=False, help='Allow to perform insecure SSL requests to cinder'), + cfg.BoolOpt('cinder_cross_az_attach', + default=True, + help='Allow attach between instance and volume in different ' + 'availability zones.'), ] CONF = cfg.CONF @@ -195,7 +199,7 @@ class API(base.Base): return rval - def check_attach(self, context, volume): + def check_attach(self, context, volume, instance=None): # TODO(vish): abstract status checking? if volume['status'] != "available": msg = _("status must be available") @@ -203,6 +207,10 @@ class API(base.Base): if volume['attach_status'] == "attached": msg = _("already attached") raise exception.InvalidVolume(reason=msg) + if instance and not CONF.cinder_cross_az_attach: + if instance['availability_zone'] != volume['availability_zone']: + msg = _("Instance and volume not in same availability_zone") + raise exception.InvalidVolume(reason=msg) def check_detach(self, context, volume): # TODO(vish): abstract status checking? |