@Override public List<DataStore> listImageStoresByScope(ZoneScope scope) { List<ImageStoreVO> stores = dataStoreDao.findByScope(scope); List<DataStore> imageStores = new ArrayList<DataStore>(); for (ImageStoreVO store : stores) { imageStores.add(getImageStore(store.getId())); } return imageStores; }
@Override public List<DataStore> listImageStores() { List<ImageStoreVO> stores = dataStoreDao.listImageStores(); List<DataStore> imageStores = new ArrayList<DataStore>(); for (ImageStoreVO store : stores) { imageStores.add(getImageStore(store.getId())); } return imageStores; }
/** * Convert current NFS secondary storage to Staging store to be ready to migrate to S3 object store. * @param store NFS image store. * @return true if successful. */ public boolean convertToStagingStore(DataStore store) { ImageStoreVO nfsStore = imageStoreDao.findById(store.getId()); nfsStore.setRole(DataStoreRole.ImageCache); imageStoreDao.update(store.getId(), nfsStore); // clear snapshot entry on primary store to make next snapshot become full snapshot snapshotStoreDao.deleteSnapshotRecordsOnPrimary(); return true; } }
public ImageStoreVO createImageStore(Map<String, Object> params) { ImageStoreVO store = imageStoreDao.findByName((String)params.get("name")); if (store != null) { return store; } store = new ImageStoreVO(); store.setProtocol((String)params.get("protocol")); store.setProviderName((String)params.get("providerName")); store.setScope((ScopeType)params.get("scope")); store.setDataCenterId((Long)params.get("zoneId")); String uuid = (String)params.get("uuid"); if (uuid != null) { store.setUuid(uuid); } else { store.setUuid(UUID.randomUUID().toString()); } store.setName((String)params.get("name")); if (store.getName() == null) { store.setName(store.getUuid()); } store.setUrl((String)params.get("url")); store.setRole((DataStoreRole)params.get("role")); store = imageStoreDao.persist(store); return store; }
@Override public ImageStoreEntity getImageStore(long dataStoreId) { ImageStoreVO dataStore = dataStoreDao.findById(dataStoreId); String providerName = dataStore.getProviderName(); ImageStoreProvider provider = (ImageStoreProvider)providerManager.getDataStoreProvider(providerName); ImageStoreEntity imgStore = ImageStoreImpl.getDataStore(dataStore, driverMaps.get(provider.getName()), provider); return imgStore; }
ImageStoreVO imageStore = _imageStoreDao.findByName(name); if (imageStore != null) { throw new InvalidParameterValueException("The image store with name " + name + " already exists, try creating with another name"); List<ImageStoreVO> imageStores = _imageStoreDao.listImageStores(); for (ImageStoreVO store : imageStores) { if (!store.getProviderName().equalsIgnoreCase(providerName)) {
@Override public void doInTransactionWithoutResult(TransactionStatus status) { // first delete from image_store_details table, we need to do that since // we are not actually deleting record from main // image_data_store table, so delete cascade will not work _imageStoreDetailsDao.deleteDetails(storeId); _snapshotStoreDao.deletePrimaryRecordsForStore(storeId, DataStoreRole.ImageCache); _volumeStoreDao.deletePrimaryRecordsForStore(storeId); _templateStoreDao.deletePrimaryRecordsForStore(storeId); _imageStoreDao.remove(storeId); } });
@Override public ImageStoreEntity getImageStore(String uuid) { ImageStoreVO dataStore = dataStoreDao.findByUuid(uuid); return getImageStore(dataStore.getId()); }
final List<ImageStoreVO> imgStores = _imgStoreDao.findRegionImageStores(); if (imgStores != null && imgStores.size() > 0) { regionSecondaryEnabled = true;
@Override public List<DataStore> listImageStoreByProvider(String provider) { List<ImageStoreVO> stores = dataStoreDao.findByProvider(provider); List<DataStore> imageStores = new ArrayList<DataStore>(); for (ImageStoreVO store : stores) { imageStores.add(getImageStore(store.getId())); } return imageStores; }
@Override public List<DataStore> listImageCacheStores(Scope scope) { if (scope.getScopeType() != ScopeType.ZONE) { s_logger.debug("only support zone wide image cache stores"); return null; } List<ImageStoreVO> stores = dataStoreDao.findImageCacheByScope(new ZoneScope(scope.getScopeId())); List<DataStore> imageStores = new ArrayList<DataStore>(); for (ImageStoreVO store : stores) { imageStores.add(getImageStore(store.getId())); } return imageStores; }
final long storeId = cmd.getId(); ImageStoreVO store = _imageStoreDao.findById(storeId); if (store == null) { throw new InvalidParameterValueException("Image store with id " + storeId + " doesn't exist");
public ImageStoreVO createImageStore(Map<String, Object> params, Map<String, String> details) { ImageStoreVO store = imageStoreDao.findByName((String)params.get("name")); if (store != null) { return store; store = imageStoreDao.persist(store);
@Override public void doInTransactionWithoutResult(TransactionStatus status) { // first delete from image_store_details table, we need to do that since // we are not actually deleting record from main // image_data_store table, so delete cascade will not work _imageStoreDetailsDao.deleteDetails(storeId); _snapshotStoreDao.deletePrimaryRecordsForStore(storeId, DataStoreRole.Image); _volumeStoreDao.deletePrimaryRecordsForStore(storeId); _templateStoreDao.deletePrimaryRecordsForStore(storeId); _imageStoreDao.remove(storeId); } });
/** * Obtain NFS protocol version (if provided) for a store uuid.<br/> * @param resourceId image store id * @return {@code null} if {@code secstorage.nfs.version} is not found for storeUuid <br/> * {@code X} if {@code secstorage.nfs.version} is found found for storeUuid */ public Integer getNfsVersionByUuid(String storeUuid){ ImageStoreVO imageStore = imageStoreDao.findByUuid(storeUuid); if (imageStore != null){ return getNfsVersion(imageStore.getId()); } return getGlobalDefaultNfsVersion(); }
List<ImageStoreVO> stores = _imgStoreDao.findRegionImageStores(); if (stores != null && stores.size() > 0) { isRegionStore = true;
final long storeId = cmd.getId(); ImageStoreVO store = _imageStoreDao.findById(storeId); if (store == null) { throw new InvalidParameterValueException("Cache store with id " + storeId + " doesn't exist");
private void addStorageMetrics(final List<Item> metricsList, final long dcId, final String zoneName, final String zoneUuid) { for (final StoragePoolJoinVO pool: storagePoolJoinDao.listAll()) { if (pool == null || pool.getZoneId() != dcId) { continue; } final String poolName = pool.getName(); final String poolPath = pool.getHostAddress() + ":" + pool.getPath(); long usedCapacity = 0L; long allocatedCapacity = pool.getUsedCapacity() + pool.getReservedCapacity(); final long totalCapacity = pool.getCapacityBytes(); final StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId()); if (stats != null) { usedCapacity = stats.getByteUsed(); } final BigDecimal poolOverProvisioningFactor = BigDecimal.valueOf(CapacityManager.StorageOverprovisioningFactor.valueIn(pool.getId())); final String poolFactor = poolOverProvisioningFactor.toString(); metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, USED, usedCapacity)); metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, ALLOCATED, allocatedCapacity)); metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, UNALLOCATED, poolOverProvisioningFactor.multiply(BigDecimal.valueOf(totalCapacity)).longValue() - allocatedCapacity)); metricsList.add(new ItemPool(zoneName, zoneUuid, poolName, poolPath, "primary", poolFactor, TOTAL, totalCapacity)); } for (final ImageStore imageStore : imageStoreDao.findByScope(new ZoneScope(dcId))) { final StorageStats stats = ApiDBUtils.getSecondaryStorageStatistics(imageStore.getId()); metricsList.add(new ItemPool(zoneName, zoneUuid, imageStore.getName(), imageStore.getUrl(), "secondary", null, USED, stats != null ? stats.getByteUsed() : 0)); metricsList.add(new ItemPool(zoneName, zoneUuid, imageStore.getName(), imageStore.getUrl(), "secondary", null, TOTAL, stats != null ? stats.getCapacityBytes() : 0)); } }
@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; }