Search in sources :

Example 6 with ScReplay

use of com.emc.storageos.driver.dellsc.scapi.objects.ScReplay in project coprhd-controller by CoprHD.

the class DellSCSnapshots method createVolumeSnapshot.

/**
 * Create volume snapshots.
 *
 * @param snapshots The list of snapshots to create.
 * @param storageCapabilities The requested capabilities of the snapshots.
 * @return The snapshot creation task.
 */
public DriverTask createVolumeSnapshot(List<VolumeSnapshot> snapshots, StorageCapabilities storageCapabilities) {
    DellSCDriverTask task = new DellSCDriverTask("createVolumeSnapshot");
    StringBuilder errBuffer = new StringBuilder();
    int createCount = 0;
    for (VolumeSnapshot snapshot : snapshots) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(snapshot.getStorageSystemId());
            // Make sure we can create a replay.
            // Automated tests have an artificial workflow where they create a volume
            // and try to create a snapshot without ever having data written to it. The
            // SC array will not activate a volume until it is mapped, so if we try to
            // create a snapshot right away it will fail. As a workaround, since we know
            // this should only ever happen in a test scenario, we temporarily map/unmap
            // it to get it to be activated.
            api.checkAndInitVolume(snapshot.getParentId());
            ScReplay replay = api.createReplay(snapshot.getParentId());
            util.getVolumeSnapshotFromReplay(replay, snapshot);
            createCount++;
        } catch (DellSCDriverException | StorageCenterAPIException dex) {
            String error = String.format("Error creating snapshot of volume %s: %s", snapshot.getParentId(), dex);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (createCount == snapshots.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (createCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 7 with ScReplay

use of com.emc.storageos.driver.dellsc.scapi.objects.ScReplay in project coprhd-controller by CoprHD.

the class StorageCenterAPI method getVolumeSnapshots.

/**
 * Gets all replays for a given volume.
 *
 * @param instanceId The volume instance ID.
 * @return The volume's replays.
 */
public ScReplay[] getVolumeSnapshots(String instanceId) {
    PayloadFilter filter = new PayloadFilter();
    filter.append("createVolume", instanceId);
    filter.append("active", false);
    filter.append("markedForExpiration", false);
    RestResult rr = restClient.post("StorageCenter/ScReplay/GetList", filter.toJson());
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScReplay[].class);
    }
    return new ScReplay[0];
}
Also used : RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) PayloadFilter(com.emc.storageos.driver.dellsc.scapi.rest.PayloadFilter) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Aggregations

ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)7 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)4 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)4 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)3 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)3 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)3 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)2 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)2 ScReplayConsistencyGroup (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayConsistencyGroup)1 Parameters (com.emc.storageos.driver.dellsc.scapi.rest.Parameters)1 PayloadFilter (com.emc.storageos.driver.dellsc.scapi.rest.PayloadFilter)1 VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)1 ArrayList (java.util.ArrayList)1