use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method getServerOperatingSystems.
/**
* Gets the OS types.
*
* @param ssn The Storage Center system serial number.
* @param product The product to filter on or null.
* @return The OS types.
*/
public ScServerOperatingSystem[] getServerOperatingSystems(String ssn, String product) {
PayloadFilter filter = new PayloadFilter();
filter.append("scSerialNumber", ssn);
if (product != null && !product.isEmpty()) {
filter.append("product", product, ValueFilterType.INCLUDESSTRING);
}
RestResult rr = restClient.post("StorageCenter/ScServerOperatingSystem/GetList", filter.toJson());
if (checkResults(rr)) {
return gson.fromJson(rr.getResult(), ScServerOperatingSystem[].class);
}
return new ScServerOperatingSystem[0];
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method getMirror.
/**
* Gets a mirror operation.
*
* @param instanceId The CMM instance ID.
* @return The CMM operation.
* @throws StorageCenterAPIException
*/
public ScCopyMirrorMigrate getMirror(String instanceId) throws StorageCenterAPIException {
RestResult rr = restClient.get(String.format("StorageCenter/ScCopyMirrorMigrate/%s", instanceId));
if (checkResults(rr)) {
return gson.fromJson(rr.getResult(), ScCopyMirrorMigrate.class);
}
String message = String.format("Error getting mirror operation: %s", rr.getErrorMsg());
throw new StorageCenterAPIException(message);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method removeVolumeFromConsistencyGroup.
/**
* Removes a volume from a consistency group.
*
* @param instanceId The volume instance ID.
* @param cgID The consistency group ID.
* @throws StorageCenterAPIException
*/
public void removeVolumeFromConsistencyGroup(String instanceId, String cgID) throws StorageCenterAPIException {
RestResult rr = restClient.get(String.format("StorageCenter/ScVolumeConfiguration/%s", instanceId));
if (!checkResults(rr)) {
throw new StorageCenterAPIException(String.format("Error getting volume configuration: %s", rr.getErrorMsg()));
}
ScVolumeConfiguration volConfig = gson.fromJson(rr.getResult(), ScVolumeConfiguration.class);
List<String> profiles = new ArrayList<>();
for (ScObject profile : volConfig.replayProfileList) {
if (!cgID.equals(profile.instanceId)) {
profiles.add(profile.instanceId);
}
}
Parameters params = new Parameters();
params.add("ReplayProfileList", profiles.toArray(new String[0]));
rr = restClient.put(String.format("StorageCenter/ScVolumeConfiguration/%s", instanceId), params.toJson());
if (!checkResults(rr)) {
throw new StorageCenterAPIException(String.format("Error updating volume replay profile membership: %s", rr.getErrorMsg()));
}
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method createViewVolume.
/**
* Creates a volume from a snapshot.
*
* @param name The name for the new volume.
* @param instanceId The replay instance ID.
* @return The created volume.
* @throws StorageCenterAPIException
*/
public ScVolume createViewVolume(String name, String instanceId) throws StorageCenterAPIException {
LOG.debug("Creating view volume of replay {}", instanceId);
String errorMessage = "";
Parameters params = new Parameters();
params.add("Name", name);
params.add("Notes", NOTES_STRING);
try {
RestResult result = restClient.post(String.format("StorageCenter/ScReplay/%s/CreateView", instanceId), params.toJson());
if (checkResults(result)) {
return gson.fromJson(result.getResult(), ScVolume.class);
}
} catch (Exception e) {
errorMessage = String.format("Error creating view volume: %s", e);
LOG.warn(errorMessage);
}
if (errorMessage.length() == 0) {
errorMessage = String.format("Unable to create view volume %s from replay %s", name, instanceId);
}
throw new StorageCenterAPIException(errorMessage);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method expandVolume.
/**
* Expand a volume to a larger size.
*
* @param instanceId The volume instance ID.
* @param newSize The new size.
* @return The ScVolume object.
* @throws StorageCenterAPIException
*/
public ScVolume expandVolume(String instanceId, int newSize) throws StorageCenterAPIException {
LOG.debug("Expanding volume '{}' to {}GB", instanceId, newSize);
Parameters params = new Parameters();
params.add("NewSize", String.format("%d MB", newSize));
try {
RestResult result = restClient.post(String.format("StorageCenter/ScVolume/%s/ExpandToSize", instanceId), params.toJson());
if (checkResults(result)) {
return gson.fromJson(result.getResult(), ScVolume.class);
}
throw new StorageCenterAPIException(String.format("Failed to expande volume: %s", result.getErrorMsg()));
} catch (Exception e) {
LOG.warn(String.format("Error expanding volume: %s", e));
throw new StorageCenterAPIException("Error expanding volume", e);
}
}
Aggregations