Search in sources :

Example 11 with Parameters

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

Example 12 with Parameters

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

the class StorageCenterAPI method addHbaToServer.

/**
 * Add an HBA to a server definition.
 *
 * @param instanceId The server instance ID.
 * @param iqnOrWwn The IQN or WWN to add.
 * @param isIscsi Whether it is iSCSI or FC.
 * @return The added ScServerHba.
 */
public ScServerHba addHbaToServer(String instanceId, String iqnOrWwn, boolean isIscsi) {
    Parameters params = new Parameters();
    params.add("HbaPortType", isIscsi ? "Iscsi" : "FibreChannel");
    params.add("WwnOrIscsiName", iqnOrWwn);
    params.add("AllowManual", true);
    RestResult rr = restClient.post(String.format("StorageCenter/ScPhysicalServer/%s/AddHba", instanceId), params.toJson());
    if (!checkResults(rr)) {
        LOG.warn("Error adding HBA to server {}", rr.getErrorMsg());
        return null;
    }
    return gson.fromJson(rr.getResult(), ScServerHba.class);
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 13 with Parameters

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

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

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

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