diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 3f329cdbb0a..96cd245a32e 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -134,7 +134,7 @@ public class ApiConstants { public static final String SCHEDULE = "schedule"; public static final String SCOPE = "scope"; public static final String SECRET_KEY = "secretkey"; - public static final String SECURITY_GROUP_LIST = "securitygrouplist"; + public static final String SECURITY_GROUP_ID_LIST = "securitygroupidlist"; public static final String SECURITY_GROUP_NAME = "securitygroupname"; public static final String SECURITY_GROUP_ID = "securitygroupid"; public static final String SENT = "sent"; diff --git a/api/src/com/cloud/api/commands/DeployVMCmd.java b/api/src/com/cloud/api/commands/DeployVMCmd.java index 6c7555ce105..00ffc2a3c8d 100644 --- a/api/src/com/cloud/api/commands/DeployVMCmd.java +++ b/api/src/com/cloud/api/commands/DeployVMCmd.java @@ -71,8 +71,8 @@ public class DeployVMCmd extends BaseAsyncCreateCmd { @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="the hypervisor on which to deploy the virtual machine") private String hypervisor; - @Parameter(name=ApiConstants.SECURITY_GROUP_LIST, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of security groups that going to be applied to the virtual machine. Should be passed only when vm is created from service offering with Direct Attach Network support") - private List securityGroupList; + @Parameter(name=ApiConstants.SECURITY_GROUP_ID_LIST, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of security groups id that going to be applied to the virtual machine. Should be passed only when vm is created from service offering with Direct Attach Network support") + private List securityGroupIdList; @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, required=true, description="the ID of the service offering for the virtual machine") private Long serviceOfferingId; @@ -129,8 +129,8 @@ public class DeployVMCmd extends BaseAsyncCreateCmd { return HypervisorType.getType(hypervisor); } - public List getSecurityGroupList() { - return securityGroupList; + public List getSecurityGroupIdList() { + return securityGroupIdList; } public Long getServiceOfferingId() { diff --git a/server/src/com/cloud/network/security/SecurityGroupManager.java b/server/src/com/cloud/network/security/SecurityGroupManager.java index d171f4e9fe8..0a8d1ae6020 100644 --- a/server/src/com/cloud/network/security/SecurityGroupManager.java +++ b/server/src/com/cloud/network/security/SecurityGroupManager.java @@ -36,7 +36,7 @@ public interface SecurityGroupManager { public SecurityGroupVO createDefaultSecurityGroup( Long accountId); - public boolean addInstanceToGroups(Long userVmId, List groups); + public boolean addInstanceToGroups(Long userVmId, List groups); public void removeInstanceFromGroups(Long userVmId); diff --git a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java index 6dea81da470..c26a0c9baf1 100644 --- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java +++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java @@ -948,7 +948,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG @Override @DB - public boolean addInstanceToGroups(final Long userVmId, final List groups) { + public boolean addInstanceToGroups(final Long userVmId, final List groups) { if (!_enabled) { return true; } @@ -958,8 +958,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG txn.start(); UserVm userVm = _userVMDao.acquireInLockTable(userVmId); //ensures that duplicate entries are not created. List sgs = new ArrayList(); - for (String sg : groups) { - sgs.add(_securityGroupDao.findByAccountAndName(userVm.getAccountId(), sg)); + for (Long sgId : groups) { + sgs.add(_securityGroupDao.findById(sgId)); } final Set uniqueGroups = new TreeSet(new SecurityGroupVOComparator()); uniqueGroups.addAll(sgs); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 7ed7a5ca42e..272f4321b0f 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2185,7 +2185,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager updateVmStateForFailedVmCreation(vm.getId()); } - _networkGroupMgr.addInstanceToGroups(vm.getId(), cmd.getSecurityGroupList()); + _networkGroupMgr.addInstanceToGroups(vm.getId(), cmd.getSecurityGroupIdList()); if (template.getEnablePassword()) {