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
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4338bea0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4338bea0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4338bea0 Branch: refs/heads/master Commit: 4338bea07003e7bcdd5a9565f1b203708f75b11f Parents: 5c152e5 Author: Koushik Das <kous...@apache.org> Authored: Tue Apr 14 16:08:54 2015 +0530 Committer: Koushik Das <kous...@apache.org> Committed: Tue Apr 14 16:08:54 2015 +0530 ---------------------------------------------------------------------- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4338bea0/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 4ff7686..533f6fa 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();