]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Set source volume to "in use" during clone
authorWalter A. Boring IV <walter.boring@hp.com>
Tue, 29 Jan 2013 19:52:46 +0000 (11:52 -0800)
committerWalter A. Boring IV <walter.boring@hp.com>
Tue, 29 Jan 2013 20:00:07 +0000 (12:00 -0800)
When we are cloning a volume, we now set the source volume's status
to 'in use'. This prevents a user from deleting the source volume while the
backend copies/clones the contents to the new volume.
When the cloning is complete, we reset the status to it's original
state.

Change-Id: Ie43345aba77df4671ed2b429645cf8d1af9b975b

cinder/volume/manager.py

index 72e7cd396500ee1f6bb9fc2d2995ae9b0352404b..5722ab1129b35cc41eedb6a3866c6ac9cd2c12b9 100644 (file)
@@ -176,8 +176,12 @@ class VolumeManager(manager.SchedulerDependentManager):
                     snapshot_ref)
             elif source_volid is not None:
                 src_vref = self.db.volume_get(context, source_volid)
+                self.db.volume_update(context, src_vref['id'],
+                                      {'status': 'in use'})
                 model_update = self.driver.create_cloned_volume(volume_ref,
                                                                 src_vref)
+                self.db.volume_update(context, src_vref['id'],
+                                      {'status': src_vref['status']})
             else:
                 # create the volume from an image
                 image_service, image_id = \