Create volume in the same availability zone as instance

Volume should be created in the same availability zone as an instance to
prevent:
 > InvalidVolume: Instance and volume not in same availability_zone

Change-Id: I121cbdb68ec06d9b358a12c857dc24b75d7973e4
Closes-Bug: #1380780
This commit is contained in:
Andrey Kurilin
2015-02-18 17:33:22 +02:00
parent 7885332a11
commit 6060888b58
2 changed files with 16 additions and 12 deletions

View File

@@ -512,8 +512,8 @@ class TestDriverBlockDevice(test.NoDBTestCase):
self.volume_api.get_snapshot(self.context,
'fake-snapshot-id-1').AndReturn(snapshot)
self.volume_api.create(self.context, 3,
'', '', snapshot).AndReturn(volume)
self.volume_api.create(self.context, 3, '', '', snapshot,
availability_zone=None).AndReturn(volume)
wait_func(self.context, 'fake-volume-id-2').AndReturn(None)
instance, expected_conn_info = self._test_volume_attach(
test_bdm, no_volume_snapshot, volume)
@@ -556,8 +556,8 @@ class TestDriverBlockDevice(test.NoDBTestCase):
wait_func = self.mox.CreateMockAnything()
self.volume_api.create(self.context, 1,
'', '', image_id=image['id']).AndReturn(volume)
self.volume_api.create(self.context, 1, '', '', image_id=image['id'],
availability_zone=None).AndReturn(volume)
wait_func(self.context, 'fake-volume-id-2').AndReturn(None)
instance, expected_conn_info = self._test_volume_attach(
test_bdm, no_volume_image, volume)
@@ -606,10 +606,9 @@ class TestDriverBlockDevice(test.NoDBTestCase):
test_bdm.attach(self.context, instance, self.volume_api,
self.virt_driver)
vol_create.assert_called_once_with(self.context,
test_bdm.volume_size,
'fake-uuid-blank-vol',
'')
vol_create.assert_called_once_with(
self.context, test_bdm.volume_size, 'fake-uuid-blank-vol',
'', availability_zone=instance.availability_zone)
vol_attach.assert_called_once_with(self.context, instance,
self.volume_api,
self.virt_driver,