bug 6740: update the group for a VM if a group name is given

status 6740: resolved fixed
This commit is contained in:
Kris McQueen 2010-10-28 16:26:18 -07:00
parent 72d678b80e
commit 50a72d7f71

View File

@ -3432,6 +3432,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
@Override
public void updateVirtualMachine(UpdateVMCmd cmd) {
String displayName = cmd.getDisplayName();
String group = cmd.getGroup();
Boolean ha = cmd.getHaEnable();
Long id = cmd.getId();
Account account = UserContext.current().getAccount();
@ -3439,14 +3440,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
//Input validation
UserVmVO vmInstance = null;
// Verify input parameters
try
{
try {
vmInstance = _vmDao.findById(id.longValue());
}
catch (Exception ex1)
{
} catch (Exception ex1) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "unable to find virtual machine by id");
}
@ -3459,7 +3457,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if (displayName == null) {
displayName = vmInstance.getDisplayName();
}
if (ha == null) {
ha = vmInstance.isHaEnabled();
}
@ -3470,6 +3468,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
throw new CloudRuntimeException("Unable to find virual machine with id " + id);
}
if (group != null) {
addInstanceToGroup(id, group);
}
boolean haEnabled = vm.isHaEnabled();
_vmDao.updateVM(id, displayName, ha);
if (haEnabled != ha) {