Search in sources :

Example 1 with ScReplayConsistencyGroup

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

Aggregations

ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)1 ScReplayConsistencyGroup (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayConsistencyGroup)1 Parameters (com.emc.storageos.driver.dellsc.scapi.rest.Parameters)1 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)1