Search in sources :

Example 1 with Parameters

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

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

Example 3 with Parameters

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

Example 4 with Parameters

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

the class StorageCenterAPI method createServer.

/**
 * Create a new server definition.
 *
 * @param ssn The Storage Center system serial number.
 * @param hostName The host name.
 * @param isIscsi Whether it is iSCSI or FC.
 * @param osId The OS instance ID.
 * @return The created server.
 * @throws StorageCenterAPIException
 */
public ScPhysicalServer createServer(String ssn, String hostName, boolean isIscsi, String osId) throws StorageCenterAPIException {
    Parameters params = new Parameters();
    params.add("Name", hostName);
    params.add("StorageCenter", ssn);
    params.add("Notes", NOTES_STRING);
    params.add("OperatingSystem", osId);
    RestResult rr = restClient.post("StorageCenter/ScPhysicalServer", params.toJson());
    if (!checkResults(rr)) {
        String error = String.format("Error creating server '%s': %s", hostName, rr.getErrorMsg());
        throw new StorageCenterAPIException(error);
    }
    return gson.fromJson(rr.getResult(), ScPhysicalServer.class);
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 5 with Parameters

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

the class StorageCenterAPI method createMirror.

/**
 * Create a mirror from one volume to another.
 *
 * @param ssn The Storage Center to create the mirror.
 * @param srcId The source volume ID.
 * @param dstId The destination volume ID.
 * @return The CMM operation.
 * @throws StorageCenterAPIException
 */
public ScCopyMirrorMigrate createMirror(String ssn, String srcId, String dstId) throws StorageCenterAPIException {
    Parameters params = new Parameters();
    params.add("StorageCenter", ssn);
    params.add("SourceVolume", srcId);
    params.add("DestinationVolume", dstId);
    params.add("CopyReplays", false);
    RestResult rr = restClient.post("StorageCenter/ScCopyMirrorMigrate/Mirror", params.toJson());
    if (!checkResults(rr)) {
        String msg = String.format("Error creating mirror from %s to %s: %s", srcId, dstId, rr.getErrorMsg());
        LOG.warn(msg);
        throw new StorageCenterAPIException(msg);
    }
    return gson.fromJson(rr.getResult(), ScCopyMirrorMigrate.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