mirror of https://github.com/apache/cloudstack.git
Fix restrictions on attach and restore VMs
This commit is contained in:
parent
3063b6cae5
commit
dc4f913afa
|
|
@ -1501,8 +1501,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
|
||||
UserVmVO vm = _userVmDao.findById(vmId);
|
||||
VolumeVO exstingVolumeOfVm = null;
|
||||
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
||||
List<VolumeVO> rootVolumesOfVm = _volsDao.findByInstanceAndType(vmId, Volume.Type.ROOT);
|
||||
if (rootVolumesOfVm.size() > 1) {
|
||||
if (rootVolumesOfVm.size() > 1 && template != null && !template.isDeployAsIs()) {
|
||||
throw new CloudRuntimeException("The VM " + vm.getHostName() + " has more than one ROOT volume and is in an invalid state.");
|
||||
} else {
|
||||
if (!rootVolumesOfVm.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -6730,13 +6730,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
needRestart = true;
|
||||
}
|
||||
|
||||
VMTemplateVO currentTemplate = _templateDao.findById(vm.getTemplateId());
|
||||
List<VolumeVO> rootVols = _volsDao.findByInstanceAndType(vmId, Volume.Type.ROOT);
|
||||
if (rootVols.isEmpty()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can not find root volume for VM " + vm.getUuid());
|
||||
ex.addProxyObject(vm.getUuid(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
if (rootVols.size() > 1) {
|
||||
if (rootVols.size() > 1 && currentTemplate != null && !currentTemplate.isDeployAsIs()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("There are " + rootVols.size() + " root volumes for VM " + vm.getUuid());
|
||||
ex.addProxyObject(vm.getUuid(), "vmId");
|
||||
throw ex;
|
||||
|
|
|
|||
Loading…
Reference in New Issue