@Override public void createCapacityEntry(long poolId) { StoragePoolVO storage = _storagePoolDao.findById(poolId); createCapacityEntry(storage, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, 0); }
public long getStoragePoolIdForStoragePoolUuid(String storagePoolUuid) { StoragePoolVO storagePool = storagePoolDao.findByUuid(storagePoolUuid); if (storagePool == null) { throw new CloudRuntimeException("Unable to find Volume for ID: " + storagePoolUuid); } return storagePool.getId(); }
/** * Retrieve storage pools with scope = cluster or zone matching clusterId or dataCenterId depending on their scope */ private List<StoragePoolVO> getStoragePoolsFromClusterOrZone(Long clusterId, long dataCenterId, Hypervisor.HypervisorType hypervisorType) { List<StoragePoolVO> pools = new ArrayList<>(); if (clusterId != null) { List<StoragePoolVO> clusterPools = primaryDataStoreDao.listPoolsByCluster(clusterId); pools.addAll(clusterPools); } List<StoragePoolVO> zonePools = primaryDataStoreDao.findZoneWideStoragePoolsByHypervisor(dataCenterId, hypervisorType); pools.addAll(zonePools); return pools; }
List<StoragePoolVO> disabledPools = storagePoolDao.findDisabledPoolsByScope(plan.getDataCenterId(), null, null, ScopeType.ZONE); if (disabledPools != null && !disabledPools.isEmpty()) { for (StoragePoolVO pool : disabledPools) { List<StoragePoolVO> storagePools = storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(), dskCh.getTags()); if (storagePools == null) { storagePools = new ArrayList<>(); List<StoragePoolVO> storagePoolsByHypervisor = storagePoolDao.findZoneWideStoragePoolsByHypervisor(plan.getDataCenterId(), dskCh.getHypervisorType()); storagePools.retainAll(storagePoolsByHypervisor); storagePools.addAll(anyHypervisorStoragePools); List<StoragePoolVO> allPools = storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(), null); allPools.removeAll(storagePools); for (StoragePoolVO pool : allPools) {
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()); 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; }
User user = _userDao.findById(userId); Account account = CallContext.current().getCallingAccount(); StoragePoolVO pool = primaryDataStoreDao.findById(store.getId()); try { List<StoragePoolVO> spes = null; spes = primaryDataStoreDao.listBy(pool.getDataCenterId(), null, null, ScopeType.ZONE); } else { spes = primaryDataStoreDao.listBy(pool.getDataCenterId(), pool.getPodId(), pool.getClusterId(), ScopeType.CLUSTER); primaryDataStoreDao.update(pool.getId(), pool); return true; } else { primaryDataStoreDao.update(pool.getId(), pool); List<StoragePoolVO> upPools = primaryDataStoreDao.listByStatusInZone(pool.getDataCenterId(), StoragePoolStatus.Up); boolean restart = true; if (upPools == null || upPools.size() == 0) { s_logger.error("Exception in enabling primary storage maintenance:", e); pool.setStatus(StoragePoolStatus.ErrorInMaintenance); primaryDataStoreDao.update(pool.getId(), pool); throw new CloudRuntimeException(e.getMessage());
final StoragePoolVO storagePool = _storagePoolDao.findById(poolId); if (storagePool.isLocal() && isForceDeleteStorage) { storagePool.setUuid(null); storagePool.setClusterId(null); _storagePoolDao.update(poolId, storagePool); _storagePoolDao.remove(poolId); s_logger.debug("Local storage id=" + poolId + " is removed as a part of host removal id=" + hostId);
if (mspAnswer.getLocalDatastoreName() != null && pool.isShared()) { String datastoreName = mspAnswer.getLocalDatastoreName(); List<StoragePoolVO> localStoragePools = this.primaryStoreDao.listLocalStoragePoolByPath(pool.getDataCenterId(), datastoreName); for (StoragePoolVO localStoragePool : localStoragePools) { if (datastoreName.equals(localStoragePool.getPath())) { StoragePoolVO poolVO = this.primaryStoreDao.findById(poolId); poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes()); poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes()); primaryStoreDao.update(pool.getId(), poolVO);
StoragePoolVO dataStoreVO = _storagePoolDao.findById(store.getId()); primaryDataStoreDao.expunge(primarystore.getId()); throw new CloudRuntimeException("No host up to associate a storage pool with in cluster " + primarystore.getClusterId()); primaryDataStoreDao.expunge(primarystore.getId()); throw new CloudRuntimeException("Failed to access storage pool");
@Override public CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId) { SearchCriteria<StoragePoolVO> sc = _storagePoolDao.createSearchCriteria(); List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>(); pools.add(_storagePoolDao.findById(poolId)); } else { pools = _storagePoolDao.search(sc, null);
@Override public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) { List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId()); s_logger.debug("In createPool. Attaching the pool to each of the hosts."); List<HostVO> poolHosts = new ArrayList<HostVO>(); for (HostVO host : hosts) { try { storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId()); poolHosts.add(host); } catch (Exception e) { s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e); } } if (poolHosts.isEmpty()) { s_logger.warn("No host can access storage pool " + dataStore + " in this zone."); primaryDataStoreDao.expunge(dataStore.getId()); throw new CloudRuntimeException("Failed to create storage pool as it is not accessible to hosts."); } dataStoreHelper.attachZone(dataStore, hypervisorType); return true; }
scCmd.getHypervisorType() == HypervisorType.Ovm || scCmd.getHypervisorType() == HypervisorType.Hyperv || scCmd.getHypervisorType() == HypervisorType.LXC || scCmd.getHypervisorType() == HypervisorType.Ovm3) { List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER); List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null); List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType()); zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor); pools.addAll(zoneStoragePoolsByTags); List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any); pools.addAll(zoneStoragePoolsByAnyHypervisor);
private boolean isPoolAvailable(Long poolId) { // get list of all pools List<StoragePoolVO> pools = _storagePoolDao.listAll(); // if no pools or 1 pool which is in maintenance if (pools == null || pools.size() == 0 || (pools.size() == 1 && pools.get(0).getStatus().equals(StoragePoolStatus.Maintenance))) { return false; } else { return true; } }
@Override public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) { List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId()); s_logger.debug("In createPool. Attaching the pool to each of the hosts."); List<HostVO> poolHosts = new ArrayList<HostVO>(); for (HostVO host : hosts) { try { storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId()); poolHosts.add(host); } catch (StorageConflictException se) { primaryDataStoreDao.expunge(dataStore.getId()); throw new CloudRuntimeException("Storage has already been added as local storage to host: " + host.getName()); } catch (Exception e) { s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e); } } if (poolHosts.isEmpty()) { s_logger.warn("No host can access storage pool " + dataStore + " in this zone."); primaryDataStoreDao.expunge(dataStore.getId()); throw new CloudRuntimeException("Failed to create storage pool as it is not accessible to hosts."); } dataStoreHelper.attachZone(dataStore, hypervisorType); return true; }
@Override public InfrastructureResponse listInfrastructure() { final InfrastructureResponse response = new InfrastructureResponse(); response.setZones(dataCenterDao.listAllZones().size()); response.setPods(podDao.listAllPods(null).size()); response.setClusters(clusterDao.listAllClusters(null).size()); response.setHosts(hostDao.listByType(Host.Type.Routing).size()); response.setStoragePools(storagePoolDao.listAll().size()); response.setImageStores(imageStoreDao.listImageStores().size()); response.setSystemvms(vmInstanceDao.listByTypes(VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm).size()); response.setRouters(domainRouterDao.listAll().size()); int cpuSockets = 0; for (final Host host : hostDao.listByType(Host.Type.Routing)) { if (host.getCpuSockets() != null) { cpuSockets += host.getCpuSockets(); } } response.setCpuSockets(cpuSockets); return response; }
@Override public String getPrimaryStorageNameLabel(VolumeVO volume) { Long poolId = volume.getPoolId(); // poolId is null only if volume is destroyed, which has been checked // before. assert poolId != null; StoragePoolVO PrimaryDataStoreVO = _storagePoolDao.findById(poolId); assert PrimaryDataStoreVO != null; return PrimaryDataStoreVO.getUuid(); }
_resourceMgr.listAllUpHosts(Host.Type.Routing, primarystore.getClusterId(), primarystore.getPodId(), primarystore.getDataCenterId()); if (allHosts.isEmpty()) { primaryDataStoreDao.expunge(primarystore.getId()); throw new CloudRuntimeException("No host up to associate a storage pool with in cluster " + primarystore.getClusterId()); primaryDataStoreDao.expunge(primarystore.getId()); return false; poolHosts.add(h); } catch (StorageConflictException se) { primaryDataStoreDao.expunge(primarystore.getId()); throw new CloudRuntimeException("Storage has already been added as local storage"); } catch (Exception e) { primaryDataStoreDao.expunge(primarystore.getId()); throw new CloudRuntimeException("Failed to access storage pool");