Search in sources :

Example 6 with RestResult

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

the class StorageCenterAPI method getServerOperatingSystems.

/**
 * Gets the OS types.
 *
 * @param ssn The Storage Center system serial number.
 * @param product The product to filter on or null.
 * @return The OS types.
 */
public ScServerOperatingSystem[] getServerOperatingSystems(String ssn, String product) {
    PayloadFilter filter = new PayloadFilter();
    filter.append("scSerialNumber", ssn);
    if (product != null && !product.isEmpty()) {
        filter.append("product", product, ValueFilterType.INCLUDESSTRING);
    }
    RestResult rr = restClient.post("StorageCenter/ScServerOperatingSystem/GetList", filter.toJson());
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScServerOperatingSystem[].class);
    }
    return new ScServerOperatingSystem[0];
}
Also used : RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult) PayloadFilter(com.emc.storageos.driver.dellsc.scapi.rest.PayloadFilter) ScServerOperatingSystem(com.emc.storageos.driver.dellsc.scapi.objects.ScServerOperatingSystem)

Example 7 with RestResult

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

the class StorageCenterAPI method getMirror.

/**
 * Gets a mirror operation.
 *
 * @param instanceId The CMM instance ID.
 * @return The CMM operation.
 * @throws StorageCenterAPIException
 */
public ScCopyMirrorMigrate getMirror(String instanceId) throws StorageCenterAPIException {
    RestResult rr = restClient.get(String.format("StorageCenter/ScCopyMirrorMigrate/%s", instanceId));
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScCopyMirrorMigrate.class);
    }
    String message = String.format("Error getting mirror operation: %s", rr.getErrorMsg());
    throw new StorageCenterAPIException(message);
}
Also used : RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 8 with RestResult

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

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

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

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