mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-2159 Anti-Affinity - When "HostAntiAffinityProcessor" plugin is not included in the deployment , deployVirtualMachine() command does not error out when passing the affiitygroupnames parameter.
Changes: - Added a check during vm deployment to see if a processor for the affinity group type is available
This commit is contained in:
parent
221a053861
commit
9a9d277884
|
|
@ -73,4 +73,6 @@ public interface AffinityGroupService {
|
|||
|
||||
UserVm updateVMAffinityGroups(Long vmId, List<Long> affinityGroupIds);
|
||||
|
||||
boolean isAffinityGroupProcessorAvailable(String affinityGroupType);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -900,7 +900,9 @@
|
|||
|
||||
<bean id="UcsManager" class="com.cloud.ucs.manager.UcsManagerImpl" />
|
||||
|
||||
<bean id="AffinityGroupServiceImpl" class="org.apache.cloudstack.affinity.AffinityGroupServiceImpl"/>
|
||||
<bean id="AffinityGroupServiceImpl" class="org.apache.cloudstack.affinity.AffinityGroupServiceImpl">
|
||||
<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
|
||||
</bean>
|
||||
<bean id="DeploymentPlanningManager" class="com.cloud.deploy.DeploymentPlanningManagerImpl">
|
||||
<property name="Planners" value="#{deploymentPlanners.Adapters}" />
|
||||
<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.server.ConfigurationServer;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupService;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupVO;
|
||||
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
|
||||
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||
|
|
@ -418,6 +419,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
DedicatedResourceDao _dedicatedDao;
|
||||
@Inject
|
||||
ConfigurationServer _configServer;
|
||||
@Inject
|
||||
AffinityGroupService _affinityGroupService;
|
||||
|
||||
protected ScheduledExecutorService _executor = null;
|
||||
protected int _expungeInterval;
|
||||
|
|
@ -2494,7 +2497,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
for (Long affinityGroupId : affinityGroupIdList) {
|
||||
AffinityGroupVO ag = _affinityGroupDao.findById(affinityGroupId);
|
||||
if (ag == null) {
|
||||
throw new InvalidParameterValueException("Unable to find affinity group by id " + affinityGroupId);
|
||||
throw new InvalidParameterValueException("Unable to find affinity group " + ag);
|
||||
} else if (!_affinityGroupService.isAffinityGroupProcessorAvailable(ag.getType())) {
|
||||
throw new InvalidParameterValueException("Affinity group type is not supported for group: " + ag
|
||||
+ " ,type: " + ag.getType() + " , Please try again after removing the affinity group");
|
||||
} else {
|
||||
// verify permissions
|
||||
_accountMgr.checkAccess(caller, null, true, owner, ag);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,16 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
|
|||
@Inject
|
||||
private UserVmDao _userVmDao;
|
||||
|
||||
protected List<AffinityGroupProcessor> _affinityProcessors;
|
||||
|
||||
public List<AffinityGroupProcessor> getAffinityGroupProcessors() {
|
||||
return _affinityProcessors;
|
||||
}
|
||||
|
||||
public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) {
|
||||
this._affinityProcessors = affinityProcessors;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_AFFINITY_GROUP_CREATE, eventDescription = "Creating Affinity Group", create = true)
|
||||
public AffinityGroup createAffinityGroup(String account, Long domainId, String affinityGroupName,
|
||||
|
|
@ -359,4 +369,14 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAffinityGroupProcessorAvailable(String affinityGroupType) {
|
||||
for (AffinityGroupProcessor processor : _affinityProcessors) {
|
||||
if (affinityGroupType != null && affinityGroupType.equals(processor.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue