bug 8215: blocking snapshot creation for volumes attached to vms which are in destroyed or expunging state

status 8215: resolved fixed
This commit is contained in:
abhishek 2011-01-26 13:25:28 -08:00
parent 374a114723
commit b5d2ff71fc
1 changed files with 11 additions and 0 deletions

View File

@ -110,6 +110,7 @@ import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.dao.UserVmDao;
@Local(value={SnapshotManager.class, SnapshotService.class})
@ -359,6 +360,16 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
}
}
//if volume is attached to a vm in destroyed or expunging state; disallow
if(v.getInstanceId() != null) {
UserVmVO userVm = _vmDao.findById(v.getInstanceId());
if(userVm != null) {
if(userVm.getState().equals(State.Destroyed) || userVm.getState().equals(State.Expunging)) {
throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " due to the associated vm:"+userVm.getInstanceName()+" is in "+userVm.getState().toString()+" state");
}
}
}
SnapshotVO snapshot = null;
boolean backedUp = false;
try {