You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/10/29 20:11:54 UTC

[1/2] git commit: updated refs/heads/master to 093cccf

Repository: cloudstack
Updated Branches:
  refs/heads/master d8f9c235e -> 093cccfce


CLOUDSTACK-8962: Dedicated cluster is used for virtual routers that belong to non-dedicated account

Earlier the deployment planner was not handling the case of virtual routers.(In Explicit Dedication)
It was only handling for all instance VMs/user VMs.
Added code for checking the case of Virtual Routers.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/adcd23d1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/adcd23d1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/adcd23d1

Branch: refs/heads/master
Commit: adcd23d15aec9c5cee37d8b1ec031eb57660d605
Parents: e7638c0
Author: Nitin Kumar Maharana <ni...@gmail.com>
Authored: Thu Oct 22 12:57:56 2015 +0530
Committer: Nitin Kumar Maharana <ni...@gmail.com>
Committed: Thu Oct 22 12:57:56 2015 +0530

----------------------------------------------------------------------
 .../deploy/DeploymentPlanningManagerImpl.java   | 112 ++++++++++++++++---
 .../vm/DeploymentPlanningManagerImplTest.java   |   6 +
 2 files changed, 105 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adcd23d1/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index bfd6af4..8b9be25 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -38,8 +38,10 @@ import org.apache.cloudstack.affinity.AffinityGroupProcessor;
 import org.apache.cloudstack.affinity.AffinityGroupService;
 import org.apache.cloudstack.affinity.AffinityGroupVMMapVO;
 import org.apache.cloudstack.affinity.AffinityGroupVO;
+import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
 import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
+import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao;
 import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
 import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@@ -147,6 +149,8 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
     @Inject
     protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
     @Inject
+    protected AffinityGroupDomainMapDao _affinityGroupDomainMapDao;
+    @Inject
     AffinityGroupService _affinityGroupService;
     @Inject
     DataCenterDao _dcDao;
@@ -258,7 +262,7 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
             }
         }
 
-        if (vm.getType() == VirtualMachine.Type.User) {
+        if (vm.getType() == VirtualMachine.Type.User || vm.getType() == VirtualMachine.Type.DomainRouter) {
             checkForNonDedicatedResources(vmProfile, dc, avoids);
         }
         if (s_logger.isDebugEnabled()) {
@@ -547,7 +551,7 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
         boolean isExplicit = false;
         VirtualMachine vm = vmProfile.getVirtualMachine();
 
-        // check if zone is dedicated. if yes check if vm owner has acess to it.
+        // check if zone is dedicated. if yes check if vm owner has access to it.
         DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(dc.getId());
         if (dedicatedZone != null && !_accountMgr.isRootAdmin(vmProfile.getOwner().getId())) {
             long accountDomainId = vmProfile.getOwner().getDomainId();
@@ -582,22 +586,104 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
             isExplicit = true;
         }
 
-        if (!isExplicit) {
+        List<Long> allPodsInDc = _podDao.listAllPods(dc.getId());
+        List<Long> allDedicatedPods = _dedicatedDao.listAllPods();
+        allPodsInDc.retainAll(allDedicatedPods);
+
+        List<Long> allClustersInDc = _clusterDao.listAllCusters(dc.getId());
+        List<Long> allDedicatedClusters = _dedicatedDao.listAllClusters();
+        allClustersInDc.retainAll(allDedicatedClusters);
+
+        List<Long> allHostsInDc = _hostDao.listAllHosts(dc.getId());
+        List<Long> allDedicatedHosts = _dedicatedDao.listAllHosts();
+        allHostsInDc.retainAll(allDedicatedHosts);
+
+        //Only when the type is instance VM and not explicitly dedicated.
+        if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
             //add explicitly dedicated resources in avoidList
 
-            List<Long> allPodsInDc = _podDao.listAllPods(dc.getId());
-            List<Long> allDedicatedPods = _dedicatedDao.listAllPods();
-            allPodsInDc.retainAll(allDedicatedPods);
             avoids.addPodList(allPodsInDc);
-
-            List<Long> allClustersInDc = _clusterDao.listAllCusters(dc.getId());
-            List<Long> allDedicatedClusters = _dedicatedDao.listAllClusters();
-            allClustersInDc.retainAll(allDedicatedClusters);
             avoids.addClusterList(allClustersInDc);
+            avoids.addHostList(allHostsInDc);
+        }
+
+        //Handle the Virtual Router Case
+        //No need to check the isExplicit. As both the cases are handled.
+        if (vm.getType() == VirtualMachine.Type.DomainRouter) {
+            long vmAccountId = vm.getAccountId();
+            long vmDomainId = vm.getDomainId();
+
+            //Lists all explicitly dedicated resources from vm account ID or domain ID.
+            List<Long> allPodsFromDedicatedID = new ArrayList<Long>();
+            List<Long> allClustersFromDedicatedID = new ArrayList<Long>();
+            List<Long> allHostsFromDedicatedID = new ArrayList<Long>();
+
+            //Whether the dedicated resources belong to Domain or not. If not, it may belongs to Account or no dedication.
+            List<AffinityGroupDomainMapVO> domainGroupMappings = _affinityGroupDomainMapDao.listByDomain(vmDomainId);
+
+            //For temporary storage and indexing.
+            List<DedicatedResourceVO> tempStorage;
+
+            if (domainGroupMappings == null || domainGroupMappings.isEmpty()) {
+                //The dedicated resource belongs to VM Account ID.
+
+                tempStorage = _dedicatedDao.searchDedicatedPods(null, vmDomainId, vmAccountId, null).first();
+
+                for(DedicatedResourceVO vo : tempStorage) {
+                    allPodsFromDedicatedID.add(vo.getPodId());
+                }
+
+                tempStorage.clear();
+                tempStorage = _dedicatedDao.searchDedicatedClusters(null, vmDomainId, vmAccountId, null).first();
+
+                for(DedicatedResourceVO vo : tempStorage) {
+                    allClustersFromDedicatedID.add(vo.getClusterId());
+                }
 
-            List<Long> allHostsInDc = _hostDao.listAllHosts(dc.getId());
-            List<Long> allDedicatedHosts = _dedicatedDao.listAllHosts();
-            allHostsInDc.retainAll(allDedicatedHosts);
+                tempStorage.clear();
+                tempStorage = _dedicatedDao.searchDedicatedHosts(null, vmDomainId, vmAccountId, null).first();
+
+                for(DedicatedResourceVO vo : tempStorage) {
+                    allHostsFromDedicatedID.add(vo.getHostId());
+                }
+
+                //Remove the dedicated ones from main list
+                allPodsInDc.removeAll(allPodsFromDedicatedID);
+                allClustersInDc.removeAll(allClustersFromDedicatedID);
+                allHostsInDc.removeAll(allHostsFromDedicatedID);
+            }
+            else {
+                //The dedicated resource belongs to VM Domain ID or No dedication.
+
+                tempStorage = _dedicatedDao.searchDedicatedPods(null, vmDomainId, null, null).first();
+
+                for(DedicatedResourceVO vo : tempStorage) {
+                    allPodsFromDedicatedID.add(vo.getPodId());
+                }
+
+                tempStorage.clear();
+                tempStorage = _dedicatedDao.searchDedicatedClusters(null, vmDomainId, null, null).first();
+
+                for(DedicatedResourceVO vo : tempStorage) {
+                    allClustersFromDedicatedID.add(vo.getClusterId());
+                }
+
+                tempStorage.clear();
+                tempStorage = _dedicatedDao.searchDedicatedHosts(null, vmDomainId, null, null).first();
+
+                for(DedicatedResourceVO vo : tempStorage) {
+                    allHostsFromDedicatedID.add(vo.getHostId());
+                }
+
+                //Remove the dedicated ones from main list
+                allPodsInDc.removeAll(allPodsFromDedicatedID);
+                allClustersInDc.removeAll(allClustersFromDedicatedID);
+                allHostsInDc.removeAll(allHostsFromDedicatedID);
+            }
+
+            //Add in avoid list or no addition if no dedication
+            avoids.addPodList(allPodsInDc);
+            avoids.addClusterList(allClustersInDc);
             avoids.addHostList(allHostsInDc);
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adcd23d1/server/test/com/cloud/vm/DeploymentPlanningManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/DeploymentPlanningManagerImplTest.java b/server/test/com/cloud/vm/DeploymentPlanningManagerImplTest.java
index b9e2831..72960e3 100644
--- a/server/test/com/cloud/vm/DeploymentPlanningManagerImplTest.java
+++ b/server/test/com/cloud/vm/DeploymentPlanningManagerImplTest.java
@@ -25,6 +25,7 @@ import java.util.List;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -262,6 +263,11 @@ public class DeploymentPlanningManagerImplTest {
         }
 
         @Bean
+        public AffinityGroupDomainMapDao affinityGroupDomainMapDao() {
+            return Mockito.mock(AffinityGroupDomainMapDao.class);
+        }
+
+        @Bean
         public DataStoreManager cataStoreManager() {
             return Mockito.mock(DataStoreManager.class);
         }


[2/2] git commit: updated refs/heads/master to 093cccf

Posted by re...@apache.org.
Merge pull request #945 from nitin-maharana/CloudStack-Nitin11

CLOUDSTACK-8962: Dedicated cluster is used for virtual routers that belong to non-dedicated account
Earlier the deployment planner was not handling the case of virtual routers.(In Explicit Dedication)
It was only handling for all instance VMs/user VMs.
Added code for checking the case of Virtual Routers.

* pr/945:
  CLOUDSTACK-8962: Dedicated cluster is used for virtual routers that belong to non-dedicated account

Signed-off-by: Remi Bergsma <gi...@remi.nl>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/093cccfc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/093cccfc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/093cccfc

Branch: refs/heads/master
Commit: 093cccfce293531560fabe532c6648d92f84b7a3
Parents: d8f9c23 adcd23d
Author: Remi Bergsma <gi...@remi.nl>
Authored: Thu Oct 29 20:10:31 2015 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Thu Oct 29 20:10:31 2015 +0100

----------------------------------------------------------------------
 .../deploy/DeploymentPlanningManagerImpl.java   | 112 ++++++++++++++++---
 .../vm/DeploymentPlanningManagerImplTest.java   |   6 +
 2 files changed, 105 insertions(+), 13 deletions(-)
----------------------------------------------------------------------