From d534811cbcfe591688b5e9c6becbed2224be3c31 Mon Sep 17 00:00:00 2001 From: Avishay Traeger Date: Wed, 25 Sep 2013 08:41:21 +0300 Subject: [PATCH] Fix mandatory and optional args for create_volume Calls to create_volume (both volume_rpcapi and scheduler_rpcapi) pass mandatory args as optional and reverse. This patch fixes the calls to be according to the function definition. Also, fix the call to create_volume in the migration code where allow_reschedule defaults to True, but we don't pass request_spec so it prints a warning and disables it. Change-Id: I9509f88866e0ae182f90ebdfca1fcf415ca60d19 Closes-Bug: #1230069 --- cinder/scheduler/filter_scheduler.py | 3 +-- cinder/tests/test_volume.py | 3 ++- cinder/volume/flows/create_volume/__init__.py | 13 +++++++------ cinder/volume/manager.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cinder/scheduler/filter_scheduler.py b/cinder/scheduler/filter_scheduler.py index c47b41d4f..247e72f1a 100644 --- a/cinder/scheduler/filter_scheduler.py +++ b/cinder/scheduler/filter_scheduler.py @@ -80,8 +80,7 @@ class FilterScheduler(driver.Scheduler): filter_properties.pop('context', None) self.volume_rpcapi.create_volume(context, updated_volume, host, - request_spec=request_spec, - filter_properties=filter_properties, + request_spec, filter_properties, allow_reschedule=True, snapshot_id=snapshot_id, image_id=image_id) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 8ce5b7357..7ebfe7329 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -1713,7 +1713,8 @@ class VolumeTestCase(BaseVolumeTestCase): def fake_delete_volume_rpc(self, ctxt, vol_id): raise Exception('should not be called') - def fake_create_volume(self, ctxt, volume, host, req_spec, filters): + def fake_create_volume(self, ctxt, volume, host, req_spec, filters, + allow_reschedule=True): db.volume_update(ctxt, volume['id'], {'status': 'available'}) diff --git a/cinder/volume/flows/create_volume/__init__.py b/cinder/volume/flows/create_volume/__init__.py index de2192c48..0353f5261 100644 --- a/cinder/volume/flows/create_volume/__init__.py +++ b/cinder/volume/flows/create_volume/__init__.py @@ -732,8 +732,8 @@ class VolumeCastTask(base.CinderTask): context, CONF.volume_topic, volume_id, - snapshot_id, - image_id, + snapshot_id=snapshot_id, + image_id=image_id, request_spec=request_spec, filter_properties=filter_properties) else: @@ -746,8 +746,8 @@ class VolumeCastTask(base.CinderTask): context, volume_ref, volume_ref['host'], - request_spec=request_spec, - filter_properties=filter_properties, + request_spec, + filter_properties, allow_reschedule=False, snapshot_id=snapshot_id, image_id=image_id, @@ -893,8 +893,9 @@ class OnFailureRescheduleTask(base.CinderTask): retry_info['exc'] = traceback.format_exception(*cause.exc_info) return create_volume(context, CONF.volume_topic, volume_id, - snapshot_id, image_id, request_spec, - filter_properties) + snapshot_id=snapshot_id, image_id=image_id, + request_spec=request_spec, + filter_properties=filter_properties) def _post_reschedule(self, context, volume_id): """Actions that happen after the rescheduling attempt occur here.""" diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 34b4357ab..1c291f699 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -652,7 +652,7 @@ class VolumeManager(manager.SchedulerDependentManager): new_vol_values['attach_status'] = 'detached' new_volume = self.db.volume_create(ctxt, new_vol_values) rpcapi.create_volume(ctxt, new_volume, host['host'], - None, None) + None, None, allow_reschedule=False) # Wait for new_volume to become ready starttime = time.time() -- 2.45.2