[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-19 Thread anshul1886
GitHub user anshul1886 reopened a pull request:

https://github.com/apache/cloudstack/pull/1853

CLOUDSTACK-9696: Fixed Virtual Router deployment failing if there are…

… no shared resources available

and has access to resources through parent domain heirarachy

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/anshul1886/cloudstack-1 CLOUDSTACK-9696

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1853.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1853


commit 0024dfc62266cc52380b7977860f667414d36e42
Author: Anshul Gangwar 
Date:   2016-12-22T06:17:03Z

CLOUDSTACK-9696: Fixed Virtual Router deployment failing if there are no 
shared resources available
and has access to resources through parent domain heirarachy




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-19 Thread anshul1886
Github user anshul1886 closed the pull request at:

https://github.com/apache/cloudstack/pull/1853


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-17 Thread anshul1886
Github user anshul1886 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106632802
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
+List allPodsInDc = _podDao.listAllPods(dc.getId());
+List allDedicatedPods = _dedicatedDao.listAllPods();
+allPodsInDc.retainAll(allDedicatedPods);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allClustersFromDedicatedID.add(vo.getClusterId());
-}
+List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
+List allDedicatedClusters = 
_dedicatedDao.listAllClusters();
+allClustersInDc.retainAll(allDedicatedClusters);
 
-tempStorage.clear();
-tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, vmAccountId, null).first();
+List allHostsInDc = _hostDao.listAllHosts(dc.getId());
+List allDedicatedHosts = _dedicatedDao.listAllHosts();
+allHostsInDc.retainAll(allDedicatedHosts);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allHostsFromDedicatedID.add(vo.getHostId());
-}
+//Only when the type is instance VM and not explicitly 
dedicated.
+if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
+//add explicitly dedicated resources in avoidList
 
-//Remove the dedicated ones from main list
-allPodsInDc.removeAll(allPodsFromDedicatedID);
-allClustersInDc.removeAll(allClustersFromDedicatedID);
-allHostsInDc.removeAll(allHostsFromDedicatedID);
+avoids.addPodList(allPodsInDc);
+avoids.addClusterList(allClustersInDc);
+avoids.addHostList(allHostsInDc);
 }
-else {
-//The dedicated resource belongs to VM 

[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-17 Thread anshul1886
Github user anshul1886 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106632584
  
--- Diff: server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java ---
@@ -312,6 +317,65 @@ public DedicatedResourceVO findByHostId(Long hostId) {
 }
 
 @Override
+public List listAvailableResources(Long 
accountId, Long... domains) {
--- End diff --

@koushik-das Made the changes using SearchBuilder class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-17 Thread koushik-das
Github user koushik-das commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106589966
  
--- Diff: server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java ---
@@ -312,6 +317,65 @@ public DedicatedResourceVO findByHostId(Long hostId) {
 }
 
 @Override
+public List listAvailableResources(Long 
accountId, Long... domains) {
--- End diff --

@anshul1886 Check out SearchBuilder class, it has methods like or(), op(), 
cp() which can be used to construct the query. Also the same field can be used 
in multiple places, search for reference to or(), op() etc. elsewhere in the 
code and you will find how to use them. One such place is QueryManagerImpl.java


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-17 Thread koushik-das
Github user koushik-das commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106590720
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
+List allPodsInDc = _podDao.listAllPods(dc.getId());
+List allDedicatedPods = _dedicatedDao.listAllPods();
+allPodsInDc.retainAll(allDedicatedPods);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allClustersFromDedicatedID.add(vo.getClusterId());
-}
+List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
+List allDedicatedClusters = 
_dedicatedDao.listAllClusters();
+allClustersInDc.retainAll(allDedicatedClusters);
 
-tempStorage.clear();
-tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, vmAccountId, null).first();
+List allHostsInDc = _hostDao.listAllHosts(dc.getId());
+List allDedicatedHosts = _dedicatedDao.listAllHosts();
+allHostsInDc.retainAll(allDedicatedHosts);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allHostsFromDedicatedID.add(vo.getHostId());
-}
+//Only when the type is instance VM and not explicitly 
dedicated.
+if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
+//add explicitly dedicated resources in avoidList
 
-//Remove the dedicated ones from main list
-allPodsInDc.removeAll(allPodsFromDedicatedID);
-allClustersInDc.removeAll(allClustersFromDedicatedID);
-allHostsInDc.removeAll(allHostsFromDedicatedID);
+avoids.addPodList(allPodsInDc);
+avoids.addClusterList(allClustersInDc);
+avoids.addHostList(allHostsInDc);
 }
-else {
-//The dedicated resource belongs to VM 

[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-17 Thread koushik-das
Github user koushik-das commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106591079
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
--- End diff --

@anshul1886 Got it


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-16 Thread anshul1886
Github user anshul1886 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106381321
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
+List allPodsInDc = _podDao.listAllPods(dc.getId());
+List allDedicatedPods = _dedicatedDao.listAllPods();
+allPodsInDc.retainAll(allDedicatedPods);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allClustersFromDedicatedID.add(vo.getClusterId());
-}
+List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
+List allDedicatedClusters = 
_dedicatedDao.listAllClusters();
+allClustersInDc.retainAll(allDedicatedClusters);
 
-tempStorage.clear();
-tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, vmAccountId, null).first();
+List allHostsInDc = _hostDao.listAllHosts(dc.getId());
+List allDedicatedHosts = _dedicatedDao.listAllHosts();
+allHostsInDc.retainAll(allDedicatedHosts);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allHostsFromDedicatedID.add(vo.getHostId());
-}
+//Only when the type is instance VM and not explicitly 
dedicated.
+if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
+//add explicitly dedicated resources in avoidList
 
-//Remove the dedicated ones from main list
-allPodsInDc.removeAll(allPodsFromDedicatedID);
-allClustersInDc.removeAll(allClustersFromDedicatedID);
-allHostsInDc.removeAll(allHostsFromDedicatedID);
+avoids.addPodList(allPodsInDc);
+avoids.addClusterList(allClustersInDc);
+avoids.addHostList(allHostsInDc);
 }
-else {
-//The dedicated resource belongs to VM 

[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-16 Thread anshul1886
Github user anshul1886 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106380082
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
--- End diff --

@koushik-das Here additional isExplicit check is needed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-16 Thread anshul1886
Github user anshul1886 commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106378310
  
--- Diff: server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java ---
@@ -312,6 +317,65 @@ public DedicatedResourceVO findByHostId(Long hostId) {
 }
 
 @Override
+public List listAvailableResources(Long 
accountId, Long... domains) {
--- End diff --

@koushik-das Could not find a way to write the conditional statement so 
went with this way. Here account_id in involved in two places in condition.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-15 Thread koushik-das
Github user koushik-das commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106138864
  
--- Diff: server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java ---
@@ -312,6 +317,65 @@ public DedicatedResourceVO findByHostId(Long hostId) {
 }
 
 @Override
+public List listAvailableResources(Long 
accountId, Long... domains) {
--- End diff --

Please rewrite this using the standard query builder (SearchBuilder) that 
is available and used in the other methods in this class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-15 Thread koushik-das
Github user koushik-das commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106142726
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
--- End diff --

Any reason for this check? checkForNonDedicatedResources() is anyway called 
for user and router VMs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2017-03-15 Thread koushik-das
Github user koushik-das commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1853#discussion_r106145072
  
--- Diff: server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---
@@ -584,105 +583,64 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
 isExplicit = true;
 }
 
-List allPodsInDc = _podDao.listAllPods(dc.getId());
-List allDedicatedPods = _dedicatedDao.listAllPods();
-allPodsInDc.retainAll(allDedicatedPods);
-
-List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
-List allDedicatedClusters = _dedicatedDao.listAllClusters();
-allClustersInDc.retainAll(allDedicatedClusters);
-
-List allHostsInDc = _hostDao.listAllHosts(dc.getId());
-List 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
-
-avoids.addPodList(allPodsInDc);
-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 allPodsFromDedicatedID = new ArrayList();
-List allClustersFromDedicatedID = new ArrayList();
-List allHostsFromDedicatedID = new ArrayList();
-
-//Whether the dedicated resources belong to Domain or not. If 
not, it may belongs to Account or no dedication.
-List domainGroupMappings = 
_affinityGroupDomainMapDao.listByDomain(vmDomainId);
-
-//For temporary storage and indexing.
-List 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();
+if ((vm.getType() == VirtualMachine.Type.User && !isExplicit) || 
vm.getType() == VirtualMachine.Type.DomainRouter) {
+List allPodsInDc = _podDao.listAllPods(dc.getId());
+List allDedicatedPods = _dedicatedDao.listAllPods();
+allPodsInDc.retainAll(allDedicatedPods);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allClustersFromDedicatedID.add(vo.getClusterId());
-}
+List allClustersInDc = 
_clusterDao.listAllCusters(dc.getId());
+List allDedicatedClusters = 
_dedicatedDao.listAllClusters();
+allClustersInDc.retainAll(allDedicatedClusters);
 
-tempStorage.clear();
-tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, vmAccountId, null).first();
+List allHostsInDc = _hostDao.listAllHosts(dc.getId());
+List allDedicatedHosts = _dedicatedDao.listAllHosts();
+allHostsInDc.retainAll(allDedicatedHosts);
 
-for(DedicatedResourceVO vo : tempStorage) {
-allHostsFromDedicatedID.add(vo.getHostId());
-}
+//Only when the type is instance VM and not explicitly 
dedicated.
+if (vm.getType() == VirtualMachine.Type.User && !isExplicit) {
+//add explicitly dedicated resources in avoidList
 
-//Remove the dedicated ones from main list
-allPodsInDc.removeAll(allPodsFromDedicatedID);
-allClustersInDc.removeAll(allClustersFromDedicatedID);
-allHostsInDc.removeAll(allHostsFromDedicatedID);
+avoids.addPodList(allPodsInDc);
+avoids.addClusterList(allClustersInDc);
+avoids.addHostList(allHostsInDc);
 }
-else {
-//The dedicated resource belongs to VM 

[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2016-12-22 Thread anshul1886
GitHub user anshul1886 reopened a pull request:

https://github.com/apache/cloudstack/pull/1853

CLOUDSTACK-9696: Fixed Virtual Router deployment failing if there are…

… no shared resources available

and has access to resources through parent domain heirarachy

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/anshul1886/cloudstack-1 CLOUDSTACK-9696

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1853.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1853


commit 5f6f4ef3c634bbf60f157253253b5720a7177c0d
Author: Anshul Gangwar 
Date:   2016-12-22T06:17:03Z

CLOUDSTACK-9696: Fixed Virtual Router deployment failing if there are no 
shared resources available
and has access to resources through parent domain heirarachy




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2016-12-22 Thread anshul1886
Github user anshul1886 closed the pull request at:

https://github.com/apache/cloudstack/pull/1853


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1853: CLOUDSTACK-9696: Fixed Virtual Router deploym...

2016-12-21 Thread anshul1886
GitHub user anshul1886 opened a pull request:

https://github.com/apache/cloudstack/pull/1853

CLOUDSTACK-9696: Fixed Virtual Router deployment failing if there are…

… no shared resources available

and has access to resources through parent domain heirarachy

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/anshul1886/cloudstack-1 CLOUDSTACK-9696

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1853.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1853


commit b866776708ac664a8b71380b0f62009d0a88a3b3
Author: Anshul Gangwar 
Date:   2016-12-22T06:17:03Z

CLOUDSTACK-9696: Fixed Virtual Router deployment failing if there are no 
shared resources available
and has access to resources through parent domain heirarachy




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---