Search in sources :

Example 16 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method preparePorts.

private void preparePorts(StorageSystem storage, URI exportMaskUri, List<URI> targetURIList, List<StoragePort> recommendedPorts, List<StoragePort> availablePorts, Map<String, com.emc.storageos.db.client.model.StoragePort> nativeIdToAvailablePortMap) {
    Iterator<com.emc.storageos.db.client.model.StoragePort> ports = dbClient.queryIterativeObjects(com.emc.storageos.db.client.model.StoragePort.class, targetURIList);
    while (ports.hasNext()) {
        StoragePort driverPort = createDriverPort(storage, ports.next());
        recommendedPorts.add(driverPort);
    }
    List<ExportGroup> exportGroups = ExportUtils.getExportGroupsForMask(exportMaskUri, dbClient);
    URI varrayUri = exportGroups.get(0).getVirtualArray();
    List<com.emc.storageos.db.client.model.StoragePort> varrayPorts = getStorageSystemVarrayStoragePorts(storage, varrayUri);
    for (com.emc.storageos.db.client.model.StoragePort port : varrayPorts) {
        if (port.getNativeId() != null) {
            nativeIdToAvailablePortMap.put(port.getNativeId(), port);
        } else {
            // This is error condition. Each port for driver managed systems should have nativeId set at
            // discovery time.
            String errorMsg = String.format("No nativeId defined for port: storage system: %s, storagePort: %s .", storage.getId(), port.getId());
            log.error(errorMsg);
            throw ExternalDeviceException.exceptions.noNativeIdDefinedForPort(storage.getNativeId(), port.getId().toString());
        }
        StoragePort driverPort = createDriverPort(storage, port);
        availablePorts.add(driverPort);
    }
}
Also used : StoragePort(com.emc.storageos.storagedriver.model.StoragePort) URI(java.net.URI) ExportGroup(com.emc.storageos.db.client.model.ExportGroup)

Example 17 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method createExportMask.

@Override
public void createExportMask(StorageSystem storage, URI exportMaskUri, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<com.emc.storageos.db.client.model.Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} createExportMask START...", storage.getSerialNumber());
    try {
        log.info("createExportMask: Export mask id: {}", exportMaskUri);
        log.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
        log.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
        log.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
        BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
        ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
        // Get export group uri from task completer
        URI exportGroupUri = taskCompleter.getId();
        ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
        Set<URI> volumeUris = new HashSet<>();
        for (VolumeURIHLU volumeURIHLU : volumeURIHLUs) {
            URI volumeURI = volumeURIHLU.getVolumeURI();
            volumeUris.add(volumeURI);
        }
        // Prepare volumes
        List<StorageVolume> driverVolumes = new ArrayList<>();
        Map<String, String> driverVolumeToHLUMap = new HashMap<>();
        Map<String, URI> volumeNativeIdToUriMap = new HashMap<>();
        prepareVolumes(storage, volumeURIHLUs, driverVolumes, driverVolumeToHLUMap, volumeNativeIdToUriMap);
        // Prepare initiators
        List<Initiator> driverInitiators = new ArrayList<>();
        prepareInitiators(initiatorList, exportGroup.forCluster(), driverInitiators);
        // Prepare target storage ports
        List<StoragePort> recommendedPorts = new ArrayList<>();
        List<StoragePort> availablePorts = new ArrayList<>();
        List<StoragePort> selectedPorts = new ArrayList<>();
        // Prepare ports for driver call. Populate lists of recommended and available ports.
        Map<String, com.emc.storageos.db.client.model.StoragePort> nativeIdToAvailablePortMap = new HashMap<>();
        preparePorts(storage, exportMaskUri, targetURIList, recommendedPorts, availablePorts, nativeIdToAvailablePortMap);
        ExportPathParams pathParams = blockScheduler.calculateExportPathParamForVolumes(volumeUris, exportGroup.getNumPaths(), storage.getId(), exportGroupUri);
        StorageCapabilities capabilities = new StorageCapabilities();
        // Prepare num paths to send to driver
        prepareCapabilities(pathParams, capabilities);
        MutableBoolean usedRecommendedPorts = new MutableBoolean(true);
        // Ready to call driver
        DriverTask task = driver.exportVolumesToInitiators(driverInitiators, driverVolumes, driverVolumeToHLUMap, recommendedPorts, availablePorts, capabilities, usedRecommendedPorts, selectedPorts);
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            // If driver used recommended ports, we are done.
            // Otherwise, if driver did not use recommended ports, we have to get ports selected by driver
            // and use them in export mask and zones.
            // We will verify driver selected ports against available ports list.
            String msg = String.format("createExportMask -- Created export: %s . Used recommended ports: %s .", task.getMessage(), usedRecommendedPorts);
            log.info(msg);
            log.info("Recommended ports: {}", recommendedPorts);
            log.info("Available ports: {}", availablePorts);
            log.info("Selected ports: {}", selectedPorts);
            if (usedRecommendedPorts.isFalse()) {
                // process driver selected ports
                if (validateSelectedPorts(availablePorts, selectedPorts, pathParams.getMinPaths())) {
                    List<com.emc.storageos.db.client.model.StoragePort> selectedPortsForMask = new ArrayList<>();
                    for (StoragePort driverPort : selectedPorts) {
                        com.emc.storageos.db.client.model.StoragePort port = nativeIdToAvailablePortMap.get(driverPort.getNativeId());
                        selectedPortsForMask.add(port);
                    }
                    updateStoragePortsInExportMask(exportMask, exportGroup, selectedPortsForMask);
                    // Update volumes Lun Ids in export mask based on driver selection
                    for (String volumeNativeId : driverVolumeToHLUMap.keySet()) {
                        String targetLunId = driverVolumeToHLUMap.get(volumeNativeId);
                        URI volumeUri = volumeNativeIdToUriMap.get(volumeNativeId);
                        exportMask.getVolumes().put(volumeUri.toString(), targetLunId);
                    }
                    dbClient.updateObject(exportMask);
                    taskCompleter.ready(dbClient);
                } else {
                    // selected ports are not valid. failure
                    String errorMsg = "createExportMask -- Ports selected by driver failed validation.";
                    log.error("createExportMask -- Ports selected by driver failed validation.");
                    ServiceError serviceError = ExternalDeviceException.errors.createExportMaskFailed("createExportMask", errorMsg);
                    taskCompleter.error(dbClient, serviceError);
                }
            } else {
                // Update volumes Lun Ids in export mask based on driver selection
                for (String volumeNativeId : driverVolumeToHLUMap.keySet()) {
                    String targetLunId = driverVolumeToHLUMap.get(volumeNativeId);
                    URI volumeUri = volumeNativeIdToUriMap.get(volumeNativeId);
                    exportMask.getVolumes().put(volumeUri.toString(), targetLunId);
                }
                dbClient.updateObject(exportMask);
                taskCompleter.ready(dbClient);
            }
        } else {
            String errorMsg = String.format("createExportMask -- Failed to create export: %s .", task.getMessage());
            log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createExportMaskFailed("createExportMask", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception ex) {
        log.error("Problem in createExportMask: ", ex);
        log.error("createExportMask -- Failed to create export mask. ", ex);
        ServiceError serviceError = ExternalDeviceException.errors.createExportMaskFailed("createExportMask", ex.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} createExportMask END...", storage.getSerialNumber());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) StorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.StorageCapabilities) Initiator(com.emc.storageos.storagedriver.model.Initiator) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) HashSet(java.util.HashSet) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams)

Example 18 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method addVolumes.

@Override
public void addVolumes(StorageSystem storage, URI exportMaskUri, VolumeURIHLU[] volumeURIHLUs, List<com.emc.storageos.db.client.model.Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} addVolumes START...", storage.getSerialNumber());
    try {
        log.info("addVolumes: Export mask id: {}", exportMaskUri);
        log.info("addVolumes: New volumes to add: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
        if (initiatorList != null) {
            log.info("addVolumes: initiators: {}", Joiner.on(',').join(initiatorList));
        }
        BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
        ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
        StringSet maskInitiators = exportMask.getInitiators();
        List<String> maskInitiatorList = new ArrayList<>();
        for (String initiatorUri : maskInitiators) {
            maskInitiatorList.add(initiatorUri);
        }
        log.info("Export mask existing initiators: {} ", Joiner.on(',').join(maskInitiatorList));
        StringSet storagePorts = exportMask.getStoragePorts();
        List<URI> portList = new ArrayList<>();
        for (String portUri : storagePorts) {
            portList.add(URI.create(portUri));
        }
        log.info("Export mask existing storage ports: {} ", Joiner.on(',').join(portList));
        // Get export group uri from task completer
        URI exportGroupUri = taskCompleter.getId();
        ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
        Set<URI> volumeUris = new HashSet<>();
        for (VolumeURIHLU volumeURIHLU : volumeURIHLUs) {
            URI volumeURI = volumeURIHLU.getVolumeURI();
            volumeUris.add(volumeURI);
        }
        // Prepare volumes. We send to driver only new volumes for the export mask.
        List<StorageVolume> driverVolumes = new ArrayList<>();
        Map<String, String> driverVolumeToHLUMap = new HashMap<>();
        Map<String, URI> volumeNativeIdToUriMap = new HashMap<>();
        prepareVolumes(storage, volumeURIHLUs, driverVolumes, driverVolumeToHLUMap, volumeNativeIdToUriMap);
        // Prepare initiators
        Set<com.emc.storageos.db.client.model.Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(dbClient, exportMask, null);
        List<Initiator> driverInitiators = new ArrayList<>();
        prepareInitiators(initiators, exportGroup.forCluster(), driverInitiators);
        // Prepare target storage ports
        List<StoragePort> recommendedPorts = new ArrayList<>();
        List<StoragePort> availablePorts = new ArrayList<>();
        List<StoragePort> selectedPorts = new ArrayList<>();
        // Prepare ports for driver call. Populate lists of recommended and available ports.
        Map<String, com.emc.storageos.db.client.model.StoragePort> nativeIdToAvailablePortMap = new HashMap<>();
        // We use existing ports in the mask as recommended ports.
        preparePorts(storage, exportMaskUri, portList, recommendedPorts, availablePorts, nativeIdToAvailablePortMap);
        log.info("varray ports: {}", nativeIdToAvailablePortMap);
        // For add volumes to existing export mask, we do not allow storage port change in the mask.
        // Only ports in the mask are available for driver call.
        availablePorts = recommendedPorts;
        ExportPathParams pathParams = blockScheduler.calculateExportPathParamForVolumes(volumeUris, exportGroup.getNumPaths(), storage.getId(), exportGroupUri);
        StorageCapabilities capabilities = new StorageCapabilities();
        // Prepare num paths to send to driver
        prepareCapabilities(pathParams, capabilities);
        MutableBoolean usedRecommendedPorts = new MutableBoolean(true);
        // Ready to call driver
        DriverTask task = driver.exportVolumesToInitiators(driverInitiators, driverVolumes, driverVolumeToHLUMap, recommendedPorts, availablePorts, capabilities, usedRecommendedPorts, selectedPorts);
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("Created export for volumes: %s . Used recommended ports: %s .", task.getMessage(), usedRecommendedPorts);
            log.info(msg);
            log.info("Driver selected storage ports: {} ", Joiner.on(',').join(selectedPorts));
            // auto san zoning is enabled, we will fail the request.
            if (usedRecommendedPorts.isFalse() && !selectedPorts.containsAll(recommendedPorts)) {
                // for auto san zoning enabled we can not support case when selected ports do not include ports which are already in the mask
                VirtualArray varray = dbClient.queryObject(VirtualArray.class, exportGroup.getVirtualArray());
                log.info("AutoSanZoning for varray {} is {} ", varray.getLabel(), varray.getAutoSanZoning());
                if (varray.getAutoSanZoning()) {
                    String errorMsg = String.format("AutoSanZoning is enabled and driver selected ports do not contain ports from the export mask: %s .", task.getMessage());
                    log.error(errorMsg);
                    ServiceError serviceError = ExternalDeviceException.errors.addVolumesToExportMaskFailed("addVolumes", errorMsg);
                    taskCompleter.error(dbClient, serviceError);
                } else {
                    // auto san zoning is disabled --- add new selected ports to the mask
                    // we do not care about zoning map in this case
                    List<com.emc.storageos.db.client.model.StoragePort> selectedPortsForMask = new ArrayList<>();
                    for (StoragePort driverPort : selectedPorts) {
                        log.info("Driver selected port: {}", driverPort);
                        com.emc.storageos.db.client.model.StoragePort port = nativeIdToAvailablePortMap.get(driverPort.getNativeId());
                        if (port != null) {
                            // add all ports, StringSet in the mask will ignore duplicates
                            log.info("System port: {}", port);
                            selectedPortsForMask.add(port);
                        }
                    }
                    for (com.emc.storageos.db.client.model.StoragePort port : selectedPortsForMask) {
                        exportMask.addTarget(port.getId());
                    }
                    dbClient.updateObject(exportMask);
                    taskCompleter.ready(dbClient);
                }
            } else {
                // Update volumes Lun Ids in export mask based on driver selection
                for (String volumeNativeId : driverVolumeToHLUMap.keySet()) {
                    String targetLunId = driverVolumeToHLUMap.get(volumeNativeId);
                    URI volumeUri = volumeNativeIdToUriMap.get(volumeNativeId);
                    exportMask.getVolumes().put(volumeUri.toString(), targetLunId);
                }
                dbClient.updateObject(exportMask);
                taskCompleter.ready(dbClient);
            }
        } else {
            String errorMsg = String.format("Failed to add volumes to export mask: %s .", task.getMessage());
            log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.addVolumesToExportMaskFailed("addVolumes", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception ex) {
        log.error("Problem in addVolumes: ", ex);
        String errorMsg = String.format("Failed to add volumes to export mask: %s .", ex.getMessage());
        log.error(errorMsg);
        ServiceError serviceError = ExternalDeviceException.errors.addVolumesToExportMaskFailed("addVolumes", errorMsg);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} addVolumes END...", storage.getSerialNumber());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) StorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.StorageCapabilities) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) HashSet(java.util.HashSet) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams)

Example 19 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort in project coprhd-controller by CoprHD.

the class ExternalDeviceUnManagedVolumeDiscoverer method createUnManagedExportMask.

/**
 * This method builds unManaged export mask from the provided hostExportInfo.
 *
 * @param hostExportInfo       source for unmanaged export mask data
 * @param unManagedVolumesUris set of unManaged volumes database ids for unManaged mask
 * @param managedVolumesUris   set of managed volumes database ids for unManaged mask
 * @param dbClient             reference to db client [IN]
 * @return unManaged export mask
 */
private UnManagedExportMask createUnManagedExportMask(com.emc.storageos.db.client.model.StorageSystem storageSystem, HostExportInfo hostExportInfo, Set<String> unManagedVolumesUris, Set<String> managedVolumesUris, DbClient dbClient) {
    UnManagedExportMask exportMask = new UnManagedExportMask();
    exportMask.setId(URIUtil.createId(UnManagedExportMask.class));
    StringSet knownInitiatorUris = new StringSet();
    StringSet knownInitiatorNetworkIds = new StringSet();
    StringSet unknownInitiatorNetworkIds = new StringSet();
    StringSet knownStoragePortUris = new StringSet();
    StringSet unmanagedStoragePortNetworkIds = new StringSet();
    StringSet unknownVolumesUris = new StringSet();
    StringSet knownVolumesUris = new StringSet();
    List<com.emc.storageos.db.client.model.Initiator> knownFCInitiators = new ArrayList<>();
    List<com.emc.storageos.db.client.model.StoragePort> knownFCPorts = new ArrayList<>();
    // FQDN of a host
    String hostName = hostExportInfo.getHostName();
    // List of host initiators
    List<Initiator> initiators = hostExportInfo.getInitiators();
    // List of storage ports
    List<StoragePort> targets = hostExportInfo.getTargets();
    exportMask.setMaskName(getUnManagedMaskName(hostName, storageSystem.getNativeGuid()));
    exportMask.setStorageSystemUri(storageSystem.getId());
    // get URIs for the initiators
    for (Initiator driverInitiator : initiators) {
        com.emc.storageos.db.client.model.Initiator knownInitiator = NetworkUtil.getInitiator(driverInitiator.getPort(), dbClient);
        if (knownInitiator != null) {
            URI initiatorUri = knownInitiator.getId();
            knownInitiatorUris.add(initiatorUri.toString());
            knownInitiatorNetworkIds.add(driverInitiator.getPort());
            if (HostInterface.Protocol.FC.toString().equals(knownInitiator.getProtocol())) {
                knownFCInitiators.add(knownInitiator);
            }
        } else {
            // unknown initiator
            unknownInitiatorNetworkIds.add(driverInitiator.getPort());
        }
    }
    exportMask.setKnownInitiatorNetworkIds(knownInitiatorNetworkIds);
    exportMask.setKnownInitiatorUris(knownInitiatorUris);
    exportMask.setUnmanagedInitiatorNetworkIds(unknownInitiatorNetworkIds);
    // get URIs for storage ports
    for (StoragePort driverPort : targets) {
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, driverPort.getNativeId(), NativeGUIDGenerator.PORT);
        URIQueryResultList storagePortURIs = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), storagePortURIs);
        if (storagePortURIs.iterator().hasNext()) {
            URI portUri = storagePortURIs.iterator().next();
            knownStoragePortUris.add(portUri.toString());
            com.emc.storageos.db.client.model.StoragePort port = dbClient.queryObject(com.emc.storageos.db.client.model.StoragePort.class, portUri);
            if (com.emc.storageos.db.client.model.StoragePort.TransportType.FC.toString().equals(port.getTransportType())) {
                knownFCPorts.add(port);
            }
        } else {
            // unknown storage port
            unmanagedStoragePortNetworkIds.add(driverPort.getPortNetworkId());
        }
    }
    exportMask.setKnownStoragePortUris(knownStoragePortUris);
    exportMask.setUnmanagedStoragePortNetworkIds(unmanagedStoragePortNetworkIds);
    // set unManaged volume uris
    if (unManagedVolumesUris != null && !unManagedVolumesUris.isEmpty()) {
        unknownVolumesUris.addAll(unManagedVolumesUris);
        exportMask.setUnmanagedVolumeUris(unknownVolumesUris);
    }
    // set managed volume uris
    if (managedVolumesUris != null && !managedVolumesUris.isEmpty()) {
        knownVolumesUris.addAll(managedVolumesUris);
        exportMask.setKnownVolumeUris(knownVolumesUris);
    }
    // populate zone map for FC initiators and FC storage ports from the mask.
    // we zone only known FC initiators to known FC ports defined in the mask.
    updateZoningMap(exportMask, knownFCInitiators, knownFCPorts);
    return exportMask;
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 20 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort in project coprhd-controller by CoprHD.

the class ExternalDeviceUnManagedVolumeDiscoverer method verifyHostExports.

/**
 * Validates that hostExportInfo has the same set of initiators and storage ports as provided input arguments.
 *
 * @param initiatorNetworkIds [IN] Set of initiator network ids
 * @param storagePortNativeIds [IN] Set of storage ports network ids
 * @param hostExportInfo [IN] host export info to verify
 * @return true if verification passed, false otherwise
 */
boolean verifyHostExports(Set<String> initiatorNetworkIds, Set<String> storagePortNativeIds, HostExportInfo hostExportInfo) {
    if (initiatorNetworkIds == null || storagePortNativeIds == null) {
        return false;
    }
    boolean isValid = true;
    Set<String> initiatorNetworkIdsSet = new HashSet<>();
    Set<String> targetNativeIdsSet = new HashSet<>();
    List<Initiator> initiatorsList = hostExportInfo.getInitiators();
    List<StoragePort> targetsList = hostExportInfo.getTargets();
    for (Initiator initiator : initiatorsList) {
        initiatorNetworkIdsSet.add(initiator.getPort());
    }
    for (StoragePort port : targetsList) {
        targetNativeIdsSet.add(port.getNativeId());
    }
    // compare with benchmark initiator and target set
    if (!initiatorNetworkIds.equals(initiatorNetworkIdsSet) || !storagePortNativeIds.equals(targetNativeIdsSet)) {
        isValid = false;
    }
    return isValid;
}
Also used : Initiator(com.emc.storageos.storagedriver.model.Initiator) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) HashSet(java.util.HashSet)

Aggregations

StoragePort (com.emc.storageos.storagedriver.model.StoragePort)23 ArrayList (java.util.ArrayList)15 Initiator (com.emc.storageos.storagedriver.model.Initiator)12 HashMap (java.util.HashMap)10 URI (java.net.URI)8 List (java.util.List)8 HostExportInfo (com.emc.storageos.storagedriver.HostExportInfo)7 HashSet (java.util.HashSet)7 DriverTask (com.emc.storageos.storagedriver.DriverTask)6 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)6 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)4 ExportMask (com.emc.storageos.db.client.model.ExportMask)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)3 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)3 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)3 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)3 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)3 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)3