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/tests | |
| parent | 4ffddcfa6385703ce9a02f624999f05b388778e6 (diff) | |
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/tests')
| -rw-r--r-- | nova/tests/fake_volume.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nova/tests/fake_volume.py b/nova/tests/fake_volume.py index c7430ee6d..0d8a502a5 100644 --- a/nova/tests/fake_volume.py +++ b/nova/tests/fake_volume.py @@ -17,12 +17,17 @@ import uuid from nova import exception +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova.openstack.common import timeutils LOG = logging.getLogger(__name__) +CONF = cfg.CONF +CONF.import_opt('cinder_cross_az_attach', + 'nova.volume.cinder') + class fake_volume(): user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66' @@ -175,7 +180,7 @@ class API(object): LOG.info('deleting volume %s', volume['id']) self.volume_list = [v for v in self.volume_list if v != volume] - def check_attach(self, context, volume): + def check_attach(self, context, volume, instance=None): if volume['status'] != 'available': msg = _("status must be available") msg = "%s" % volume @@ -183,6 +188,10 @@ class API(object): 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): if volume['status'] == "available": |
