use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class StoragePoolHostDaoImpl method listByHostStatus.
@Override
public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
String sql = HOST_FOR_POOL_SEARCH;
List<StoragePoolHostVO> result = new ArrayList<StoragePoolHostVO>();
try (PreparedStatement pstmt = txn.prepareStatement(sql)) {
pstmt.setLong(1, poolId);
pstmt.setString(2, hostStatus.toString());
try (ResultSet rs = pstmt.executeQuery()) {
while (rs.next()) {
// result.add(toEntityBean(rs, false)); TODO: this is buggy in
// GenericDaoBase for hand constructed queries
// ID column
long id = rs.getLong(1);
result.add(findById(id));
}
} catch (SQLException e) {
s_logger.warn("listByHostStatus:Exception: ", e);
}
} catch (Exception e) {
s_logger.warn("listByHostStatus:Exception: ", e);
}
return result;
}
use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class PrimaryDataStoreHelper method deletePrimaryDataStore.
public boolean deletePrimaryDataStore(DataStore store) {
List<StoragePoolHostVO> hostPoolRecords = this.storagePoolHostDao.listByPoolId(store.getId());
StoragePoolVO poolVO = this.dataStoreDao.findById(store.getId());
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
for (StoragePoolHostVO host : hostPoolRecords) {
storagePoolHostDao.deleteStoragePoolHostDetails(host.getHostId(), host.getPoolId());
}
poolVO.setUuid(null);
this.dataStoreDao.update(poolVO.getId(), poolVO);
dataStoreDao.remove(poolVO.getId());
dataStoreDao.deletePoolTags(poolVO.getId());
annotationDao.removeByEntityType(AnnotationService.EntityType.PRIMARY_STORAGE.name(), poolVO.getUuid());
deletePoolStats(poolVO.getId());
// Delete op_host_capacity entries
this._capacityDao.removeBy(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, null, null, null, poolVO.getId());
txn.commit();
s_logger.debug("Storage pool id=" + poolVO.getId() + " is removed successfully");
return true;
}
use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class PrimaryDataStoreImpl method getScope.
@Override
public Scope getScope() {
StoragePoolVO vo = dataStoreDao.findById(pdsv.getId());
if (vo.getScope() == ScopeType.CLUSTER) {
return new ClusterScope(vo.getClusterId(), vo.getPodId(), vo.getDataCenterId());
} else if (vo.getScope() == ScopeType.ZONE) {
return new ZoneScope(vo.getDataCenterId());
} else if (vo.getScope() == ScopeType.HOST) {
List<StoragePoolHostVO> poolHosts = poolHostDao.listByPoolId(vo.getId());
if (poolHosts.size() > 0) {
return new HostScope(poolHosts.get(0).getHostId(), vo.getClusterId(), vo.getDataCenterId());
}
s_logger.debug("can't find a local storage in pool host table: " + vo.getId());
}
return null;
}
Aggregations