use of com.cloud.engine.subsystem.api.storage.ZoneScope in project cosmic by MissionCriticalCloud.
the class PrimaryDataStoreImpl method getScope.
@Override
public Scope getScope() {
final 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) {
final 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;
}
use of com.cloud.engine.subsystem.api.storage.ZoneScope in project cosmic by MissionCriticalCloud.
the class ImageStoreProviderManagerImpl method listImageCacheStores.
@Override
public List<DataStore> listImageCacheStores(final Scope scope) {
if (scope.getScopeType() != ScopeType.ZONE) {
s_logger.debug("only support zone wide image cache stores");
return null;
}
final List<ImageStoreVO> stores = dataStoreDao.findImageCacheByScope(new ZoneScope(scope.getScopeId()));
final List<DataStore> imageStores = new ArrayList<>();
for (final ImageStoreVO store : stores) {
imageStores.add(getImageStore(store.getId()));
}
return imageStores;
}
use of com.cloud.engine.subsystem.api.storage.ZoneScope in project cosmic by MissionCriticalCloud.
the class AncientDataMotionStrategy method getZoneScope.
private Scope getZoneScope(final Scope destScope) {
ZoneScope zoneScope = null;
if (destScope instanceof ClusterScope) {
final ClusterScope clusterScope = (ClusterScope) destScope;
zoneScope = new ZoneScope(clusterScope.getZoneId());
} else if (destScope instanceof HostScope) {
final HostScope hostScope = (HostScope) destScope;
zoneScope = new ZoneScope(hostScope.getZoneId());
} else {
zoneScope = (ZoneScope) destScope;
}
return zoneScope;
}
use of com.cloud.engine.subsystem.api.storage.ZoneScope in project cosmic by MissionCriticalCloud.
the class AncientDataMotionStrategy method copyVolumeFromSnapshot.
protected Answer copyVolumeFromSnapshot(final DataObject snapObj, final DataObject volObj) {
final SnapshotInfo snapshot = (SnapshotInfo) snapObj;
final StoragePool pool = (StoragePool) volObj.getDataStore();
final String basicErrMsg = "Failed to create volume from " + snapshot.getName() + " on pool " + pool;
final DataStore store = snapObj.getDataStore();
final DataStoreTO storTO = store.getTO();
DataObject srcData = snapObj;
try {
if (!(storTO instanceof NfsTO)) {
// cache snapshot to zone-wide staging store for the volume to be created
srcData = cacheSnapshotChain(snapshot, new ZoneScope(pool.getDataCenterId()));
}
final String value = configDao.getValue(Config.CreateVolumeFromSnapshotWait.toString());
final int _createVolumeFromSnapshotWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreateVolumeFromSnapshotWait.getDefaultValue()));
EndPoint ep = null;
if (srcData.getDataStore().getRole() == DataStoreRole.Primary) {
ep = selector.select(volObj);
} else {
ep = selector.select(srcData, volObj);
}
final CopyCommand cmd = new CopyCommand(srcData.getTO(), volObj.getTO(), _createVolumeFromSnapshotWait, VirtualMachineManager.ExecuteInSequence.value());
Answer answer = null;
if (ep == null) {
final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
}
return answer;
} catch (final Exception e) {
s_logger.error(basicErrMsg, e);
throw new CloudRuntimeException(basicErrMsg);
} finally {
if (!(storTO instanceof NfsTO)) {
// still keep snapshot on cache which may be migrated from previous secondary storage
releaseSnapshotCacheChain((SnapshotInfo) srcData);
}
}
}
use of com.cloud.engine.subsystem.api.storage.ZoneScope in project cosmic by MissionCriticalCloud.
the class StorageManagerImpl method cleanupSecondaryStorage.
@Override
@DB
public void cleanupSecondaryStorage(final boolean recurring) {
// so here we don't need to issue DeleteCommand to resource anymore, only need to remove db entry.
try {
// Cleanup templates in template_store_ref
final List<DataStore> imageStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(null));
for (final DataStore store : imageStores) {
try {
final long storeId = store.getId();
final List<TemplateDataStoreVO> destroyedTemplateStoreVOs = _templateStoreDao.listDestroyed(storeId);
s_logger.debug("Secondary storage garbage collector found " + destroyedTemplateStoreVOs.size() + " templates to cleanup on template_store_ref for store: " + store.getName());
for (final TemplateDataStoreVO destroyedTemplateStoreVO : destroyedTemplateStoreVOs) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Deleting template store DB entry: " + destroyedTemplateStoreVO);
}
_templateStoreDao.remove(destroyedTemplateStoreVO.getId());
}
} catch (final Exception e) {
s_logger.warn("problem cleaning up templates in template_store_ref for store: " + store.getName(), e);
}
}
// CleanUp snapshots on snapshot_store_ref
for (final DataStore store : imageStores) {
try {
final List<SnapshotDataStoreVO> destroyedSnapshotStoreVOs = _snapshotStoreDao.listDestroyed(store.getId());
s_logger.debug("Secondary storage garbage collector found " + destroyedSnapshotStoreVOs.size() + " snapshots to cleanup on snapshot_store_ref for store: " + store.getName());
for (final SnapshotDataStoreVO destroyedSnapshotStoreVO : destroyedSnapshotStoreVOs) {
// check if this snapshot has child
final SnapshotInfo snap = snapshotFactory.getSnapshot(destroyedSnapshotStoreVO.getSnapshotId(), store);
if (snap.getChild() != null) {
s_logger.debug("Skip snapshot on store: " + destroyedSnapshotStoreVO + " , because it has child");
continue;
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Deleting snapshot store DB entry: " + destroyedSnapshotStoreVO);
}
_snapshotDao.remove(destroyedSnapshotStoreVO.getSnapshotId());
final SnapshotDataStoreVO snapshotOnPrimary = _snapshotStoreDao.findBySnapshot(destroyedSnapshotStoreVO.getSnapshotId(), DataStoreRole.Primary);
if (snapshotOnPrimary != null) {
_snapshotStoreDao.remove(snapshotOnPrimary.getId());
}
_snapshotStoreDao.remove(destroyedSnapshotStoreVO.getId());
}
} catch (final Exception e2) {
s_logger.warn("problem cleaning up snapshots in snapshot_store_ref for store: " + store.getName(), e2);
}
}
// CleanUp volumes on volume_store_ref
for (final DataStore store : imageStores) {
try {
final List<VolumeDataStoreVO> destroyedStoreVOs = _volumeStoreDao.listDestroyed(store.getId());
s_logger.debug("Secondary storage garbage collector found " + destroyedStoreVOs.size() + " volumes to cleanup on volume_store_ref for store: " + store.getName());
for (final VolumeDataStoreVO destroyedStoreVO : destroyedStoreVOs) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Deleting volume store DB entry: " + destroyedStoreVO);
}
_volumeStoreDao.remove(destroyedStoreVO.getId());
}
} catch (final Exception e2) {
s_logger.warn("problem cleaning up volumes in volume_store_ref for store: " + store.getName(), e2);
}
}
} catch (final Exception e3) {
s_logger.warn("problem cleaning up secondary storage DB entries. ", e3);
}
}
Aggregations