Search in sources :

Example 36 with RestResult

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

the class StorageCenterAPI method createVolume.

/**
 * Creates a volume on the Storage Center.
 *
 * @param ssn The Storage Center SN on which to create the volume.
 * @param name The volume name.
 * @param storageType The storage type to use.
 * @param sizeInGB The size in GB
 * @param cgID The consistency group ID to add volume to or null.
 * @return The Storage Center volume.
 * @throws StorageCenterAPIException
 */
public ScVolume createVolume(String ssn, String name, String storageType, int sizeInGB, String cgID) throws StorageCenterAPIException {
    LOG.debug("Creating {}GB volume: '{}'", sizeInGB, name);
    String errorMessage = "";
    Parameters params = new Parameters();
    params.add("Name", name);
    params.add("Notes", NOTES_STRING);
    params.add("Size", String.format("%d MB", sizeInGB));
    params.add("StorageCenter", ssn);
    if (cgID != null && !cgID.isEmpty()) {
        String[] ids = { cgID };
        params.add("ReplayProfileList", ids);
    }
    ScStorageType[] storageTypes = getStorageTypes(ssn);
    for (ScStorageType storType : storageTypes) {
        if (storType.name.equals(storageType)) {
            params.add("StorageType", storType.instanceId);
            break;
        }
    }
    try {
        RestResult result = restClient.post("StorageCenter/ScVolume", params.toJson());
        if (checkResults(result)) {
            return gson.fromJson(result.getResult(), ScVolume.class);
        }
    } catch (Exception e) {
        errorMessage = String.format("Error creating volume: %s", e);
        LOG.warn(errorMessage);
    }
    if (errorMessage.length() == 0) {
        errorMessage = String.format("Unable to create volume %s on SC %s", name, ssn);
    }
    throw new StorageCenterAPIException(errorMessage);
}
Also used : ScStorageType(com.emc.storageos.driver.dellsc.scapi.objects.ScStorageType) Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 37 with RestResult

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

the class StorageCenterAPI method deleteMirror.

/**
 * Delete a mirror operation.
 *
 * @param instanceId The CMM instance ID.
 * @throws StorageCenterAPIException
 */
public void deleteMirror(String instanceId) throws StorageCenterAPIException {
    LOG.debug("Deleting mirror '{}'", instanceId);
    RestResult rr = restClient.delete(String.format("StorageCenter/ScCopyMirrorMigrate/%s", instanceId));
    if (!checkResults(rr)) {
        String msg = String.format("Error deleting mirror %s: %s", instanceId, rr.getErrorMsg());
        LOG.error(msg);
        throw new StorageCenterAPIException(msg);
    }
}
Also used : RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 38 with RestResult

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

the class StorageCenterAPI method getVolumeSnapshots.

/**
 * Gets all replays for a given volume.
 *
 * @param instanceId The volume instance ID.
 * @return The volume's replays.
 */
public ScReplay[] getVolumeSnapshots(String instanceId) {
    PayloadFilter filter = new PayloadFilter();
    filter.append("createVolume", instanceId);
    filter.append("active", false);
    filter.append("markedForExpiration", false);
    RestResult rr = restClient.post("StorageCenter/ScReplay/GetList", filter.toJson());
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScReplay[].class);
    }
    return new ScReplay[0];
}
Also used : RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) PayloadFilter(com.emc.storageos.driver.dellsc.scapi.rest.PayloadFilter) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 39 with RestResult

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

the class StorageCenterAPI method createReplayView.

/**
 * Create a view volume of a replay.
 *
 * @param instanceId The replay instance ID.
 * @param name The name to give the volume.
 * @return The created volume.
 * @throws StorageCenterAPIException
 */
public ScVolume createReplayView(String instanceId, String name) throws StorageCenterAPIException {
    Parameters params = new Parameters();
    params.add("Name", name);
    params.add("Notes", instanceId);
    RestResult rr = restClient.post(String.format("StorageCenter/ScReplay/%s/CreateView", instanceId), params.toJson());
    if (!checkResults(rr)) {
        LOG.warn("Error creating view volume of replay {}: {}", instanceId, rr.getErrorMsg());
        throw new StorageCenterAPIException(rr.getErrorMsg());
    }
    return gson.fromJson(rr.getResult(), ScVolume.class);
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 40 with RestResult

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

the class StorageCenterAPI method createVolumeMappingProfile.

/**
 * Maps a volume to a server.
 *
 * @param volInstanceId The volume instance ID.
 * @param serverInstanceId The server instance ID.
 * @param preferredLun The preferred LUN to use or -1 to let the system decided.
 * @param preferredPorts The preferred server HBA ports to use.
 * @param maxPathCount The maximum paths to map or -1 for no restriction.
 * @param preferredController The preferred controller to map through or null.
 * @return The created mapping profile.
 * @throws StorageCenterAPIException
 */
public ScMappingProfile createVolumeMappingProfile(String volInstanceId, String serverInstanceId, int preferredLun, String[] preferredPorts, int maxPathCount, String preferredController) throws StorageCenterAPIException {
    Parameters advancedParams = new Parameters();
    advancedParams.add("MapToDownServerHbas", true);
    if (preferredLun != -1) {
        advancedParams.add("PreferredLun", preferredLun);
    }
    if (preferredPorts != null && preferredPorts.length > 0) {
        advancedParams.add("PreferredServerHbaList", preferredPorts);
    }
    if (maxPathCount > 0) {
        advancedParams.add("MaximumPathCount", maxPathCount);
    }
    if (preferredController != null) {
        advancedParams.add("PreferredController", preferredController);
    }
    Parameters params = new Parameters();
    params.add("server", serverInstanceId);
    params.add("Advanced", advancedParams.getRawPayload());
    RestResult rr = restClient.post(String.format("StorageCenter/ScVolume/%s/MapToServer", volInstanceId), params.toJson());
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScMappingProfile.class);
    }
    throw new StorageCenterAPIException(String.format("Error creating volume mapping: %s", rr.getErrorMsg()));
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Aggregations

RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)44 Parameters (com.emc.storageos.driver.dellsc.scapi.rest.Parameters)16 PayloadFilter (com.emc.storageos.driver.dellsc.scapi.rest.PayloadFilter)12 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)4 ScServerHba (com.emc.storageos.driver.dellsc.scapi.objects.ScServerHba)3 ScVolumeConfiguration (com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeConfiguration)3 ArrayList (java.util.ArrayList)3 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)2 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)2 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)2 ScObject (com.emc.storageos.driver.dellsc.scapi.objects.ScObject)2 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)2 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)2 ScStorageType (com.emc.storageos.driver.dellsc.scapi.objects.ScStorageType)2 ScFaultDomain (com.emc.storageos.driver.dellsc.scapi.objects.ScFaultDomain)1 ScReplayConsistencyGroup (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayConsistencyGroup)1 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)1 ScServerOperatingSystem (com.emc.storageos.driver.dellsc.scapi.objects.ScServerOperatingSystem)1