Search in sources :

Example 6 with Parameters

use of com.emc.storageos.driver.dellsc.scapi.rest.Parameters 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.");
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) ScReplayConsistencyGroup(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayConsistencyGroup) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 7 with Parameters

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

Example 8 with Parameters

use of com.emc.storageos.driver.dellsc.scapi.rest.Parameters in project coprhd-controller by CoprHD.

the class StorageCenterAPI method createClusterServer.

/**
 * Creates a new cluster server definition.
 *
 * @param ssn The Storage Center serial number.
 * @param clusterName The cluster name.
 * @param osId The OS instance ID.
 * @return The created server.
 * @throws StorageCenterAPIException
 */
public ScServer createClusterServer(String ssn, String clusterName, String osId) throws StorageCenterAPIException {
    Parameters params = new Parameters();
    params.add("Name", clusterName);
    params.add("StorageCenter", ssn);
    params.add("Notes", NOTES_STRING);
    params.add("OperatingSystem", osId);
    RestResult rr = restClient.post("StorageCenter/ScServerCluster", params.toJson());
    if (!checkResults(rr)) {
        String error = String.format("Error creating cluster server '%s': %s", clusterName, rr.getErrorMsg());
        throw new StorageCenterAPIException(error);
    }
    return gson.fromJson(rr.getResult(), ScServer.class);
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 9 with Parameters

use of com.emc.storageos.driver.dellsc.scapi.rest.Parameters 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)

Example 10 with Parameters

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

Aggregations

Parameters (com.emc.storageos.driver.dellsc.scapi.rest.Parameters)16 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)16 ScObject (com.emc.storageos.driver.dellsc.scapi.objects.ScObject)2 ScVolumeConfiguration (com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeConfiguration)2 ArrayList (java.util.ArrayList)2 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)1 ScReplayConsistencyGroup (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayConsistencyGroup)1 ScStorageType (com.emc.storageos.driver.dellsc.scapi.objects.ScStorageType)1