@Override public PrimaryDataStoreInfo getStoragePool(long id) { return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(id, DataStoreRole.Primary); }
@Override public String getStoragePoolOfVolume(long volumeId) { VolumeVO vol = _volsDao.findById(volumeId); return dataStoreMgr.getPrimaryDataStore(vol.getPoolId()).getUuid(); }
@Override public DataStore getImageStore(String storeUuid, Long zoneId) { DataStore imageStore = null; if (storeUuid != null) { imageStore = _dataStoreMgr.getDataStore(storeUuid, DataStoreRole.Image); } else { imageStore = _dataStoreMgr.getImageStore(zoneId); if (imageStore == null) { throw new CloudRuntimeException("cannot find an image store for zone " + zoneId); } } return imageStore; }
@Override public TemplateDataStoreVO findByTemplateZone(long templateId, Long zoneId, DataStoreRole role) { // get all elgible image stores List<DataStore> imgStores = null; if (role == DataStoreRole.Image) { imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); } else if (role == DataStoreRole.ImageCache) { imgStores = _storeMgr.getImageCacheStores(new ZoneScope(zoneId)); } if (imgStores != null) { for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStore(templateId, store.getId()); if (sRes != null && sRes.size() > 0) { return sRes.get(0); } } } return null; }
@Override public String getSecondaryStorageURL(long zoneId) { DataStore secStore = _dataStoreMgr.getImageStore(zoneId); if (secStore == null) { return null; } return secStore.getUri(); }
@Override public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) { // get all elgible image stores List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imgStores != null) { for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status); if (sRes != null && sRes.size() > 0) { Collections.shuffle(sRes); return sRes.get(0); } } } return null; }
zoneId = volume.getDataCenterId(); DataStore store = _dataStoreMgr.getImageStore(zoneId); if (store == null) { throw new CloudRuntimeException("cannot find an image store for zone " + zoneId); if (_dataStoreMgr.isRegionStore(store)) {
@Override public void syncVolumeSnapshotsToRegionStore(long volumeId, DataStore store) { if (dataStoreMgr.isRegionStore(store)) { // list all backed up snapshots for the given volume List<SnapshotVO> snapshots = _snapshotDao.listByStatus(volumeId, Snapshot.State.BackedUp); if (snapshots != null) { for (SnapshotVO snapshot : snapshots) { syncSnapshotToRegionStore(snapshot.getId(), store); } } } }
@Override public DataStore getCacheStore(Scope scope) { if (scope.getScopeType() != ScopeType.ZONE) { s_logger.debug("Can only support zone wide cache storage"); return null; } List<DataStore> cacheStores = dataStoreMgr.getImageCacheStores(scope); if ((cacheStores == null) || (cacheStores.size() <= 0)) { s_logger.debug("Can't find staging storage in zone: " + scope.getScopeId()); return null; } return imageStoreMgr.getImageStore(cacheStores); }
private String getSecondaryStorageStoreUrl(long zoneId) { String secUrl = null; DataStore secStore = _dataStoreMgr.getImageStore(zoneId); if (secStore != null) { secUrl = secStore.getUri(); } if (secUrl == null) { s_logger.warn("Secondary storage uri couldn't be retrieved"); } return secUrl; }
@Override public List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId) { // find all eligible image stores for this zone scope List<DataStore> imageStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imageStores == null || imageStores.size() == 0) { return null; } List<DataStore> stores = new ArrayList<DataStore>(); for (DataStore store : imageStores) { // check if the template is stored there List<TemplateDataStoreVO> storeTmpl = _tmplStoreDao.listByTemplateStore(templateId, store.getId()); if (storeTmpl != null && storeTmpl.size() > 0) { stores.add(store); } } return stores; }
@Override public void syncTemplateToRegionStore(long templateId, DataStore store) { if (_storeMgr.isRegionStore(store)) { if (s_logger.isDebugEnabled()) { s_logger.debug("Sync template " + templateId + " from cache to object store...");
@Override public TemplateDataStoreVO findByTemplateZoneStagingDownloadStatus(long templateId, Long zoneId, Status... status) { // get all elgible image stores List<DataStore> cacheStores = _storeMgr.getImageCacheStores(new ZoneScope(zoneId)); if (cacheStores != null) { for (DataStore store : cacheStores) { List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status); if (sRes != null && sRes.size() > 0) { Collections.shuffle(sRes); return sRes.get(0); } } } return null; }
private boolean storageSystemSupportsCapability(long storagePoolId, String capability) { boolean supportsCapability = false; DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(capability); supportsCapability = Boolean.valueOf(value); } return supportsCapability; }
private DataStore findSnapshotImageStore(SnapshotInfo snapshot) { Boolean fullSnapshot = true; Boolean snapshotFullBackup = snapshot.getFullBackup(); if (snapshotFullBackup != null) { fullSnapshot = snapshotFullBackup; } if (fullSnapshot) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } else { SnapshotInfo parentSnapshot = snapshot.getParent(); // Note that DataStore information in parentSnapshot is for primary // data store here, we need to // find the image store where the parent snapshot backup is located SnapshotDataStoreVO parentSnapshotOnBackupStore = null; if (parentSnapshot != null) { parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image); } if (parentSnapshotOnBackupStore == null) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } return dataStoreMgr.getDataStore(parentSnapshotOnBackupStore.getDataStoreId(), parentSnapshotOnBackupStore.getRole()); } }
break; StoragePool pol = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
@Override public TemplateProfile prepareDelete(DeleteIsoCmd cmd) { TemplateProfile profile = super.prepareDelete(cmd); List<Long> zoneIdList = profile.getZoneIdList(); if (zoneIdList != null && (storeMgr.getImageStore(zoneIdList.get(0)) == null)) { throw new InvalidParameterValueException("Failed to find a secondary storage in the specified zone."); } return profile; } }
@Override public List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) { // get all elgible image stores List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imgStores != null) { List<TemplateDataStoreVO> result = new ArrayList<TemplateDataStoreVO>(); for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status); if (sRes != null && sRes.size() > 0) { result.addAll(sRes); } } return result; } return null; }
s_logger.info("Template Sync did not find " + uniqueName + " on image store " + storeId + ", may request download based on available hypervisor types"); if (tmpltStore != null) { if (_storeMgr.isRegionStore(store) && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready && tmpltStore.getInstallPath() == null) { if (_storeMgr.isRegionStore(store)) { TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId()); if (tmpltStore != null && tmpltStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready
@Override public DataStore getCacheStore(DataObject data, Scope scope) { if (scope.getScopeType() != ScopeType.ZONE) { s_logger.debug("Can only support zone wide cache storage"); return null; } List<DataStore> cacheStores = dataStoreMgr.getImageCacheStores(scope); if (cacheStores.size() <= 0) { s_logger.debug("Can't find staging storage in zone: " + scope.getScopeId()); return null; } // if there are multiple cache stores, we give priority to the one where data is already there if (cacheStores.size() > 1) { for (DataStore store : cacheStores) { DataObjectInStore obj = objectInStoreMgr.findObject(data, store); if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready && statsCollector.imageStoreHasEnoughCapacity(store)) { s_logger.debug("pick the cache store " + store.getId() + " where data is already there"); return store; } } } return imageStoreMgr.getImageStore(cacheStores); } }