Search in sources :

Example 1 with CreateObjectCommand

use of com.cloud.legacymodel.communication.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.legacymodel.to.SnapshotObjectTO) Answer(com.cloud.legacymodel.communication.answer.Answer) ResizeVolumeAnswer(com.cloud.legacymodel.communication.answer.ResizeVolumeAnswer) CopyCmdAnswer(com.cloud.legacymodel.communication.answer.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.legacymodel.communication.command.CreateObjectCommand) StorageUnavailableException(com.cloud.legacymodel.exceptions.StorageUnavailableException)

Example 2 with CreateObjectCommand

use of com.cloud.legacymodel.communication.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 : Answer(com.cloud.legacymodel.communication.answer.Answer) ResizeVolumeAnswer(com.cloud.legacymodel.communication.answer.ResizeVolumeAnswer) CopyCmdAnswer(com.cloud.legacymodel.communication.answer.CopyCmdAnswer) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CreateObjectCommand(com.cloud.legacymodel.communication.command.CreateObjectCommand)

Aggregations

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