Search in sources :

Example 26 with RestResult

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

the class StorageCenterAPI method getVolumeConfig.

/**
 * Gets a volume's configuration.
 *
 * @param instanceId The volume instance ID.
 * @return The volume config.
 */
public ScVolumeConfiguration getVolumeConfig(String instanceId) {
    RestResult rr = restClient.get(String.format("StorageCenter/ScVolume/%s/VolumeConfiguration", instanceId));
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScVolumeConfiguration.class);
    }
    LOG.warn(String.format("Error getting volume configuration: %s", rr.getErrorMsg()));
    return null;
}
Also used : RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 27 with RestResult

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

the class StorageCenterAPI method addVolumeToConsistencyGroup.

/**
 * Adds a volume to a consistency group.
 *
 * @param instanceId The volume instance ID.
 * @param cgID The consistency group ID.
 * @throws StorageCenterAPIException
 */
public void addVolumeToConsistencyGroup(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);
        }
    }
    profiles.add(cgID);
    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 28 with RestResult

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

the class StorageCenterAPI method createReplay.

/**
 * Creates a replay on a volume.
 *
 * @param instanceId The volume instance ID.
 * @param expireTime The number of minutes before the snapshot expires.
 * @return The created replay.
 * @throws StorageCenterAPIException
 */
public ScReplay createReplay(String instanceId, int expireTime) throws StorageCenterAPIException {
    Parameters params = new Parameters();
    params.add("description", NOTES_STRING);
    params.add("expireTime", expireTime);
    RestResult rr = restClient.post(String.format("StorageCenter/ScVolume/%s/CreateReplay", instanceId), params.toJson());
    if (!checkResults(rr)) {
        String msg = String.format("Error creating replay %s: %s", instanceId, rr.getErrorMsg());
        LOG.warn(msg);
        throw new StorageCenterAPIException(msg);
    }
    return gson.fromJson(rr.getResult(), ScReplay.class);
}
Also used : Parameters(com.emc.storageos.driver.dellsc.scapi.rest.Parameters) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 29 with RestResult

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

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

the class StorageCenterAPI method getVolumeStorageUsage.

/**
 * Gets the storage consumption information for a volume.
 *
 * @param instanceId The volume instance ID.
 * @return The storage usage information.
 * @throws StorageCenterAPIException
 */
public ScVolumeStorageUsage getVolumeStorageUsage(String instanceId) throws StorageCenterAPIException {
    RestResult rr = restClient.get(String.format("StorageCenter/ScVolume/%s/StorageUsage", instanceId));
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScVolumeStorageUsage.class);
    }
    String message = "Unknown";
    if (rr.getErrorMsg().length() > 0) {
        message = rr.getErrorMsg();
    }
    message = String.format("Error getting storage usage for volume %s: %s", instanceId, message);
    throw new StorageCenterAPIException(message);
}
Also used : 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