Search in sources :

Example 1 with ScReplay

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

the class DellSCDiscovery method getVolumeSnapshots.

/**
 * Gets all snapshots for a volume.
 *
 * @param storageVolume The volume.
 * @return The snapshots.
 */
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume storageVolume) {
    LOG.info("Getting snapshots for {}", storageVolume.getNativeId());
    List<VolumeSnapshot> result = new ArrayList<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
        ScReplay[] replays = api.getVolumeSnapshots(storageVolume.getNativeId());
        for (ScReplay replay : replays) {
            VolumeSnapshot snap = util.getVolumeSnapshotFromReplay(replay, null);
            result.add(snap);
        }
    } catch (DellSCDriverException e) {
        String msg = String.format("Error getting volume info: %s", e);
        LOG.warn(msg);
    }
    return result;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) ArrayList(java.util.ArrayList) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 2 with ScReplay

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

the class DellSCConsistencyGroups method populateCgSnapshotInfo.

/**
 * Populates VolumeSnapshot info from CG created replays.
 *
 * @param snapshots The expected VolumeSnapshot objects.
 * @param replays The created replays.
 * @return True if successful, false if errors encountered.
 */
private boolean populateCgSnapshotInfo(List<VolumeSnapshot> snapshots, ScReplay[] replays) {
    boolean complete = true;
    for (VolumeSnapshot snapshot : snapshots) {
        boolean found = false;
        for (ScReplay replay : replays) {
            if (replay.instanceId.startsWith(snapshot.getParentId())) {
                // Found match, populate the info
                util.getVolumeSnapshotFromReplay(replay, snapshot);
                found = true;
                break;
            }
        }
        if (!found) {
            complete = false;
            LOG.warn("Unable to find snapshot for {}", snapshot.getDisplayName());
        }
    }
    return complete;
}
Also used : ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 3 with ScReplay

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

the class StorageCenterAPI method createConsistencyGroupSnapshots.

/**
 * Create snapshots for the consistency group.
 *
 * @param instanceId The replay profile instance ID.
 * @return The replays created.
 * @throws StorageCenterAPIException
 */
public ScReplay[] createConsistencyGroupSnapshots(String instanceId) throws StorageCenterAPIException {
    LOG.debug("Creating consistency group snapshots for '{}'", instanceId);
    // Get a random identifier that will fit in our description field
    String id = UUID.randomUUID().toString().substring(0, 31);
    Parameters params = new Parameters();
    params.add("description", id);
    params.add("expireTime", 0);
    RestResult rr = restClient.post(String.format("StorageCenter/ScReplayProfile/%s/CreateReplay", instanceId), params.toJson());
    if (!checkResults(rr)) {
        String msg = String.format("Error creating snapshots from CG %s: %s", instanceId, rr.getErrorMsg());
        LOG.error(msg);
        throw new StorageCenterAPIException(msg);
    }
    rr = restClient.get(String.format("StorageCenter/ScReplayProfile/%s/ConsistencyGroupList", instanceId));
    if (!checkResults(rr)) {
        String msg = String.format("Error getting consistent groups: %s", rr.getErrorMsg());
        LOG.warn(msg);
        throw new StorageCenterAPIException(msg);
    }
    ScReplayConsistencyGroup consistentGroup = null;
    ScReplayConsistencyGroup[] cgs = gson.fromJson(rr.getResult(), ScReplayConsistencyGroup[].class);
    for (ScReplayConsistencyGroup cg : cgs) {
        if (id.equals(cg.description)) {
            consistentGroup = cg;
        }
    }
    if (consistentGroup != null) {
        rr = restClient.get(String.format("StorageCenter/ScReplayConsistencyGroup/%s/ReplayList", consistentGroup.instanceId));
        if (checkResults(rr)) {
            return gson.fromJson(rr.getResult(), ScReplay[].class);
        }
    }
    throw new StorageCenterAPIException("Unable to get replays created for consistency group.");
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) ScReplayConsistencyGroup(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayConsistencyGroup) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 4 with ScReplay

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

the class DellSCCloning method createVolumeClone.

/**
 * Create a clone of a volume.
 *
 * @param clones The clones to create.
 * @return The clone task.
 */
public DriverTask createVolumeClone(List<VolumeClone> clones) {
    LOG.info("Creating volume clone");
    DellSCDriverTask task = new DellSCDriverTask("createVolumeClone");
    StringBuilder errBuffer = new StringBuilder();
    int createCount = 0;
    for (VolumeClone clone : clones) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(clone.getStorageSystemId());
            ScReplay replay = null;
            // Make sure volume is active for the automated tests that try to
            // create temporary snapshot to create the clone from after immediate volume creation
            api.checkAndInitVolume(clone.getParentId());
            if (clone.getSourceType() == SourceType.SNAPSHOT) {
                replay = api.getReplay(clone.getParentId());
            } else {
                // Create temporary replay to create the clone from
                replay = api.createReplay(clone.getParentId(), 5);
            }
            // Now create a new volume from the snapshot
            ScVolume scVol = api.createViewVolume(clone.getDisplayName(), replay.instanceId);
            clone.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
            // New volumes don't allocate any space
            clone.setAllocatedCapacity(0L);
            clone.setWwn(scVol.deviceId);
            clone.setNativeId(scVol.instanceId);
            clone.setDeviceLabel(scVol.name);
            clone.setAccessStatus(AccessStatus.READ_WRITE);
            clone.setReplicationState(ReplicationState.SYNCHRONIZED);
            createCount++;
        } catch (DellSCDriverException | StorageCenterAPIException dex) {
            String error = String.format("Error creating clone of volume %s: %s", clone.getParentId(), dex);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (createCount == clones.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (createCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) 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) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 5 with ScReplay

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

the class DellSCConsistencyGroups method createConsistencyGroupSnapshot.

/**
 * Create consistency group snapshots.
 *
 * @param volumeConsistencyGroup The consistency group.
 * @param snapshots The snapshots.
 * @param capabilities The requested capabilities.
 * @return The create task.
 */
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup volumeConsistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities) {
    DellSCDriverTask task = new DellSCDriverTask("createCGSnapshot");
    try {
        StorageCenterAPI api = connectionManager.getConnection(volumeConsistencyGroup.getStorageSystemId());
        // Make sure all of our volumes are active for the automated tests that try to
        // snap right away before writing anything to them.
        ScVolume[] volumes = api.getConsistencyGroupVolumes(volumeConsistencyGroup.getNativeId());
        for (ScVolume volume : volumes) {
            api.checkAndInitVolume(volume.instanceId);
        }
        ScReplay[] replays = api.createConsistencyGroupSnapshots(volumeConsistencyGroup.getNativeId());
        if (populateCgSnapshotInfo(snapshots, replays)) {
            task.setStatus(TaskStatus.READY);
        } else {
            task.setStatus(TaskStatus.PARTIALLY_FAILED);
        }
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error creating CG snapshots %s: %s", volumeConsistencyGroup.getDisplayName(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    return task;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) 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)

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