Search in sources :

Example 6 with PrimaryDataStoreInfo

use of com.cloud.legacymodel.storage.PrimaryDataStoreInfo in project cosmic by MissionCriticalCloud.

the class StorageManagerImpl method preparePrimaryStorageForMaintenance.

@Override
@DB
public PrimaryDataStoreInfo preparePrimaryStorageForMaintenance(final Long primaryStorageId) throws ResourceUnavailableException, InsufficientCapacityException {
    final StoragePoolVO primaryStorage;
    primaryStorage = this._storagePoolDao.findById(primaryStorageId);
    if (primaryStorage == null) {
        final String msg = "Unable to obtain lock on the storage pool record in preparePrimaryStorageForMaintenance()";
        s_logger.error(msg);
        throw new InvalidParameterValueException(msg);
    }
    if (!primaryStorage.getStatus().equals(StoragePoolStatus.Up) && !primaryStorage.getStatus().equals(StoragePoolStatus.ErrorInMaintenance)) {
        throw new InvalidParameterValueException("Primary storage with id " + primaryStorageId + " is not ready for migration, as the status is:" + primaryStorage.getStatus().toString());
    }
    final DataStoreProvider provider = this._dataStoreProviderMgr.getDataStoreProvider(primaryStorage.getStorageProviderName());
    final DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
    final DataStore store = this._dataStoreMgr.getDataStore(primaryStorage.getId(), DataStoreRole.Primary);
    lifeCycle.maintain(store);
    return (PrimaryDataStoreInfo) this._dataStoreMgr.getDataStore(primaryStorage.getId(), DataStoreRole.Primary);
}
Also used : PrimaryDataStoreInfo(com.cloud.legacymodel.storage.PrimaryDataStoreInfo) DataStoreLifeCycle(com.cloud.engine.subsystem.api.storage.DataStoreLifeCycle) PrimaryDataStoreLifeCycle(com.cloud.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) DataStoreProvider(com.cloud.engine.subsystem.api.storage.DataStoreProvider) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) DB(com.cloud.utils.db.DB)

Aggregations

PrimaryDataStoreInfo (com.cloud.legacymodel.storage.PrimaryDataStoreInfo)6 DataStoreLifeCycle (com.cloud.engine.subsystem.api.storage.DataStoreLifeCycle)4 DataStoreProvider (com.cloud.engine.subsystem.api.storage.DataStoreProvider)4 PrimaryDataStoreLifeCycle (com.cloud.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle)4 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)4 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)3 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)3 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)3 StorageConflictException (com.cloud.legacymodel.exceptions.StorageConflictException)2 StorageUnavailableException (com.cloud.legacymodel.exceptions.StorageUnavailableException)2 DB (com.cloud.utils.db.DB)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 DataCenterVO (com.cloud.dc.DataCenterVO)1 ClusterScope (com.cloud.engine.subsystem.api.storage.ClusterScope)1 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)1 HostVO (com.cloud.host.HostVO)1 AgentUnavailableException (com.cloud.legacymodel.exceptions.AgentUnavailableException)1 ConnectionException (com.cloud.legacymodel.exceptions.ConnectionException)1 DiscoveryException (com.cloud.legacymodel.exceptions.DiscoveryException)1