Search in sources :

Example 21 with DellSCDriverTask

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

the class DellSCDiscovery method discoverStoragePools.

/**
 * Discover storage pools and their capabilities.
 *
 * @param storageSystem The storage system on which to discover.
 * @param storagePools The storage pools.
 * @return The discovery task.
 */
public DriverTask discoverStoragePools(StorageSystem storageSystem, List<StoragePool> storagePools) {
    LOG.info("Discovering storage pools for [{}] {} {}", storageSystem.getSystemName(), storageSystem.getIpAddress(), storageSystem.getNativeId());
    DellSCDriverTask task = new DellSCDriverTask("discoverStoragePools");
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageSystem.getNativeId());
        ScStorageType[] storageTypes = api.getStorageTypes(storageSystem.getNativeId());
        for (ScStorageType storageType : storageTypes) {
            storagePools.add(util.getStoragePoolFromStorageType(api, storageType, null));
        }
        task.setStatus(DriverTask.TaskStatus.READY);
    } catch (Exception e) {
        String failureMessage = String.format("Error getting pool information: %s", e);
        task.setFailed(failureMessage);
        LOG.warn(failureMessage);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) ScStorageType(com.emc.storageos.driver.dellsc.scapi.objects.ScStorageType) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Example 22 with DellSCDriverTask

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

the class DellSCMirroring method deleteVolumeMirror.

/**
 * Delete volume mirror and the destination volume.
 *
 * @param mirror The mirror to delete.
 * @return The delete task.
 */
public DriverTask deleteVolumeMirror(VolumeMirror mirror) {
    LOG.info("Deleting volume mirror {}", mirror);
    DellSCDriverTask task = new DellSCDriverTask("deleteVolumeMirror");
    try {
        StorageCenterAPI api = connectionManager.getConnection(mirror.getStorageSystemId());
        ScCopyMirrorMigrate cmm = api.getMirror(mirror.getNativeId());
        api.deleteMirror(cmm.instanceId);
        api.deleteVolume(cmm.destinationVolume.instanceId);
        task.setStatus(TaskStatus.READY);
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error deleting volume mirror %s: %s", mirror.getNativeId(), 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) ScCopyMirrorMigrate(com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Example 23 with DellSCDriverTask

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

Example 24 with DellSCDriverTask

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

the class DellSCProvisioning method exportVolumesToInitiators.

/**
 * Export volumes to initiators through a given set of ports. If ports are
 * not provided, use port requirements from ExportPathsServiceOption
 * storage capability.
 *
 * @param initiators The initiators to export to.
 * @param volumes The volumes to export.
 * @param volumeToHLUMap Map of volume nativeID to requested HLU. HLU
 *            value of -1 means that HLU is not defined and will
 *            be assigned by array.
 * @param recommendedPorts List of storage ports recommended for the export.
 *            Optional.
 * @param availablePorts List of ports available for the export.
 * @param capabilities The storage capabilities.
 * @param usedRecommendedPorts True if driver used recommended and only
 *            recommended ports for the export, false
 *            otherwise.
 * @param selectedPorts Ports selected for the export (if recommended ports
 *            have not been used).
 * @return The export task.
 * @throws DellSCDriverException
 */
public DriverTask exportVolumesToInitiators(List<Initiator> initiators, List<StorageVolume> volumes, Map<String, String> volumeToHLUMap, List<StoragePort> recommendedPorts, List<StoragePort> availablePorts, StorageCapabilities capabilities, MutableBoolean usedRecommendedPorts, List<StoragePort> selectedPorts) {
    LOG.info("Exporting volumes to inititators");
    DellSCDriverTask task = new DellSCDriverTask("exportVolumes");
    ScServer server = null;
    List<ScServerHba> preferredHbas = new ArrayList<>();
    StringBuilder errBuffer = new StringBuilder();
    int volumesMapped = 0;
    Set<StoragePort> usedPorts = new HashSet<>();
    String preferredController = null;
    // Cache of controller port instance IDs to StoragePort objects
    Map<String, StoragePort> discoveredPorts = new HashMap<>();
    // See if a max port count has been specified
    int maxPaths = -1;
    List<ExportPathsServiceOption> pathOptions = capabilities.getCommonCapabilitis().getExportPathParams();
    for (ExportPathsServiceOption pathOption : pathOptions) {
        // List but appears to only ever have one option?
        maxPaths = pathOption.getMaxPath();
    }
    // Get the recommended server ports to use
    List<String> recommendedServerPorts = new ArrayList<>();
    for (StoragePort port : recommendedPorts) {
        recommendedServerPorts.add(port.getNativeId());
    }
    for (StorageVolume volume : volumes) {
        String ssn = volume.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            // Find our actual volume
            ScVolume scVol = null;
            int dotCount = StringUtils.countMatches(volume.getNativeId(), ".");
            if (dotCount == 2) {
                // Not actually a volume
                scVol = api.createReplayView(volume.getNativeId(), String.format("View of %s", volume.getNativeId()));
            } else {
                // Normal volume instance ID
                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 = createOrFindScServer(api, ssn, initiators, preferredHbas);
            }
            if (server == null) {
                // Unable to find or create the server, can't continue
                throw new DellSCDriverException(SERVER_CREATE_FAIL_MSG);
            }
            // See if we have a preferred controller
            if (preferredController == null && scVol.active) {
                // At least first volume is active somewhere, so we need to try to
                // use that controller for all mappings
                ScVolumeConfiguration volConfig = api.getVolumeConfig(scVol.instanceId);
                if (volConfig != null) {
                    preferredController = volConfig.controller.instanceId;
                }
            }
            // Next try to get a preferred controller based on what's requested
            if (preferredController == null && !recommendedPorts.isEmpty()) {
                try {
                    ScControllerPort scPort = api.getControllerPort(recommendedPorts.get(0).getNativeId());
                    preferredController = scPort.controller.instanceId;
                } catch (Exception e) {
                    LOG.warn("Failed to get recommended port controller.", e);
                }
            }
            int preferredLun = -1;
            if (volumeToHLUMap.containsKey(volume.getNativeId())) {
                String hlu = volumeToHLUMap.get(volume.getNativeId());
                try {
                    preferredLun = Integer.parseInt(hlu);
                } catch (NumberFormatException e) {
                    LOG.warn("Unable to parse preferred LUN {}", hlu);
                }
            }
            ScMappingProfile profile;
            // See if the volume is already mapped
            ScMappingProfile[] mappingProfiles = api.getServerVolumeMapping(scVol.instanceId, server.instanceId);
            if (mappingProfiles.length > 0) {
                // This one is already mapped
                profile = mappingProfiles[0];
            } else {
                profile = api.createVolumeMappingProfile(scVol.instanceId, server.instanceId, preferredLun, new String[0], maxPaths, preferredController);
            }
            ScMapping[] maps = api.getMappingProfileMaps(profile.instanceId);
            for (ScMapping map : maps) {
                volumeToHLUMap.put(volume.getNativeId(), String.valueOf(map.lun));
                StoragePort port;
                if (discoveredPorts.containsKey(map.controllerPort.instanceId)) {
                    port = discoveredPorts.get(map.controllerPort.instanceId);
                } else {
                    ScControllerPort scPort = api.getControllerPort(map.controllerPort.instanceId);
                    port = util.getStoragePortForControllerPort(api, scPort);
                    discoveredPorts.put(map.controllerPort.instanceId, port);
                }
                usedPorts.add(port);
            }
            volumesMapped++;
            LOG.info("Volume '{}' exported to server '{}'", scVol.name, server.name);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error mapping 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;
            }
        }
    }
    // See if we were able to use all of the recommended ports
    // TODO: Expand this to do more accurate checking
    usedRecommendedPorts.setValue(recommendedPorts.size() == usedPorts.size());
    if (!usedRecommendedPorts.isTrue()) {
        selectedPorts.addAll(usedPorts);
    }
    task.setMessage(errBuffer.toString());
    if (volumesMapped == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (volumesMapped == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) HashMap(java.util.HashMap) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ArrayList(java.util.ArrayList) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) ScVolumeConfiguration(com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeConfiguration) ScMapping(com.emc.storageos.driver.dellsc.scapi.objects.ScMapping) HashSet(java.util.HashSet) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) ScMappingProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ScServerHba(com.emc.storageos.driver.dellsc.scapi.objects.ScServerHba) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) ScControllerPort(com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort) ExportPathsServiceOption(com.emc.storageos.storagedriver.storagecapabilities.ExportPathsServiceOption)

Example 25 with DellSCDriverTask

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

the class DellSCProvisioning method deleteVolume.

/**
 * Delete volume.
 *
 * @param volume The volume to delete.
 * @return The volume deletion task.
 */
public DriverTask deleteVolume(StorageVolume volume) {
    DellSCDriverTask task = new DellSCDriverTask("deleteVolume");
    try {
        StorageCenterAPI api = connectionManager.getConnection(volume.getStorageSystemId());
        api.deleteVolume(volume.getNativeId());
        task.setStatus(TaskStatus.READY);
        LOG.info("Deleted volume '{}'", volume.getNativeId());
    } catch (DellSCDriverException | StorageCenterAPIException dex) {
        String error = String.format("Error deleting volume %s", volume.getNativeId(), 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) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Aggregations

DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)27 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)22 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)22 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)22 DriverTask (com.emc.storageos.storagedriver.DriverTask)10 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)8 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)6 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)3 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)3 ArrayList (java.util.ArrayList)3 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)2 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)2 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)2 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)2 StorageCenter (com.emc.storageos.driver.dellsc.scapi.objects.StorageCenter)2 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)2 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)2 List (java.util.List)2 EmDataCollector (com.emc.storageos.driver.dellsc.scapi.objects.EmDataCollector)1 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)1