You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/07/17 00:49:30 UTC
git commit: updated refs/heads/master to ee664a1
Updated Branches:
refs/heads/master 9f019ec7c -> ee664a1ca
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
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ee664a1c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ee664a1c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ee664a1c
Branch: refs/heads/master
Commit: ee664a1cac9030f1e9902a6d9a574788ae34f9a6
Parents: 9f019ec
Author: Prachi Damle <pr...@cloud.com>
Authored: Tue Jul 16 15:21:14 2013 -0700
Committer: Prachi Damle <pr...@cloud.com>
Committed: Tue Jul 16 15:48:07 2013 -0700
----------------------------------------------------------------------
.../affinity/AffinityGroupService.java | 2 ++
client/tomcatconf/applicationContext.xml.in | 4 +++-
server/src/com/cloud/vm/UserVmManagerImpl.java | 8 +++++++-
.../affinity/AffinityGroupServiceImpl.java | 20 ++++++++++++++++++++
4 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee664a1c/api/src/org/apache/cloudstack/affinity/AffinityGroupService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/affinity/AffinityGroupService.java b/api/src/org/apache/cloudstack/affinity/AffinityGroupService.java
index 7423c48..1b30e58 100644
--- a/api/src/org/apache/cloudstack/affinity/AffinityGroupService.java
+++ b/api/src/org/apache/cloudstack/affinity/AffinityGroupService.java
@@ -73,4 +73,6 @@ public interface AffinityGroupService {
UserVm updateVMAffinityGroups(Long vmId, List<Long> affinityGroupIds);
+ boolean isAffinityGroupProcessorAvailable(String affinityGroupType);
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee664a1c/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 0f3d328..fa52d3f 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -899,7 +899,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}" />
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee664a1c/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index bd7a791..461176e 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -37,6 +37,7 @@ import org.apache.log4j.Logger;
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;
@@ -414,6 +415,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
DedicatedResourceDao _dedicatedDao;
@Inject
ConfigurationServer _configServer;
+ @Inject
+ AffinityGroupService _affinityGroupService;
protected ScheduledExecutorService _executor = null;
protected int _expungeInterval;
@@ -2488,7 +2491,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);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee664a1c/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
index 287e622..e1fba1d 100644
--- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
+++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
@@ -82,6 +82,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,
@@ -361,4 +371,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;
+ }
+
}