cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject git commit: updated refs/heads/4.4 to 406c289
Date Wed, 16 Apr 2014 11:27:55 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 eee8a04da -> 406c289d1


CLOUDSTACK-6151: Local data disk with tag goes to the wrong local storage pool

Signed-off-by: Koushik Das <koushik@apache.org>


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

Branch: refs/heads/4.4
Commit: 406c289d15fb25501c6e9d9ce1a73725c34b7aea
Parents: eee8a04
Author: Saksham Srivastava <saksham.srivastava@citrix.com>
Authored: Wed Apr 16 14:39:56 2014 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Wed Apr 16 16:20:04 2014 +0530

----------------------------------------------------------------------
 .../spring-engine-schema-core-daos-context.xml  |  2 +-
 .../datastore/db/PrimaryDataStoreDao.java       |  2 +
 .../datastore/db/PrimaryDataStoreDaoImpl.java   | 46 ++++++++++++++++++++
 .../allocator/LocalStoragePoolAllocator.java    | 12 +++--
 server/test/resources/createNetworkOffering.xml |  2 +
 5 files changed, 56 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/406c289d/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
----------------------------------------------------------------------
diff --git a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
index 489b37d..bd9226e 100644
--- a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
+++ b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
@@ -221,6 +221,7 @@
   <bean id="PortableIpRangeDaoImpl" class="org.apache.cloudstack.region.PortableIpRangeDaoImpl"
/>
   <bean id="portForwardingRulesDaoImpl" class="com.cloud.network.rules.dao.PortForwardingRulesDaoImpl"
/>
   <bean id="portProfileDaoImpl" class="com.cloud.network.dao.PortProfileDaoImpl" />
+  <bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl"
/>
   <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl"
/>
   <bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl"
/>
   <bean id="privateIpDaoImpl" class="com.cloud.network.vpc.dao.PrivateIpDaoImpl" />
@@ -258,7 +259,6 @@
   <bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl"
/>
   <bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl"
/>
   <bean id="storagePoolDetailsDaoImpl" class="com.cloud.storage.dao.StoragePoolDetailsDaoImpl"
/>
-  <bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl"
/>
   <bean id="storagePoolJoinDaoImpl" class="com.cloud.api.query.dao.StoragePoolJoinDaoImpl"
/>
   <bean id="storagePoolWorkDaoImpl" class="com.cloud.storage.dao.StoragePoolWorkDaoImpl"
/>
   <bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl"
/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/406c289d/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
index 2c4369d..a976bfb 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -113,4 +113,6 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO,
Long> {
     List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
 
     List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType
hypervisorType);
+
+    List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/406c289d/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
index 57afa16..7e558f8 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.PostConstruct;
 import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
@@ -31,10 +32,13 @@ import javax.naming.ConfigurationException;
 import com.cloud.host.Status;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePoolHostVO;
 import com.cloud.storage.StoragePoolStatus;
+import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.JoinBuilder;
 import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -51,9 +55,14 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
     protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
     protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
     protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
+    protected SearchBuilder<StoragePoolVO> HostSearch;
+    protected SearchBuilder<StoragePoolHostVO> HostPoolSearch;
+    protected SearchBuilder<StoragePoolDetailVO> TagPoolSearch;
 
     @Inject
     protected StoragePoolDetailsDao _detailsDao;
+    @Inject
+    protected StoragePoolHostDao _hostDao;
 
     private final String DetailsSqlPrefix =
         "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id
= storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status
= 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id
is null) and storage_pool.scope = ? and (";
@@ -111,6 +120,26 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
 
     }
 
+    @PostConstruct
+    void init() {
+        HostSearch = createSearchBuilder();
+        TagPoolSearch = _detailsDao.createSearchBuilder();
+        HostPoolSearch = _hostDao.createSearchBuilder();
+        // Search for pools on the host
+        HostPoolSearch.and("hostId", HostPoolSearch.entity().getHostId(), Op.EQ);
+        // Set criteria for pools
+        HostSearch.and("scope", HostSearch.entity().getScope(), Op.EQ);
+        HostSearch.and("removed", HostSearch.entity().getRemoved(), Op.NULL);
+        HostSearch.and("status", HostSearch.entity().getStatus(), Op.EQ);
+        HostSearch.join("hostJoin", HostPoolSearch, HostSearch.entity().getId(), HostPoolSearch.entity().getPoolId(),
JoinBuilder.JoinType.INNER);
+        // Set criteria for tags
+        TagPoolSearch.and("name", TagPoolSearch.entity().getName(), Op.EQ);
+        TagPoolSearch.and("value", TagPoolSearch.entity().getValue(), Op.EQ);
+
+        HostSearch.join("tagJoin", TagPoolSearch, HostSearch.entity().getId(), TagPoolSearch.entity().getResourceId(),
JoinBuilder.JoinType.INNER);
+        HostSearch.done();
+    }
+
     @Override
     public List<StoragePoolVO> findPoolByName(String name) {
         SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
@@ -315,6 +344,23 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
     }
 
     @Override
+    public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[]
tags) {
+
+        SearchCriteria<StoragePoolVO> sc = HostSearch.create();
+        sc.setJoinParameters("hostJoin", "hostId", hostId );
+        sc.setParameters("scope", ScopeType.HOST.toString());
+        sc.setParameters("status", Status.Up.toString());
+        if (!(tags == null || tags.length == 0 )) {
+            Map<String, String> details = tagsToDetails(tags);
+            for (Map.Entry<String, String> detail : details.entrySet()) {
+                sc.setJoinParameters("tagJoin","name", detail.getKey());
+                sc.setJoinParameters("tagJoin", "value", detail.getValue());
+            }
+        }
+        return listBy(sc);
+    }
+
+    @Override
     public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags)
{
         List<StoragePoolVO> storagePools = null;
         if (tags == null || tags.length == 0) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/406c289d/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
index 678b2a3..e988327 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
@@ -25,19 +25,17 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolHostVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.utils.NumbersUtil;
@@ -76,9 +74,9 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator
{
 
         // data disk and host identified from deploying vm (attach volume case)
         if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null)
{
-            List<StoragePoolHostVO> hostPools = _poolHostDao.listByHostId(plan.getHostId());
-            for (StoragePoolHostVO hostPool : hostPools) {
-                StoragePoolVO pool = _storagePoolDao.findById(hostPool.getPoolId());
+            List<StoragePoolVO> hostTagsPools = null;
+            hostTagsPools =_storagePoolDao.findLocalStoragePoolsByHostAndTags(plan.getHostId(),
dskCh.getTags());
+            for (StoragePoolVO pool : hostTagsPools) {
                 if (pool != null && pool.isLocal()) {
                     StoragePool storagePool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
                     if (filter(avoid, storagePool, dskCh, plan)) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/406c289d/server/test/resources/createNetworkOffering.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/createNetworkOffering.xml b/server/test/resources/createNetworkOffering.xml
index 6ae1978..887a8af 100644
--- a/server/test/resources/createNetworkOffering.xml
+++ b/server/test/resources/createNetworkOffering.xml
@@ -48,4 +48,6 @@
     <bean id="vGPUTypesDaoImpl" class="com.cloud.gpu.dao.VGPUTypesDaoImpl" />
     <bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
     <bean id="usageEventDetailsDaoImpl" class="com.cloud.event.dao.UsageEventDetailsDaoImpl"
/>
+    <bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl"
/>
+    <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl"
/>
 </beans>


Mime
View raw message