Search in sources :

Example 1 with ScObject

use of com.emc.storageos.driver.dellsc.scapi.objects.ScObject 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()));
    }
}
Also used : ScVolumeConfiguration(com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeConfiguration) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) ArrayList(java.util.ArrayList) ScObject(com.emc.storageos.driver.dellsc.scapi.objects.ScObject)

Example 2 with ScObject

use of com.emc.storageos.driver.dellsc.scapi.objects.ScObject 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()));
    }
}
Also used : ScVolumeConfiguration(com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeConfiguration) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) ArrayList(java.util.ArrayList) ScObject(com.emc.storageos.driver.dellsc.scapi.objects.ScObject)

Aggregations

ScObject (com.emc.storageos.driver.dellsc.scapi.objects.ScObject)2 ScVolumeConfiguration (com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeConfiguration)2 Parameters (com.emc.storageos.driver.dellsc.scapi.rest.Parameters)2 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)2 ArrayList (java.util.ArrayList)2