@Override public List<StoragePoolVO> listByStatus(StoragePoolStatus status) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("status", status); return listBy(sc); }
@Override public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) { List<StoragePoolVO> storagePools = null; if (tags == null || tags.length == 0) { storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST); } else { String sqlValues = getSqlValuesFromStorageTags(tags); storagePools = findPoolsByDetailsOrTagsInternal(dcId, podId, clusterId, ScopeType.HOST, sqlValues, ValueType.TAGS, tags.length); } return storagePools; }
@Override public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("uuid", uuid); return listBy(sc); }
@Override public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags) { List<StoragePoolVO> storagePools = null; if (tags == null || tags.length == 0) { storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER); } else { String sqlValues = getSqlValuesFromStorageTags(tags); storagePools = findPoolsByDetailsOrTagsInternal(dcId, podId, clusterId, ScopeType.CLUSTER, sqlValues, ValueType.TAGS, tags.length); } return storagePools; }
@Override public List<StoragePoolVO> findPoolsByProvider(String provider) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("storage_provider_name", provider); return listBy(sc); }
@Override public List<StoragePoolVO> listByDataCenterId(long datacenterId) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("datacenterId", datacenterId); return listBy(sc); }
@Override public List<StoragePoolVO> listPoolsByCluster(long clusterId) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("clusterId", clusterId); return listBy(sc); }
@Override public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("status", status); sc.setParameters("datacenterId", dcId); return listBy(sc); }
@Override public List<StoragePoolVO> listPoolByHostPath(String host, String path) { SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("hostAddress", host); sc.setParameters("path", path); return listBy(sc); }
@Override public List<StoragePoolVO> listLocalStoragePoolByPath(long datacenterId, String path) { SearchCriteria<StoragePoolVO> sc = DcLocalStorageSearch.create(); sc.setParameters("path", path); sc.setParameters("datacenterId", datacenterId); sc.setParameters("scope", ScopeType.HOST); return listBy(sc); }
@Override public List<StoragePoolVO> findDisabledPoolsByScope(long dcId, Long podId, Long clusterId, ScopeType scope) { List<StoragePoolVO> storagePools = null; SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); sc.setParameters("status", StoragePoolStatus.Disabled); sc.setParameters("scope", scope); if (scope == ScopeType.ZONE) { sc.setParameters("datacenterId", dcId); storagePools = listBy(sc); } else if ((scope == ScopeType.CLUSTER || scope == ScopeType.HOST) && podId != null && clusterId != null) { sc.setParameters("datacenterId", dcId); sc.setParameters("podId", podId); sc.setParameters("clusterId", clusterId); storagePools = listBy(sc); } return storagePools; }
@Override public List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope) { SearchCriteria<StoragePoolVO> sc = null; if (clusterId != null) { sc = DcPodSearch.create(); sc.setParameters("cluster", clusterId); } else { sc = DcPodAnyClusterSearch.create(); } sc.setParameters("datacenterId", datacenterId); sc.setParameters("podId", podId); sc.setParameters("status", Status.Up); if (scope != null) { sc.setParameters("scope", scope); } return listBy(sc); }
@Override public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags) { SearchBuilder<StoragePoolVO> hostSearch = createSearchBuilder(); SearchBuilder<StoragePoolHostVO> hostPoolSearch = _hostDao.createSearchBuilder(); SearchBuilder<StoragePoolTagVO> tagPoolSearch = _tagsDao.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); if (!(tags == null || tags.length == 0)) { tagPoolSearch.and("tag", tagPoolSearch.entity().getTag(), Op.EQ); hostSearch.join("tagJoin", tagPoolSearch, hostSearch.entity().getId(), tagPoolSearch.entity().getPoolId(), 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)) { for (String tag : tags) { sc.setJoinParameters("tagJoin", "tag", tag); } } return listBy(sc); }