use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createVolume.
/**
* Creates a volume on the Storage Center.
*
* @param ssn The Storage Center SN on which to create the volume.
* @param name The volume name.
* @param storageType The storage type to use.
* @param sizeInGB The size in GB
* @param cgID The consistency group ID to add volume to or null.
* @return The Storage Center volume.
* @throws StorageCenterAPIException
*/
public ScVolume createVolume(String ssn, String name, String storageType, int sizeInGB, String cgID) throws StorageCenterAPIException {
LOG.debug("Creating {}GB volume: '{}'", sizeInGB, name);
String errorMessage = "";
Parameters params = new Parameters();
params.add("Name", name);
params.add("Notes", NOTES_STRING);
params.add("Size", String.format("%d MB", sizeInGB));
params.add("StorageCenter", ssn);
if (cgID != null && !cgID.isEmpty()) {
String[] ids = { cgID };
params.add("ReplayProfileList", ids);
}
ScStorageType[] storageTypes = getStorageTypes(ssn);
for (ScStorageType storType : storageTypes) {
if (storType.name.equals(storageType)) {
params.add("StorageType", storType.instanceId);
break;
}
}
try {
RestResult result = restClient.post("StorageCenter/ScVolume", params.toJson());
if (checkResults(result)) {
return gson.fromJson(result.getResult(), ScVolume.class);
}
} catch (Exception e) {
errorMessage = String.format("Error creating volume: %s", e);
LOG.warn(errorMessage);
}
if (errorMessage.length() == 0) {
errorMessage = String.format("Unable to create volume %s on SC %s", name, ssn);
}
throw new StorageCenterAPIException(errorMessage);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method deleteMirror.
/**
* Delete a mirror operation.
*
* @param instanceId The CMM instance ID.
* @throws StorageCenterAPIException
*/
public void deleteMirror(String instanceId) throws StorageCenterAPIException {
LOG.debug("Deleting mirror '{}'", instanceId);
RestResult rr = restClient.delete(String.format("StorageCenter/ScCopyMirrorMigrate/%s", instanceId));
if (!checkResults(rr)) {
String msg = String.format("Error deleting mirror %s: %s", instanceId, rr.getErrorMsg());
LOG.error(msg);
throw new StorageCenterAPIException(msg);
}
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method getVolumeSnapshots.
/**
* Gets all replays for a given volume.
*
* @param instanceId The volume instance ID.
* @return The volume's replays.
*/
public ScReplay[] getVolumeSnapshots(String instanceId) {
PayloadFilter filter = new PayloadFilter();
filter.append("createVolume", instanceId);
filter.append("active", false);
filter.append("markedForExpiration", false);
RestResult rr = restClient.post("StorageCenter/ScReplay/GetList", filter.toJson());
if (checkResults(rr)) {
return gson.fromJson(rr.getResult(), ScReplay[].class);
}
return new ScReplay[0];
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createReplayView.
/**
* Create a view volume of a replay.
*
* @param instanceId The replay instance ID.
* @param name The name to give the volume.
* @return The created volume.
* @throws StorageCenterAPIException
*/
public ScVolume createReplayView(String instanceId, String name) throws StorageCenterAPIException {
Parameters params = new Parameters();
params.add("Name", name);
params.add("Notes", instanceId);
RestResult rr = restClient.post(String.format("StorageCenter/ScReplay/%s/CreateView", instanceId), params.toJson());
if (!checkResults(rr)) {
LOG.warn("Error creating view volume of replay {}: {}", instanceId, rr.getErrorMsg());
throw new StorageCenterAPIException(rr.getErrorMsg());
}
return gson.fromJson(rr.getResult(), ScVolume.class);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createVolumeMappingProfile.
/**
* Maps a volume to a server.
*
* @param volInstanceId The volume instance ID.
* @param serverInstanceId The server instance ID.
* @param preferredLun The preferred LUN to use or -1 to let the system decided.
* @param preferredPorts The preferred server HBA ports to use.
* @param maxPathCount The maximum paths to map or -1 for no restriction.
* @param preferredController The preferred controller to map through or null.
* @return The created mapping profile.
* @throws StorageCenterAPIException
*/
public ScMappingProfile createVolumeMappingProfile(String volInstanceId, String serverInstanceId, int preferredLun, String[] preferredPorts, int maxPathCount, String preferredController) throws StorageCenterAPIException {
Parameters advancedParams = new Parameters();
advancedParams.add("MapToDownServerHbas", true);
if (preferredLun != -1) {
advancedParams.add("PreferredLun", preferredLun);
}
if (preferredPorts != null && preferredPorts.length > 0) {
advancedParams.add("PreferredServerHbaList", preferredPorts);
}
if (maxPathCount > 0) {
advancedParams.add("MaximumPathCount", maxPathCount);
}
if (preferredController != null) {
advancedParams.add("PreferredController", preferredController);
}
Parameters params = new Parameters();
params.add("server", serverInstanceId);
params.add("Advanced", advancedParams.getRawPayload());
RestResult rr = restClient.post(String.format("StorageCenter/ScVolume/%s/MapToServer", volInstanceId), params.toJson());
if (checkResults(rr)) {
return gson.fromJson(rr.getResult(), ScMappingProfile.class);
}
throw new StorageCenterAPIException(String.format("Error creating volume mapping: %s", rr.getErrorMsg()));
}
Aggregations