mirror of https://github.com/apache/cloudstack.git
Remove user vm from instance_group when empty string is passed as value for "group" parameter in updateVirtualMachine API.
This commit is contained in:
parent
e46306b5d7
commit
49143dbe4a
|
|
@ -66,11 +66,7 @@ public class UpdateVMCmd extends BaseCmd{
|
|||
// default userId to SYSTEM user
|
||||
if (userId == null) {
|
||||
userId = Long.valueOf(1);
|
||||
}
|
||||
|
||||
//don't accept empty parameter for the group
|
||||
if (group != null && group.isEmpty())
|
||||
group = null;
|
||||
}
|
||||
|
||||
// Verify input parameters
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -2804,9 +2804,14 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
if (group != null) {
|
||||
boolean addToGroup = _vmMgr.addInstanceToGroup(Long.valueOf(vmId), group);
|
||||
if (!addToGroup) {
|
||||
throw new CloudRuntimeException("Unable to update Vm with the the group " + group);
|
||||
if (group.isEmpty()) {
|
||||
_vmMgr.removeInstanceFromGroup(vmId);
|
||||
}
|
||||
else {
|
||||
boolean addToGroup = _vmMgr.addInstanceToGroup(Long.valueOf(vmId), group);
|
||||
if (!addToGroup) {
|
||||
throw new CloudRuntimeException("Unable to update Vm with the the group " + group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -232,5 +232,7 @@ public interface UserVmManager extends Manager, VirtualMachineManager<UserVmVO>
|
|||
boolean addInstanceToGroup(long userVmId, String group);
|
||||
|
||||
InstanceGroupVO getGroupForVm(long vmId);
|
||||
|
||||
void removeInstanceFromGroup(long vmId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3154,6 +3154,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeInstanceFromGroup(long vmId) {
|
||||
try {
|
||||
List<InstanceGroupVMMapVO> groupVmMaps = _groupVMMapDao.listByInstanceId(vmId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue