Search in sources :

Example 1 with CreateObjectCommand

use of com.cloud.storage.command.CreateObjectCommand in project cosmic by MissionCriticalCloud.

the class CloudStackPrimaryDataStoreDriverImpl method takeSnapshot.

@Override
public void takeSnapshot(final SnapshotInfo snapshot, final AsyncCompletionCallback<CreateCmdResult> callback) {
    CreateCmdResult result = null;
    try {
        final SnapshotObjectTO snapshotTO = (SnapshotObjectTO) snapshot.getTO();
        final Object payload = snapshot.getPayload();
        if (payload != null && payload instanceof CreateSnapshotPayload) {
            final CreateSnapshotPayload snapshotPayload = (CreateSnapshotPayload) payload;
            snapshotTO.setQuiescevm(snapshotPayload.getQuiescevm());
        }
        final CreateObjectCommand cmd = new CreateObjectCommand(snapshotTO);
        final EndPoint ep = epSelector.select(snapshot, StorageAction.TAKESNAPSHOT);
        Answer answer = null;
        if (ep == null) {
            final String errMsg = "No remote endpoint to send createObjectCommand, check if host or ssvm is down?";
            s_logger.error(errMsg);
            answer = new Answer(cmd, false, errMsg);
        } else {
            answer = ep.sendMessage(cmd);
        }
        result = new CreateCmdResult(null, answer);
        if (answer != null && !answer.getResult()) {
            result.setResult(answer.getDetails());
        }
        callback.complete(result);
        return;
    } catch (final Exception e) {
        s_logger.debug("Failed to take snapshot: " + snapshot.getId(), e);
        result = new CreateCmdResult(null, null);
        result.setResult(e.toString());
    }
    callback.complete(result);
}
Also used : SnapshotObjectTO(com.cloud.storage.to.SnapshotObjectTO) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) CreateSnapshotPayload(com.cloud.storage.CreateSnapshotPayload) VolumeObject(com.cloud.storage.volume.VolumeObject) DataObject(com.cloud.engine.subsystem.api.storage.DataObject) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CreateCmdResult(com.cloud.engine.subsystem.api.storage.CreateCmdResult) CreateObjectCommand(com.cloud.storage.command.CreateObjectCommand) StorageUnavailableException(com.cloud.exception.StorageUnavailableException)

Example 2 with CreateObjectCommand

use of com.cloud.storage.command.CreateObjectCommand in project cosmic by MissionCriticalCloud.

the class CloudStackPrimaryDataStoreDriverImpl method createVolume.

public Answer createVolume(final VolumeInfo volume) throws StorageUnavailableException {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Creating volume: " + volume);
    }
    final CreateObjectCommand cmd = new CreateObjectCommand(volume.getTO());
    final EndPoint ep = epSelector.select(volume);
    Answer answer = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send DeleteCommand, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    return answer;
}
Also used : ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CreateObjectCommand(com.cloud.storage.command.CreateObjectCommand)

Aggregations

Answer (com.cloud.agent.api.Answer)2 ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)2 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)2 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)2 CreateObjectCommand (com.cloud.storage.command.CreateObjectCommand)2 CreateCmdResult (com.cloud.engine.subsystem.api.storage.CreateCmdResult)1 DataObject (com.cloud.engine.subsystem.api.storage.DataObject)1 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)1 CreateSnapshotPayload (com.cloud.storage.CreateSnapshotPayload)1 SnapshotObjectTO (com.cloud.storage.to.SnapshotObjectTO)1 VolumeObject (com.cloud.storage.volume.VolumeObject)1