Search in sources :

Example 16 with RestResult

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

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

the class StorageCenterAPI method findServer.

/**
 * Find a server definition.
 *
 * @param ssn The Storage Center SN on which to check.
 * @param iqnOrWwn The WWN or IQN.
 * @return The server definition.
 */
public ScServer findServer(String ssn, String iqnOrWwn) {
    ScServer result = null;
    ScServerHba hba = findServerHba(ssn, iqnOrWwn);
    // If the initiator has been seen but never used to define a server it will have a null server
    if (hba != null && hba.server != null) {
        RestResult rr = restClient.get(String.format("StorageCenter/ScServer/%s", hba.server.instanceId));
        if (checkResults(rr)) {
            result = gson.fromJson(rr.getResult(), ScServer.class);
        }
    }
    return result;
}
Also used : ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) ScServerHba(com.emc.storageos.driver.dellsc.scapi.objects.ScServerHba)

Example 18 with RestResult

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

Example 19 with RestResult

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

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

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