bug 8335: changing the deployVm flow to take in a list of security group ids instead of a list of security group names

This commit is contained in:
abhishek 2011-02-03 11:19:54 -08:00
parent b75d23bb36
commit 2a38a58be0
5 changed files with 10 additions and 10 deletions

View File

@ -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";

View File

@ -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<String> 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<Long> 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<String> getSecurityGroupList() {
return securityGroupList;
public List<Long> getSecurityGroupIdList() {
return securityGroupIdList;
}
public Long getServiceOfferingId() {

View File

@ -36,7 +36,7 @@ public interface SecurityGroupManager {
public SecurityGroupVO createDefaultSecurityGroup( Long accountId);
public boolean addInstanceToGroups(Long userVmId, List<String> groups);
public boolean addInstanceToGroups(Long userVmId, List<Long> groups);
public void removeInstanceFromGroups(Long userVmId);

View File

@ -948,7 +948,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
@Override
@DB
public boolean addInstanceToGroups(final Long userVmId, final List<String> groups) {
public boolean addInstanceToGroups(final Long userVmId, final List<Long> 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<SecurityGroupVO> sgs = new ArrayList<SecurityGroupVO>();
for (String sg : groups) {
sgs.add(_securityGroupDao.findByAccountAndName(userVm.getAccountId(), sg));
for (Long sgId : groups) {
sgs.add(_securityGroupDao.findById(sgId));
}
final Set<SecurityGroupVO> uniqueGroups = new TreeSet<SecurityGroupVO>(new SecurityGroupVOComparator());
uniqueGroups.addAll(sgs);

View File

@ -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()) {