Search in sources :

Example 6 with DellSCDriverException

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

the class DellSCDiscovery method getVolumeSnapshots.

/**
 * Gets all snapshots for a volume.
 *
 * @param storageVolume The volume.
 * @return The snapshots.
 */
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume storageVolume) {
    LOG.info("Getting snapshots for {}", storageVolume.getNativeId());
    List<VolumeSnapshot> result = new ArrayList<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
        ScReplay[] replays = api.getVolumeSnapshots(storageVolume.getNativeId());
        for (ScReplay replay : replays) {
            VolumeSnapshot snap = util.getVolumeSnapshotFromReplay(replay, null);
            result.add(snap);
        }
    } catch (DellSCDriverException e) {
        String msg = String.format("Error getting volume info: %s", e);
        LOG.warn(msg);
    }
    return result;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) ArrayList(java.util.ArrayList) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 7 with DellSCDriverException

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

the class DellSCMirroring method splitVolumeMirror.

/**
 * Delete volume mirror but leave the destination volume intact.
 *
 * @param mirrors The mirrors to split.
 * @return The split task.
 */
public DriverTask splitVolumeMirror(List<VolumeMirror> mirrors) {
    LOG.info("Splitting volume mirror");
    DellSCDriverTask task = new DellSCDriverTask("splitVolumeMirror");
    StringBuilder errBuffer = new StringBuilder();
    int mirrorSplit = 0;
    for (VolumeMirror mirror : mirrors) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(mirror.getStorageSystemId());
            api.deleteMirror(mirror.getNativeId());
            task.setStatus(TaskStatus.READY);
            mirrorSplit++;
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error splitting volume mirror %s: %s", mirror.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (mirrorSplit == mirrors.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (mirrorSplit == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    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) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror)

Example 8 with DellSCDriverException

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

the class DellSCProvisioning method getVolumeExportInfo.

/**
 * Gets the mapping information for a volume to initiators.
 *
 * @param volumeId The volume instance ID.
 * @param systemId The storage system ID.
 * @return The mapping details. Map of HostName:HostExportInfo
 */
public Map<String, HostExportInfo> getVolumeExportInfo(String volumeId, String systemId) {
    Map<String, HostExportInfo> result = new HashMap<>();
    Map<String, ScServer> serverCache = new HashMap<>();
    Map<String, Initiator> serverPortCache = new HashMap<>();
    Map<String, StoragePort> portCache = new HashMap<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(systemId);
        ScVolume scVol = api.getVolume(volumeId);
        if (scVol == null) {
            throw new DellSCDriverException(String.format("Volume %s could not be found.", volumeId));
        }
        ScMapping[] maps = api.getVolumeMaps(scVol.instanceId);
        for (ScMapping map : maps) {
            populateVolumeExportInfo(api, volumeId, map, result, serverCache, serverPortCache, portCache);
        }
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String message = String.format("Error getting export info for volume %s: %s", volumeId, dex);
        LOG.warn(message);
    }
    return result;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) HashMap(java.util.HashMap) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) Initiator(com.emc.storageos.storagedriver.model.Initiator) ScMapping(com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)

Example 9 with DellSCDriverException

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

the class DellSCProvisioning method unexportVolumesFromInitiators.

/**
 * Remove volume exports to initiators.
 *
 * @param initiators The initiators to remove from.
 * @param volumes The volumes to remove.
 * @return The unexport task.
 */
public DriverTask unexportVolumesFromInitiators(List<Initiator> initiators, List<StorageVolume> volumes) {
    LOG.info("Unexporting volumes from initiators");
    DriverTask task = new DellSCDriverTask("unexportVolumes");
    ScServer server = null;
    StringBuilder errBuffer = new StringBuilder();
    int volumesUnmapped = 0;
    for (StorageVolume volume : volumes) {
        String ssn = volume.getStorageSystemId();
        boolean isSnapshot = StringUtils.countMatches(volume.getNativeId(), ".") == 2;
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            // Find our actual volume
            ScVolume scVol = null;
            if (isSnapshot) {
                scVol = api.findReplayView(volume.getNativeId());
                // For snapshot views we can just delete the view
                if (scVol != null) {
                    api.deleteVolume(scVol.instanceId);
                    volumesUnmapped++;
                    continue;
                }
            } else {
                scVol = api.getVolume(volume.getNativeId());
            }
            if (scVol == null) {
                throw new DellSCDriverException(String.format("Unable to find volume %s", volume.getNativeId()));
            }
            // Look up the server if needed
            if (server == null) {
                server = findScServer(api, ssn, initiators);
            }
            if (server == null) {
                // Unable to find the server, can't continue
                throw new DellSCDriverException(SERVER_CREATE_FAIL_MSG);
            }
            ScMappingProfile[] mappingProfiles = api.findMappingProfiles(server.instanceId, scVol.instanceId);
            for (ScMappingProfile mappingProfile : mappingProfiles) {
                api.deleteMappingProfile(mappingProfile.instanceId);
            }
            volumesUnmapped++;
            LOG.info("Volume '{}' unexported from server '{}'", scVol.name, server.name);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error unmapping volume %s: %s", volume.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
            if (SERVER_CREATE_FAIL_MSG.equals(dex.getMessage())) {
                // Game over
                break;
            }
        }
    }
    task.setMessage(errBuffer.toString());
    if (volumesUnmapped == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (volumesUnmapped == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScMappingProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException)

Example 10 with DellSCDriverException

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

the class DellSCProvisioning method createVolumes.

/**
 * Create storage volumes with a given set of capabilities.
 * Before completion of the request, set all required data for provisioned
 * volumes in "volumes" parameter.
 *
 * @param volumes Input/output argument for volumes.
 * @param storageCapabilities Input argument for capabilities. Defines
 *            storage capabilities of volumes to create.
 * @return The volume creation task.
 */
public DriverTask createVolumes(List<StorageVolume> volumes, StorageCapabilities storageCapabilities) {
    DriverTask task = new DellSCDriverTask("createVolume");
    StringBuilder errBuffer = new StringBuilder();
    int volumesCreated = 0;
    for (StorageVolume volume : volumes) {
        LOG.debug("Creating volume {} on system {}", volume.getDisplayName(), volume.getStorageSystemId());
        String ssn = volume.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            ScVolume scVol = api.createVolume(ssn, volume.getDisplayName(), volume.getStoragePoolId(), SizeUtil.byteToMeg(volume.getRequestedCapacity()), volume.getConsistencyGroup());
            volume.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
            // New volumes don't allocate any space
            volume.setAllocatedCapacity(0L);
            volume.setWwn(scVol.deviceId);
            volume.setNativeId(scVol.instanceId);
            volume.setDeviceLabel(scVol.name);
            volume.setAccessStatus(AccessStatus.READ_WRITE);
            volumesCreated++;
            LOG.info("Created volume '{}'", scVol.name);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error creating volume %s: %s", volume.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (volumesCreated == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (volumesCreated == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) 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)

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