Search in sources :

Example 26 with DellSCDriverTask

use of com.emc.storageos.driver.dellsc.DellSCDriverTask in project coprhd-controller by CoprHD.

the class DellSCSnapshots method deleteVolumeSnapshot.

/**
 * Delete a snapshot.
 *
 * @param snapshot The snapshots to delete.
 * @return The delete task.
 */
public DriverTask deleteVolumeSnapshot(VolumeSnapshot snapshot) {
    DellSCDriverTask task = new DellSCDriverTask("deleteVolumeSnapshot");
    try {
        StorageCenterAPI api = connectionManager.getConnection(snapshot.getStorageSystemId());
        api.expireReplay(snapshot.getNativeId());
        task.setStatus(TaskStatus.READY);
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error deleting snapshot %s: %s", snapshot.getNativeId(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    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)

Example 27 with DellSCDriverTask

use of com.emc.storageos.driver.dellsc.DellSCDriverTask 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)

Aggregations

DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)27 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)22 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)22 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)22 DriverTask (com.emc.storageos.storagedriver.DriverTask)10 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)8 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)6 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)3 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)3 ArrayList (java.util.ArrayList)3 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)2 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)2 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)2 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)2 StorageCenter (com.emc.storageos.driver.dellsc.scapi.objects.StorageCenter)2 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)2 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)2 List (java.util.List)2 EmDataCollector (com.emc.storageos.driver.dellsc.scapi.objects.EmDataCollector)1 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)1