use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createServer.
/**
* Create a new server definition.
*
* @param ssn The Storage Center system serial number.
* @param hostName The host name.
* @param isIscsi Whether it is iSCSI or FC.
* @param osId The OS instance ID.
* @return The created server.
* @throws StorageCenterAPIException
*/
public ScPhysicalServer createServer(String ssn, String hostName, boolean isIscsi, String osId) throws StorageCenterAPIException {
Parameters params = new Parameters();
params.add("Name", hostName);
params.add("StorageCenter", ssn);
params.add("Notes", NOTES_STRING);
params.add("OperatingSystem", osId);
RestResult rr = restClient.post("StorageCenter/ScPhysicalServer", params.toJson());
if (!checkResults(rr)) {
String error = String.format("Error creating server '%s': %s", hostName, rr.getErrorMsg());
throw new StorageCenterAPIException(error);
}
return gson.fromJson(rr.getResult(), ScPhysicalServer.class);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method findServer.
/**
* Find a server definition.
*
* @param ssn The Storage Center SN on which to check.
* @param iqnOrWwn The WWN or IQN.
* @return The server definition.
*/
public ScServer findServer(String ssn, String iqnOrWwn) {
ScServer result = null;
ScServerHba hba = findServerHba(ssn, iqnOrWwn);
// If the initiator has been seen but never used to define a server it will have a null server
if (hba != null && hba.server != null) {
RestResult rr = restClient.get(String.format("StorageCenter/ScServer/%s", hba.server.instanceId));
if (checkResults(rr)) {
result = gson.fromJson(rr.getResult(), ScServer.class);
}
}
return result;
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createMirror.
/**
* Create a mirror from one volume to another.
*
* @param ssn The Storage Center to create the mirror.
* @param srcId The source volume ID.
* @param dstId The destination volume ID.
* @return The CMM operation.
* @throws StorageCenterAPIException
*/
public ScCopyMirrorMigrate createMirror(String ssn, String srcId, String dstId) throws StorageCenterAPIException {
Parameters params = new Parameters();
params.add("StorageCenter", ssn);
params.add("SourceVolume", srcId);
params.add("DestinationVolume", dstId);
params.add("CopyReplays", false);
RestResult rr = restClient.post("StorageCenter/ScCopyMirrorMigrate/Mirror", params.toJson());
if (!checkResults(rr)) {
String msg = String.format("Error creating mirror from %s to %s: %s", srcId, dstId, rr.getErrorMsg());
LOG.warn(msg);
throw new StorageCenterAPIException(msg);
}
return gson.fromJson(rr.getResult(), ScCopyMirrorMigrate.class);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult 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.");
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createConsistencyGroup.
/**
* Creates a new consistency group on the Storage Center.
*
* @param ssn The Storage Center on which to create the CG.
* @param name The name of the CG.
* @return The created consistency group.
* @throws StorageCenterAPIException
*/
public ScReplayProfile createConsistencyGroup(String ssn, String name) throws StorageCenterAPIException {
LOG.debug("Creating consistency group '{}'", name);
String errorMessage = "";
Parameters params = new Parameters();
params.add("Name", name);
params.add("Notes", NOTES_STRING);
params.add("Type", "Consistent");
params.add("StorageCenter", ssn);
try {
RestResult result = restClient.post("StorageCenter/ScReplayProfile", params.toJson());
if (checkResults(result)) {
return gson.fromJson(result.getResult(), ScReplayProfile.class);
}
errorMessage = String.format("Unable to create CG %s on SC %s: %s", name, ssn, result.getErrorMsg());
} catch (Exception e) {
errorMessage = String.format("Error creating consistency group: %s", e);
LOG.warn(errorMessage);
}
if (errorMessage.length() == 0) {
errorMessage = String.format("Unable to create CG %s on SC %s", name, ssn);
}
throw new StorageCenterAPIException(errorMessage);
}
Aggregations