mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6810: Fix storage migration of a vm with volume on local was failing. When a plan
with hostid included was passed to the local storage pool allocator, it returned all the local storage pools in the cluster, instead of just the local pool on the given host in the plan. This was happening the search at a host level was happening only for data disk. Fixed this. Additionally, the query to list the storage pools on a host was failing if the pool did have tags. Fixed the query too. CLOUDSTACK-6802: Fix for not being able to attach data disk on local. This issue gets fixed with the above issue too. The query to list pools on a host was failing if there were no tags on the storage pool.
This commit is contained in:
parent
76c71c7bc1
commit
f5ce280da3
|
|
@ -24,7 +24,6 @@ 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;
|
||||
|
|
@ -55,9 +54,6 @@ 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;
|
||||
|
|
@ -120,26 +116,6 @@ 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();
|
||||
|
|
@ -345,11 +321,29 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
|
||||
@Override
|
||||
public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags) {
|
||||
SearchBuilder<StoragePoolVO> hostSearch = createSearchBuilder();
|
||||
SearchBuilder<StoragePoolHostVO> hostPoolSearch = _hostDao.createSearchBuilder();
|
||||
SearchBuilder<StoragePoolDetailVO> tagPoolSearch = _detailsDao.createSearchBuilder();;
|
||||
|
||||
SearchCriteria<StoragePoolVO> sc = HostSearch.create();
|
||||
// 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);
|
||||
|
||||
if (!(tags == null || tags.length == 0 )) {
|
||||
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);
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ 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.Volume;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
|
|
@ -73,9 +72,8 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator {
|
|||
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
|
||||
|
||||
// data disk and host identified from deploying vm (attach volume case)
|
||||
if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) {
|
||||
List<StoragePoolVO> hostTagsPools = null;
|
||||
hostTagsPools =_storagePoolDao.findLocalStoragePoolsByHostAndTags(plan.getHostId(), dskCh.getTags());
|
||||
if (plan.getHostId() != null) {
|
||||
List<StoragePoolVO> hostTagsPools = _storagePoolDao.findLocalStoragePoolsByHostAndTags(plan.getHostId(), dskCh.getTags());
|
||||
for (StoragePoolVO pool : hostTagsPools) {
|
||||
if (pool != null && pool.isLocal()) {
|
||||
StoragePool storagePool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue