Fixes for issues found while testing after the merge

This commit is contained in:
Prachi Damle 2013-04-11 12:17:31 -07:00
parent bbf7900732
commit eea0ed5c4e
3 changed files with 11 additions and 2 deletions

View File

@ -52,7 +52,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the affinity group. Mutually exclusive with name parameter", entityType = AffinityGroupResponse.class)
private Long id;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The ID of the affinity group. Mutually exclusive with id parameter")
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the affinity group. Mutually exclusive with id parameter")
private String name;

View File

@ -62,6 +62,7 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements
}
List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
groupVMIds.remove(vm.getId());
for (Long groupVMId : groupVMIds) {
VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);

View File

@ -130,7 +130,9 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
throw new InvalidParameterValueException(
"Either the affinity group Id or group name must be specified to delete the group");
}
if (affinityGroupId == null) {
affinityGroupId = group.getId();
}
// check permissions
_accountMgr.checkAccess(caller, null, true, group);
@ -302,11 +304,17 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
+ "; make sure the virtual machine is stopped and not in an error state before updating.");
}
Account caller = UserContext.current().getCaller();
Account owner = _accountMgr.getAccount(vmInstance.getAccountId());
// check that the affinity groups exist
for (Long affinityGroupId : affinityGroupIds) {
AffinityGroupVO ag = _affinityGroupDao.findById(affinityGroupId);
if (ag == null) {
throw new InvalidParameterValueException("Unable to find affinity group by id " + affinityGroupId);
} else {
// verify permissions
_accountMgr.checkAccess(caller, null, true, owner, ag);
}
}
_affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds);