bug CS-14785: Allow attaching the volume for Uploaded volume. Also have transition fo delete volume.

This commit is contained in:
Nitin Mehta 2012-05-14 16:41:56 +05:30
parent 7eaa1cf6f8
commit acd55bac90
3 changed files with 10 additions and 1 deletions

View File

@ -60,6 +60,7 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
s_fsm.addTransition(UploadOp, Event.CopySucceeded, Ready);
s_fsm.addTransition(UploadOp, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Ready, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);

View File

@ -2825,6 +2825,14 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
throw new InvalidParameterValueException("Please specify a volume that is not attached to any VM.");
}
// Check that volume is completely Uploaded
if (volume.getState() == Volume.State.UploadOp){
VolumeHostVO volumeHost = _volumeHostDao.findByVolumeId(volume.getId());
if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS){
throw new InvalidParameterValueException("Please specify a volume that is not uploading");
}
}
// Check that the volume is not already destroyed
if (volume.getState() != Volume.State.Destroy) {
if (!destroyVolume(volume)) {

View File

@ -567,7 +567,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
throw new InvalidParameterValueException("Please specify a volume that has been created on a shared storage pool.");
}
if ( !(Volume.State.Allocated.equals(volume.getState()) || Volume.State.Ready.equals(volume.getState())) ) {
if ( !(Volume.State.Allocated.equals(volume.getState()) || Volume.State.Ready.equals(volume.getState()) || Volume.State.UploadOp.equals(volume.getState())) ) {
throw new InvalidParameterValueException("Volume state must be in Allocated or Ready state");
}