Putting in an extra check to see if this volume is already attached to a VM

This commit is contained in:
Mike Tutkowski 2015-01-26 16:59:26 -07:00
parent c847831662
commit 8aa34d048a
1 changed files with 5 additions and 0 deletions

View File

@ -1174,6 +1174,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
private Volume orchestrateAttachVolumeToVM(Long vmId, Long volumeId, Long deviceId) {
VolumeInfo volumeToAttach = volFactory.getVolume(volumeId);
if (volumeToAttach.isAttachedVM()) {
throw new CloudRuntimeException("This volume is already attached to a VM.");
}
UserVmVO vm = _userVmDao.findById(vmId);
VolumeVO exstingVolumeOfVm = null;
List<VolumeVO> rootVolumesOfVm = _volsDao.findByInstanceAndType(vmId, Volume.Type.ROOT);