Search in sources :

Example 11 with ScVolume

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

the class StorageCenterAPI method deleteVolume.

/**
 * Delete a volume.
 *
 * If the volume can't be found we return success assuming the volume has been deleted
 * by some other means.
 *
 * @param instanceId the instance id of the volume.
 * @throws StorageCenterAPIException if error encountered deleting the volume.
 */
public void deleteVolume(String instanceId) throws StorageCenterAPIException {
    ScVolume vol = getVolume(instanceId);
    if (vol == null) {
        LOG.warn("Volume delete request for {}, volume not found. Assuming deleted.", instanceId);
        return;
    }
    RestResult rr = restClient.delete(String.format("StorageCenter/ScVolume/%s", instanceId));
    if (!checkResults(rr)) {
        String msg = String.format("Error deleting volume %s", instanceId);
        LOG.error(msg);
        throw new StorageCenterAPIException(msg);
    }
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 12 with ScVolume

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

the class StorageCenterAPI method getReplayProfileVolumes.

/**
 * Gets all volumes that are part of a replay profile.
 *
 * @param instanceId The replay profile instance ID.
 * @return The member volumes.
 * @throws StorageCenterAPIException
 */
public ScVolume[] getReplayProfileVolumes(String instanceId) throws StorageCenterAPIException {
    RestResult rr = restClient.get(String.format("StorageCenter/ScReplayProfile/%s/VolumeList", instanceId));
    if (checkResults(rr)) {
        return gson.fromJson(rr.getResult(), ScVolume[].class);
    }
    String message = "Unknown";
    if (rr.getErrorMsg().length() > 0) {
        message = rr.getErrorMsg();
    }
    message = String.format("Error getting replay profile member volumes: %s", message);
    throw new StorageCenterAPIException(message);
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) RestResult(com.emc.storageos.driver.dellsc.scapi.rest.RestResult)

Example 13 with ScVolume

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

the class DellSCConsistencyGroups method createConsistencyGroupSnapshot.

/**
 * Create consistency group snapshots.
 *
 * @param volumeConsistencyGroup The consistency group.
 * @param snapshots The snapshots.
 * @param capabilities The requested capabilities.
 * @return The create task.
 */
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup volumeConsistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities) {
    DellSCDriverTask task = new DellSCDriverTask("createCGSnapshot");
    try {
        StorageCenterAPI api = connectionManager.getConnection(volumeConsistencyGroup.getStorageSystemId());
        // Make sure all of our volumes are active for the automated tests that try to
        // snap right away before writing anything to them.
        ScVolume[] volumes = api.getConsistencyGroupVolumes(volumeConsistencyGroup.getNativeId());
        for (ScVolume volume : volumes) {
            api.checkAndInitVolume(volume.instanceId);
        }
        ScReplay[] replays = api.createConsistencyGroupSnapshots(volumeConsistencyGroup.getNativeId());
        if (populateCgSnapshotInfo(snapshots, replays)) {
            task.setStatus(TaskStatus.READY);
        } else {
            task.setStatus(TaskStatus.PARTIALLY_FAILED);
        }
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error creating CG snapshots %s: %s", volumeConsistencyGroup.getDisplayName(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    return task;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 14 with ScVolume

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

the class DellSCDiscovery method getStorageVolumes.

/**
 * Discover storage volumes.
 *
 * @param storageSystem The storage system on which to discover.
 * @param storageVolumes The discovered storage volumes.
 * @param token Used for paging. Input 0 indicates that the first page should be returned. Output 0 indicates
 *            that last page was returned
 * @return The discovery task.
 */
public DriverTask getStorageVolumes(StorageSystem storageSystem, List<StorageVolume> storageVolumes, MutableInt token) {
    LOG.info("Getting volumes from {}", storageSystem.getNativeId());
    DellSCDriverTask task = new DellSCDriverTask("getVolumes");
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageSystem.getNativeId());
        Map<ScReplayProfile, List<String>> cgInfo = util.getGCInfo(api, storageSystem.getNativeId());
        ScVolume[] volumes = api.getAllVolumes(storageSystem.getNativeId());
        for (ScVolume volume : volumes) {
            if (volume.inRecycleBin || volume.liveVolume || volume.cmmDestination || volume.replicationDestination) {
                continue;
            }
            StorageVolume driverVol = util.getStorageVolumeFromScVolume(api, volume, cgInfo);
            storageVolumes.add(driverVol);
        }
        task.setStatus(TaskStatus.READY);
    } catch (DellSCDriverException | StorageCenterAPIException e) {
        String msg = String.format("Error getting volume info: %s", e);
        LOG.warn(msg);
        task.setFailed(msg);
    }
    return task;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScReplayProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with ScVolume

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

the class DellSCMirroring method createVolumeMirror.

/**
 * Create volume mirrors.
 *
 * @param mirrors The volume mirrors to create.
 * @return The creation task.
 */
public DriverTask createVolumeMirror(List<VolumeMirror> mirrors) {
    LOG.info("Creating volume mirror");
    DriverTask task = new DellSCDriverTask("createVolumeMirror");
    StringBuilder errBuffer = new StringBuilder();
    int mirrorsCreated = 0;
    for (VolumeMirror mirror : mirrors) {
        LOG.debug("Creating mirror of volume {}", mirror.getParentId());
        String ssn = mirror.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            ScVolume srcVol = api.getVolume(mirror.getParentId());
            ScVolume destVol = api.createVolume(ssn, mirror.getDisplayName(), srcVol.storageType.instanceId, SizeUtil.byteToMeg(SizeUtil.sizeStrToBytes(srcVol.configuredSize)), null);
            ScCopyMirrorMigrate scCmm = api.createMirror(ssn, srcVol.instanceId, destVol.instanceId);
            mirror.setNativeId(scCmm.instanceId);
            mirror.setSyncState(SynchronizationState.COPYINPROGRESS);
            mirrorsCreated++;
            LOG.info("Created volume mirror '{}'", scCmm.instanceId);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error creating volume mirror %s: %s", mirror.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (mirrorsCreated == mirrors.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (mirrorsCreated == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) DriverTask(com.emc.storageos.storagedriver.DriverTask) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScCopyMirrorMigrate(com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror)

Aggregations

ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)17 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)11 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)11 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)10 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)8 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)5 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)4 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)4 DriverTask (com.emc.storageos.storagedriver.DriverTask)4 ArrayList (java.util.ArrayList)4 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)3 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)2 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)2 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)2 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)2 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)2 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)1