From 4338bea07003e7bcdd5a9565f1b203708f75b11f Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Tue, 14 Apr 2015 16:08:54 +0530 Subject: [PATCH] volume upload: cannot delete a volume in NotUploaded state Volume deletion is not allowed in NotUploaded or UploadInProgress states, added validation in delete volume API for same --- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 4ff7686cab8..533f6fa6162 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1169,11 +1169,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic VolumeVO volume = _volsDao.findById(volumeId); if (volume == null) { - throw new InvalidParameterValueException("Unable to aquire volume with ID: " + volumeId); + throw new InvalidParameterValueException("Unable to find volume with ID: " + volumeId); } if (!_snapshotMgr.canOperateOnVolume(volume)) { - throw new InvalidParameterValueException("There are snapshot creating on it, Unable to delete the volume"); + throw new InvalidParameterValueException("There are snapshot operations in progress on the volume, unable to delete it"); } _accountMgr.checkAccess(caller, null, true, volume); @@ -1189,6 +1189,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } } + if (volume.getState() == Volume.State.NotUploaded || volume.getState() == Volume.State.UploadInProgress) { + throw new InvalidParameterValueException("The volume is either getting uploaded or it may be initiated shortly, please wait for it to be completed"); + } + try { if (volume.getState() != Volume.State.Destroy && volume.getState() != Volume.State.Expunging && volume.getState() != Volume.State.Expunging) { Long instanceId = volume.getInstanceId();