Search in sources :

Example 21 with DataStore

use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.

the class StorageCacheManagerImpl method getCacheStores.

protected List<DataStore> getCacheStores() {
    final QueryBuilder<ImageStoreVO> sc = QueryBuilder.create(ImageStoreVO.class);
    sc.and(sc.entity().getRole(), SearchCriteria.Op.EQ, DataStoreRole.ImageCache);
    final List<ImageStoreVO> imageStoreVOs = sc.list();
    final List<DataStore> stores = new ArrayList<>();
    for (final ImageStoreVO vo : imageStoreVOs) {
        stores.add(dataStoreManager.getDataStore(vo.getId(), vo.getRole()));
    }
    return stores;
}
Also used : DataStore(com.cloud.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) ImageStoreVO(com.cloud.storage.datastore.db.ImageStoreVO)

Example 22 with DataStore

use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.

the class AbstractHyperVisorStorageMotionStrategy method updateVolumePathsAfterMigration.

protected void updateVolumePathsAfterMigration(final Map<VolumeInfo, DataStore> volumeToPool, final List<VolumeObjectTO> volumeTos) {
    for (final Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
        boolean updated = false;
        final VolumeInfo volume = entry.getKey();
        final StoragePool pool = (StoragePool) entry.getValue();
        for (final VolumeObjectTO volumeTo : volumeTos) {
            if (volume.getId() == volumeTo.getId()) {
                final VolumeVO volumeVO = volDao.findById(volume.getId());
                final Long oldPoolId = volumeVO.getPoolId();
                volumeVO.setPath(volumeTo.getPath());
                volumeVO.setFolder(pool.getPath());
                volumeVO.setPodId(pool.getPodId());
                volumeVO.setPoolId(pool.getId());
                volumeVO.setLastPoolId(oldPoolId);
                volDao.update(volume.getId(), volumeVO);
                updated = true;
                break;
            }
        }
        if (!updated) {
            s_logger.error("Volume path wasn't updated for volume " + volume + " after it was migrated.");
        }
    }
}
Also used : StoragePool(com.cloud.storage.StoragePool) VolumeVO(com.cloud.storage.VolumeVO) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) VolumeObjectTO(com.cloud.storage.to.VolumeObjectTO) VolumeInfo(com.cloud.engine.subsystem.api.storage.VolumeInfo) Map(java.util.Map)

Example 23 with DataStore

use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.

the class AbstractHyperVisorStorageMotionStrategy method buildVolumeMapping.

protected List<Pair<VolumeTO, StorageFilerTO>> buildVolumeMapping(final Map<VolumeInfo, DataStore> volumeToPool) {
    final List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new ArrayList<>();
    for (final Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
        final VolumeInfo volume = entry.getKey();
        final VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
        final StorageFilerTO filerTo = new StorageFilerTO((StoragePool) entry.getValue());
        volumeToFilerto.add(new Pair<>(volumeTo, filerTo));
    }
    return volumeToFilerto;
}
Also used : VolumeTO(com.cloud.agent.api.to.VolumeTO) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) VolumeInfo(com.cloud.engine.subsystem.api.storage.VolumeInfo) Map(java.util.Map) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) Pair(com.cloud.utils.Pair)

Example 24 with DataStore

use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.

the class AncientDataMotionStrategy method cacheSnapshotChain.

protected DataObject cacheSnapshotChain(SnapshotInfo snapshot, final Scope scope) {
    DataObject leafData = null;
    final DataStore store = cacheMgr.getCacheStorage(snapshot, scope);
    while (snapshot != null) {
        final DataObject cacheData = cacheMgr.createCacheObject(snapshot, store);
        if (leafData == null) {
            leafData = cacheData;
        }
        snapshot = snapshot.getParent();
    }
    return leafData;
}
Also used : DataObject(com.cloud.engine.subsystem.api.storage.DataObject) DataStore(com.cloud.engine.subsystem.api.storage.DataStore)

Example 25 with DataStore

use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.

the class TemplateDataFactoryImpl method listTemplateOnCache.

@Override
public List<TemplateInfo> listTemplateOnCache(final long templateId) {
    final List<TemplateDataStoreVO> cacheTmpls = templateStoreDao.listOnCache(templateId);
    final List<TemplateInfo> tmplObjs = new ArrayList<>();
    for (final TemplateDataStoreVO cacheTmpl : cacheTmpls) {
        final long storeId = cacheTmpl.getDataStoreId();
        final DataStore store = storeMgr.getDataStore(storeId, DataStoreRole.ImageCache);
        final TemplateInfo tmplObj = getTemplate(templateId, store);
        tmplObjs.add(tmplObj);
    }
    return tmplObjs;
}
Also used : TemplateInfo(com.cloud.engine.subsystem.api.storage.TemplateInfo) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) TemplateDataStoreVO(com.cloud.storage.datastore.db.TemplateDataStoreVO)

Aggregations

DataStore (com.cloud.engine.subsystem.api.storage.DataStore)96 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)43 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)23 ExecutionException (java.util.concurrent.ExecutionException)23 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)19 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)17 TemplateDataStoreVO (com.cloud.storage.datastore.db.TemplateDataStoreVO)17 ArrayList (java.util.ArrayList)17 VolumeVO (com.cloud.storage.VolumeVO)16 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)15 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)14 PrimaryDataStore (com.cloud.engine.subsystem.api.storage.PrimaryDataStore)14 DB (com.cloud.utils.db.DB)14 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)12 SnapshotDataStoreVO (com.cloud.storage.datastore.db.SnapshotDataStoreVO)12 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)12 VolumeDataStoreVO (com.cloud.storage.datastore.db.VolumeDataStoreVO)12 ConfigurationException (javax.naming.ConfigurationException)12 Answer (com.cloud.agent.api.Answer)10 VMTemplateVO (com.cloud.storage.VMTemplateVO)10