Search in sources :

Example 1 with DellSCDriverException

use of com.emc.storageos.driver.dellsc.DellSCDriverException in project coprhd-controller by CoprHD.

the class DellSCCloning method createVolumeClone.

/**
 * Create a clone of a volume.
 *
 * @param clones The clones to create.
 * @return The clone task.
 */
public DriverTask createVolumeClone(List<VolumeClone> clones) {
    LOG.info("Creating volume clone");
    DellSCDriverTask task = new DellSCDriverTask("createVolumeClone");
    StringBuilder errBuffer = new StringBuilder();
    int createCount = 0;
    for (VolumeClone clone : clones) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(clone.getStorageSystemId());
            ScReplay replay = null;
            // Make sure volume is active for the automated tests that try to
            // create temporary snapshot to create the clone from after immediate volume creation
            api.checkAndInitVolume(clone.getParentId());
            if (clone.getSourceType() == SourceType.SNAPSHOT) {
                replay = api.getReplay(clone.getParentId());
            } else {
                // Create temporary replay to create the clone from
                replay = api.createReplay(clone.getParentId(), 5);
            }
            // Now create a new volume from the snapshot
            ScVolume scVol = api.createViewVolume(clone.getDisplayName(), replay.instanceId);
            clone.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
            // New volumes don't allocate any space
            clone.setAllocatedCapacity(0L);
            clone.setWwn(scVol.deviceId);
            clone.setNativeId(scVol.instanceId);
            clone.setDeviceLabel(scVol.name);
            clone.setAccessStatus(AccessStatus.READ_WRITE);
            clone.setReplicationState(ReplicationState.SYNCHRONIZED);
            createCount++;
        } catch (DellSCDriverException | StorageCenterAPIException dex) {
            String error = String.format("Error creating clone of volume %s: %s", clone.getParentId(), dex);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (createCount == clones.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (createCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    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) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 2 with DellSCDriverException

use of com.emc.storageos.driver.dellsc.DellSCDriverException in project coprhd-controller by CoprHD.

the class DellSCConnectionManager method getConnection.

/**
 * Get a connection from the saved settings.
 *
 * @param systemId The system ID of the connection.
 * @return The Storage Center API connection.
 * @throws DellSCDriverException on failure.
 */
public StorageCenterAPI getConnection(String systemId) throws DellSCDriverException {
    LOG.info("Getting saved connection information for {}", systemId);
    String key = systemLookup.get(systemId);
    if (key == null) {
        // Old connection information
        key = systemId;
    }
    try {
        Map<String, List<String>> connectionInfo = this.driverRegistry.getDriverAttributesForKey(DRIVER_NAME, key);
        return getConnection(connectionInfo.get(HOST_KEY).get(0), Integer.parseInt(connectionInfo.get(PORT_KEY).get(0)), connectionInfo.get(USER_KEY).get(0), connectionInfo.get(PASS_KEY).get(0), false);
    } catch (Exception e) {
        LOG.error(String.format("Error getting saved connection information: %s", e), e);
        throw new DellSCDriverException("Error getting saved connection information.", e);
    }
}
Also used : DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) List(java.util.List) ArrayList(java.util.ArrayList) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Example 3 with DellSCDriverException

use of com.emc.storageos.driver.dellsc.DellSCDriverException in project coprhd-controller by CoprHD.

the class DellSCConsistencyGroups method removeVolumesFromConsistencyGroup.

/**
 * Remove volumes from consistency groups.
 *
 * @param volumes The volumes.
 * @param capabilities The requested capabilities.
 * @return The driver task.
 */
public DriverTask removeVolumesFromConsistencyGroup(List<StorageVolume> volumes, StorageCapabilities capabilities) {
    DellSCDriverTask task = new DellSCDriverTask("removeVolumeFromCG");
    StringBuilder errBuffer = new StringBuilder();
    int removeCount = 0;
    for (StorageVolume volume : volumes) {
        String ssn = volume.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            api.removeVolumeFromConsistencyGroup(volume.getNativeId(), volume.getConsistencyGroup());
            removeCount++;
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error adding volume %s to consistency group: %s", volume.getNativeId(), dex);
            LOG.warn(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (removeCount == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (removeCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) 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)

Example 4 with DellSCDriverException

use of com.emc.storageos.driver.dellsc.DellSCDriverException in project coprhd-controller by CoprHD.

the class DellSCConsistencyGroups method deleteConsistencyGroup.

/**
 * Delete a consistency group.
 *
 * @param volumeConsistencyGroup The group to delete.
 * @return The consistency group delete task.
 */
public DriverTask deleteConsistencyGroup(VolumeConsistencyGroup volumeConsistencyGroup) {
    DellSCDriverTask task = new DellSCDriverTask("deleteVolume");
    try {
        StorageCenterAPI api = connectionManager.getConnection(volumeConsistencyGroup.getStorageSystemId());
        ScReplayProfile[] cgs = api.getConsistencyGroups(volumeConsistencyGroup.getStorageSystemId());
        for (ScReplayProfile cg : cgs) {
            if (cg.instanceId.equals(volumeConsistencyGroup.getNativeId())) {
                api.deleteConsistencyGroup(cg.instanceId);
                break;
            }
        }
        // We either deleted the CG or it was not found, either way we are fine
        task.setStatus(TaskStatus.READY);
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error deleting CG %s: %s", volumeConsistencyGroup.getDisplayName(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) 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)

Example 5 with DellSCDriverException

use of com.emc.storageos.driver.dellsc.DellSCDriverException in project coprhd-controller by CoprHD.

the class DellSCDiscovery method getVolumeMirrors.

/**
 * Gets all mirrors of a volume.
 *
 * @param storageVolume The volume.
 * @return The mirrors.
 */
public List<VolumeMirror> getVolumeMirrors(StorageVolume storageVolume) {
    LOG.info("Getting mirrors for volume {}", storageVolume.getNativeId());
    List<VolumeMirror> result = new ArrayList<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
        ScVolume scVolume = api.getVolume(storageVolume.getNativeId());
        if (scVolume != null && scVolume.cmmSource) {
            ScCopyMirrorMigrate[] cmms = api.getVolumeCopyMirrorMigrate(scVolume.instanceId);
            for (ScCopyMirrorMigrate cmm : cmms) {
                if ("Mirror".equals(cmm.type)) {
                    ScVolume targetVol = api.getVolume(cmm.destinationVolume.instanceId);
                    VolumeMirror mirror = new VolumeMirror();
                    mirror.setAccessStatus(AccessStatus.READ_WRITE);
                    mirror.setDeviceLabel(targetVol.name);
                    mirror.setDisplayName(targetVol.name);
                    mirror.setNativeId(targetVol.instanceId);
                    mirror.setParentId(cmm.sourceVolume.instanceId);
                    mirror.setStorageSystemId(storageVolume.getStorageSystemId());
                    SynchronizationState syncState = SynchronizationState.SYNCHRONIZED;
                    if (cmm.percentComplete != 100) {
                        syncState = SynchronizationState.COPYINPROGRESS;
                    }
                    mirror.setSyncState(syncState);
                    mirror.setWwn(targetVol.deviceId);
                    result.add(mirror);
                }
            }
        }
    } catch (DellSCDriverException e) {
        String msg = String.format("Error getting mirrors for volume %s", storageVolume.getNativeId(), e);
        LOG.warn(msg);
    }
    return result;
}
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) ScCopyMirrorMigrate(com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror) ArrayList(java.util.ArrayList) SynchronizationState(com.emc.storageos.storagedriver.model.VolumeMirror.SynchronizationState)

Aggregations

DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)22 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)21 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)20 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)18 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)10 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)6 ArrayList (java.util.ArrayList)5 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)4 DriverTask (com.emc.storageos.storagedriver.DriverTask)4 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)3 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)3 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)3 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)3 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)2 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)2 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)2 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)1