From 50a72d7f7174c9f80116e9702d9ead0c716921db Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Thu, 28 Oct 2010 16:26:18 -0700 Subject: [PATCH] bug 6740: update the group for a VM if a group name is given status 6740: resolved fixed --- server/src/com/cloud/vm/UserVmManagerImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 46e3f9063db..116acf1b741 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -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) {