From 8cd9e49a90f8ce7ee59420e4585c824e6dff889e Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Wed, 25 Mar 2015 16:33:16 -0700 Subject: [PATCH] Fixed access to instance_uuid in retype We missed an access to volume['instance_uuid'] in the multiattach patch. The instance_uuid and attached_host were moved into the volume_attachment table. This patch changes how we test to see if a volume is available or not, but checking the new location. Change-Id: I8844cd8c2947845f9efb11a2a1371efee2d28bbe Closes-Bug: 1436604 --- cinder/scheduler/manager.py | 4 ++-- cinder/tests/scheduler/test_scheduler.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cinder/scheduler/manager.py b/cinder/scheduler/manager.py index cc03b15ac..66acc4080 100644 --- a/cinder/scheduler/manager.py +++ b/cinder/scheduler/manager.py @@ -196,8 +196,8 @@ class SchedulerManager(manager.Manager): volume_ref, msg, reservations): if reservations: QUOTAS.rollback(context, reservations) - if (volume_ref['instance_uuid'] is None and - volume_ref['attached_host'] is None): + if (volume_ref['volume_attachment'] is None or + len(volume_ref['volume_attachment']) == 0): orig_status = 'available' else: orig_status = 'in-use' diff --git a/cinder/tests/scheduler/test_scheduler.py b/cinder/tests/scheduler/test_scheduler.py index 623fc3219..1248b30a8 100644 --- a/cinder/tests/scheduler/test_scheduler.py +++ b/cinder/tests/scheduler/test_scheduler.py @@ -239,7 +239,9 @@ class SchedulerManagerTestCase(test.TestCase): request_spec = {'volume_id': fake_volume_id, 'volume_type': {'id': 3}, 'migration_policy': 'on-demand'} vol_info = {'id': fake_volume_id, 'status': 'in-use', - 'instance_uuid': 'foo', 'attached_host': None} + 'volume_attachment': [{'id': 'fake_id', + 'instance_uuid': 'foo', + 'attached_host': None}]} _mock_vol_get.return_value = vol_info _mock_vol_update.return_value = {'status': 'in-use'} -- 2.45.2