bug 7780: Assign vm to the group during vm deploy if "group" parameter is specified

status 7780: resolved fixed
This commit is contained in:
alena 2010-12-30 16:56:43 -08:00
parent bcab9e5d0d
commit 367cd8dfc9
1 changed files with 14 additions and 0 deletions

View File

@ -2112,6 +2112,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
String accountName = cmd.getAccountName();
Long domainId = cmd.getDomainId();
List<Long> networkList = cmd.getNetworkIds();
String group = cmd.getGroup();
Account owner = _accountDao.findActiveAccount(accountName, domainId);
if (owner == null) {
@ -2299,6 +2300,19 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
_usageEventDao.persist(usageEvent);
_accountMgr.incrementResourceCount(accountId, ResourceType.user_vm);
//Assign instance to the group
try{
if (group != null) {
boolean addToGroup = addInstanceToGroup(Long.valueOf(id), group);
if (!addToGroup) {
throw new CloudRuntimeException("Unable to assing Vm to the group " + group);
}
}
} catch (Exception ex) {
throw new CloudRuntimeException("Unable to assing Vm to the group " + group);
}
return vm;
}