use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method getVolumeConfig.
/**
* Gets a volume's configuration.
*
* @param instanceId The volume instance ID.
* @return The volume config.
*/
public ScVolumeConfiguration getVolumeConfig(String instanceId) {
RestResult rr = restClient.get(String.format("StorageCenter/ScVolume/%s/VolumeConfiguration", instanceId));
if (checkResults(rr)) {
return gson.fromJson(rr.getResult(), ScVolumeConfiguration.class);
}
LOG.warn(String.format("Error getting volume configuration: %s", rr.getErrorMsg()));
return null;
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method addVolumeToConsistencyGroup.
/**
* Adds a volume to a consistency group.
*
* @param instanceId The volume instance ID.
* @param cgID The consistency group ID.
* @throws StorageCenterAPIException
*/
public void addVolumeToConsistencyGroup(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);
}
}
profiles.add(cgID);
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 createReplay.
/**
* Creates a replay on a volume.
*
* @param instanceId The volume instance ID.
* @param expireTime The number of minutes before the snapshot expires.
* @return The created replay.
* @throws StorageCenterAPIException
*/
public ScReplay createReplay(String instanceId, int expireTime) throws StorageCenterAPIException {
Parameters params = new Parameters();
params.add("description", NOTES_STRING);
params.add("expireTime", expireTime);
RestResult rr = restClient.post(String.format("StorageCenter/ScVolume/%s/CreateReplay", instanceId), params.toJson());
if (!checkResults(rr)) {
String msg = String.format("Error creating replay %s: %s", instanceId, rr.getErrorMsg());
LOG.warn(msg);
throw new StorageCenterAPIException(msg);
}
return gson.fromJson(rr.getResult(), ScReplay.class);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method setAddServerToCluster.
/**
* Move a server under a cluster.
*
* @param serverId The server instance ID.
* @param clusterId The cluster instance ID.
* @return True if successful, false otherwise.
*/
public boolean setAddServerToCluster(String serverId, String clusterId) {
Parameters params = new Parameters();
params.add("Parent", clusterId);
RestResult rr = restClient.post(String.format("StorageCenter/ScPhysicalServer/%s/AddToCluster", serverId), params.toJson());
return checkResults(rr);
}
use of com.emc.storageos.driver.dellsc.scapi.rest.RestResult in project coprhd-controller by CoprHD.
the class StorageCenterAPI method getVolumeStorageUsage.
/**
* Gets the storage consumption information for a volume.
*
* @param instanceId The volume instance ID.
* @return The storage usage information.
* @throws StorageCenterAPIException
*/
public ScVolumeStorageUsage getVolumeStorageUsage(String instanceId) throws StorageCenterAPIException {
RestResult rr = restClient.get(String.format("StorageCenter/ScVolume/%s/StorageUsage", instanceId));
if (checkResults(rr)) {
return gson.fromJson(rr.getResult(), ScVolumeStorageUsage.class);
}
String message = "Unknown";
if (rr.getErrorMsg().length() > 0) {
message = rr.getErrorMsg();
}
message = String.format("Error getting storage usage for volume %s: %s", instanceId, message);
throw new StorageCenterAPIException(message);
}
Aggregations