Search in sources :

Example 11 with PrimaryDataStore

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

the class TemplateObject method getInstallPath.

@Override
public String getInstallPath() {
    if (installPath != null) {
        return installPath;
    }
    if (dataStore == null) {
        return null;
    }
    // managed primary data stores should not have an install path
    if (dataStore instanceof PrimaryDataStore) {
        final PrimaryDataStore primaryDataStore = (PrimaryDataStore) dataStore;
        final Map<String, String> details = primaryDataStore.getDetails();
        final boolean managed = details != null && Boolean.parseBoolean(details.get(PrimaryDataStore.MANAGED));
        if (managed) {
            return null;
        }
    }
    final DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore);
    return obj.getInstallPath();
}
Also used : DataObjectInStore(com.cloud.engine.subsystem.api.storage.DataObjectInStore) PrimaryDataStore(com.cloud.engine.subsystem.api.storage.PrimaryDataStore)

Example 12 with PrimaryDataStore

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

the class SnapshotServiceImpl method revertSnapshot.

@Override
public boolean revertSnapshot(final SnapshotInfo snapshot) {
    final SnapshotInfo snapshotOnPrimaryStore = _snapshotFactory.getSnapshot(snapshot.getId(), DataStoreRole.Primary);
    if (snapshotOnPrimaryStore == null) {
        throw new CloudRuntimeException("Cannot find an entry for snapshot " + snapshot.getId() + " on primary storage pools");
    }
    final PrimaryDataStore store = (PrimaryDataStore) snapshotOnPrimaryStore.getDataStore();
    final AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<>();
    final RevertSnapshotContext<CommandResult> context = new RevertSnapshotContext<>(null, snapshot, future);
    final AsyncCallbackDispatcher<SnapshotServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
    caller.setCallback(caller.getTarget().revertSnapshotCallback(null, null)).setContext(context);
    ((PrimaryDataStoreDriver) store.getDriver()).revertSnapshot(snapshot, snapshotOnPrimaryStore, caller);
    SnapshotResult result = null;
    try {
        result = future.get();
        if (result.isFailed()) {
            throw new CloudRuntimeException(result.getResult());
        }
        return true;
    } catch (final InterruptedException e) {
        s_logger.debug("revert snapshot is failed: " + e.toString());
    } catch (final ExecutionException e) {
        s_logger.debug("revert snapshot is failed: " + e.toString());
    }
    return false;
}
Also used : SnapshotResult(com.cloud.engine.subsystem.api.storage.SnapshotResult) CommandResult(com.cloud.storage.command.CommandResult) CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult) AsyncCallFuture(com.cloud.framework.async.AsyncCallFuture) SnapshotInfo(com.cloud.engine.subsystem.api.storage.SnapshotInfo) PrimaryDataStoreDriver(com.cloud.engine.subsystem.api.storage.PrimaryDataStoreDriver) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ExecutionException(java.util.concurrent.ExecutionException) PrimaryDataStore(com.cloud.engine.subsystem.api.storage.PrimaryDataStore)

Aggregations

PrimaryDataStore (com.cloud.engine.subsystem.api.storage.PrimaryDataStore)12 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)7 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)6 VMTemplateVO (com.cloud.storage.VMTemplateVO)6 Test (org.junit.Test)6 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 ExecutionException (java.util.concurrent.ExecutionException)4 TemplateInfo (com.cloud.engine.subsystem.api.storage.TemplateInfo)3 AsyncCallFuture (com.cloud.framework.async.AsyncCallFuture)3 Host (com.cloud.host.Host)3 NamedThreadFactory (com.cloud.utils.concurrency.NamedThreadFactory)3 ExecutorService (java.util.concurrent.ExecutorService)3 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)3 CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)2 VolumeVO (com.cloud.storage.VolumeVO)2 Answer (com.cloud.agent.api.Answer)1 ListVolumeAnswer (com.cloud.agent.api.storage.ListVolumeAnswer)1 ResizeVolumeCommand (com.cloud.agent.api.storage.ResizeVolumeCommand)1 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)1 ChapInfo (com.cloud.engine.subsystem.api.storage.ChapInfo)1