diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java index 4d845252f57..d436762c25a 100644 --- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java +++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java @@ -22,6 +22,7 @@ import java.util.Map; import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType; +import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.StoragePoolStatus; import com.cloud.utils.db.GenericDao; /** @@ -109,4 +110,6 @@ public interface PrimaryDataStoreDao extends GenericDao { Long clusterId, String[] tags); List findZoneWideStoragePoolsByTags(long dcId, String[] tags); + + List findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType); } diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index 7fcddf1940f..d461d58ddfc 100644 --- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -32,6 +32,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType; import org.springframework.stereotype.Component; import com.cloud.host.Status; +import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.StoragePoolStatus; @@ -427,4 +428,14 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase return listBy(sc); } + + @Override + public List findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) { + SearchCriteriaService sc = SearchCriteria2.create(StoragePoolVO.class); + sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId); + sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up); + sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE); + sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType); + return sc.list(); + } } diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java index 55b2314f0fd..0262f65af0a 100644 --- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java +++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java @@ -31,6 +31,7 @@ import javax.persistence.TemporalType; import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType; +import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; @@ -102,6 +103,10 @@ public class StoragePoolVO implements StoragePool{ @Enumerated(value = EnumType.STRING) private ScopeType scope; + @Column(name = "hypervisor") + @Enumerated(value = EnumType.STRING) + private HypervisorType hypervisor; + public long getId() { return id; } @@ -276,6 +281,14 @@ public class StoragePoolVO implements StoragePool{ return this.scope; } + public HypervisorType getHypervisor() { + return hypervisor; + } + + public void setHypervisor(HypervisorType hypervisor) { + this.hypervisor = hypervisor; + } + @Override public boolean equals(Object obj) { if (!(obj instanceof StoragePoolVO) || obj == null) { diff --git a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java index e401f4474d7..e27697832b7 100644 --- a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java @@ -85,6 +85,9 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase