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.");
}
Aggregations