Search in sources :

Example 1 with StoragePort

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

the class ExternalDeviceExportOperations method createDriverPort.

private StoragePort createDriverPort(StorageSystem storage, com.emc.storageos.db.client.model.StoragePort port) {
    StoragePort driverPort = new StoragePort();
    driverPort.setNativeId(port.getNativeId());
    driverPort.setStorageSystemId(storage.getNativeId());
    driverPort.setPortName(port.getPortName());
    driverPort.setDeviceLabel(port.getLabel());
    driverPort.setPortGroup(port.getPortGroup());
    return driverPort;
}
Also used : StoragePort(com.emc.storageos.storagedriver.model.StoragePort)

Example 2 with StoragePort

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

the class ExternalDeviceUnManagedVolumeDiscoverer method verifyHostExports.

/**
 * Verifies that all members of the specified list have the same set of initiators ans the same set
 * of storage ports.
 *
 * @param hostExportInfoList list of HostExportInfo data
 * @return If validation is success return VolumeToHostExportInfo with common set of initiators, common set of
 * ports, and all volumes from all elements of input list.
 * If validation failed, return null.
 */
private HostExportInfo verifyHostExports(List<HostExportInfo> hostExportInfoList) {
    HostExportInfo exportInfo = hostExportInfoList.get(0);
    // FQDN of a host
    String hostName = exportInfo.getHostName();
    // storage volumes native Ids
    Set<String> volumeNativeIds = new HashSet<>();
    // initiators port Ids
    Set<String> masterInitiatorNetworkIds = new HashSet<>();
    // target native Ids
    Set<String> masterTargetNativeIds = new HashSet<>();
    // get benchmark set of initiators and targets from first host export info instances
    // List of host initiators
    List<Initiator> initiators = exportInfo.getInitiators();
    // List of storage ports
    List<StoragePort> targets = exportInfo.getTargets();
    for (Initiator initiator : initiators) {
        masterInitiatorNetworkIds.add(initiator.getPort());
    }
    for (StoragePort port : targets) {
        masterTargetNativeIds.add(port.getNativeId());
    }
    for (HostExportInfo hostExportInfo : hostExportInfoList) {
        boolean isValid = verifyHostExports(masterInitiatorNetworkIds, masterTargetNativeIds, hostExportInfo);
        if (!isValid) {
            return null;
        }
        // Aggregate all volumes in one set.
        volumeNativeIds.addAll(hostExportInfo.getStorageObjectNativeIds());
    }
    // Create result export info
    HostExportInfo hostExportInfo = new HostExportInfo(hostName, new ArrayList<>(volumeNativeIds), initiators, targets);
    return hostExportInfo;
}
Also used : Initiator(com.emc.storageos.storagedriver.model.Initiator) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) HashSet(java.util.HashSet)

Example 3 with StoragePort

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

the class ExternalDeviceUnManagedVolumeDiscoverer method determineUnManagedExportMasksForExportInfo.

/**
 * This method processes hostToVolumeExportInfoMap to find out which existing unmanaged masks has to be updated,
 * and which unmanaged masks have to be created new for this export info. It also identifies hosts with unsupported
 * export info data (exported host volumes are not seen through the same set of initiators and the same set of storage
 * ports --- which require more than one mask per host) and adds these hosts to invalidExportHosts set.
 *
 * @param storageSystem
 * @param hostToVolumeExportInfoMap [IN] map: key --- host FQDN, value --- list of volume export info instances
 * @param invalidExportHosts        [IN, OUT] set of invalid hosts, for which we skip export processing for a given array
 * @param dbClient                  reference to db client [IN]
 * @param masksToUpdateForVolumes   [OUT] map: key --- URI of existing unmanaged export mask, value --- export info to use
 *                                  to update the mask.
 * @param masksToCreateForVolumes   [OUT] list of export info instances for which we need to create new unmanaged masks.
 */
private void determineUnManagedExportMasksForExportInfo(com.emc.storageos.db.client.model.StorageSystem storageSystem, Map<String, List<HostExportInfo>> hostToVolumeExportInfoMap, Set<String> invalidExportHosts, DbClient dbClient, Map<URI, HostExportInfo> masksToUpdateForVolumes, List<HostExportInfo> masksToCreateForVolumes) {
    for (Map.Entry<String, List<HostExportInfo>> entry : hostToVolumeExportInfoMap.entrySet()) {
        String hostName = entry.getKey();
        log.info("Processing export info for host {} .", hostName);
        if (invalidExportHosts.contains(hostName)) {
            // skip and continue to the next host.
            log.info("Found host {} in invalid hosts list. We will not process this host export data.", hostName);
            continue;
        }
        List<HostExportInfo> volumeToHostExportInfoList = entry.getValue();
        log.info("Processing export info list {} .", volumeToHostExportInfoList);
        String maskName = getUnManagedMaskName(hostName, storageSystem.getNativeGuid());
        HostExportInfo hostExportInfo = verifyHostExports(volumeToHostExportInfoList);
        if (hostExportInfo == null) {
            // invalid, continue to the next host
            invalidExportHosts.add(hostName);
            log.info("Found export info for host {} invalid. We will not process this host export data.", hostName);
            // check existing UnManaged export mask for host/array: the mask could be discovered for volumes on previous
            // pages (all unmanaged masks from previous discovery have been deactivated at the begging).
            UnManagedExportMask unManagedMask = getUnManagedExportMask(maskName, dbClient, storageSystem.getId());
            if (unManagedMask != null) {
                log.info("Found existing unmanaged export mask for host {} and array {} --- {} . We will deactivate this mask.", hostName, storageSystem.getNativeId(), unManagedMask);
                removeInvalidMaskDataFromVolumes(unManagedMask, dbClient);
                unManagedMask.setInactive(true);
                dbClient.updateObject(unManagedMask);
            }
            continue;
        }
        log.info("The result export info for host {} and array {} : {} .", hostName, storageSystem.getNativeId(), hostExportInfo);
        // check existing UnManaged export mask for host/array: the mask could be discovered for volumes on previous
        // pages (all unmanaged masks from previous discovery have been deactivated at the begging).
        UnManagedExportMask unManagedMask = getUnManagedExportMask(maskName, dbClient, storageSystem.getId());
        boolean isValid = true;
        if (unManagedMask != null) {
            log.info("Found existing unmanaged export mask for host {} and array {} --- {} .", hostName, storageSystem.getNativeId(), unManagedMask);
            // check that existing host/array unManaged export mask has the same set of initiators and the same
            // set of ports as new discovered hostExportInfo
            StringSet storagePortsUris = unManagedMask.getKnownStoragePortUris();
            Set<String> storagePortsNativeIds = new HashSet<>();
            Set<String> initiatorsNativeIds = new HashSet<>();
            for (String portUriString : storagePortsUris) {
                URI portUri = URI.create(portUriString);
                com.emc.storageos.db.client.model.StoragePort port = dbClient.queryObject(com.emc.storageos.db.client.model.StoragePort.class, portUri);
                storagePortsNativeIds.add(port.getNativeId());
            }
            storagePortsNativeIds.addAll(unManagedMask.getUnmanagedStoragePortNetworkIds());
            initiatorsNativeIds.addAll(unManagedMask.getKnownInitiatorNetworkIds());
            initiatorsNativeIds.addAll(unManagedMask.getUnmanagedInitiatorNetworkIds());
            isValid = verifyHostExports(initiatorsNativeIds, storagePortsNativeIds, hostExportInfo);
            if (!isValid) {
                // Invalid, we deactivate existing unmanaged mask --- make sure we do not discover invalid export
                // masks. We also, remove this mask from "unmanagedExportMasks" set in its unmanaged storage volumes.
                log.info("The result export info for host {} and storage array {} does not comply with existing mask.", hostName, storageSystem.getNativeId());
                removeInvalidMaskDataFromVolumes(unManagedMask, dbClient);
                unManagedMask.setInactive(true);
                dbClient.updateObject(unManagedMask);
            }
        } else {
            // Check if export mask for host/array is already managed. If host/array mask is managed, check that hostExportInfo has the same
            // storage ports and the same host initiators as in the managed mask. If we have a match for ports/initiators between the mask and hostExportInfo, we will process this
            // host export info and create a new UnManagedExportMask for the host.
            log.info("There is no existing unmanaged export mask for host {} and array {} .", hostName, storageSystem.getNativeId());
            List<String> initiatorPorts = new ArrayList<>();
            for (Initiator initiator : hostExportInfo.getInitiators()) {
                initiatorPorts.add(initiator.getPort());
            }
            // We enforce single export mask for host/array for ingested masks, so if only one initiator port match, the mask is a match.
            Map<URI, ExportMask> uriToExportMask = ExportMaskUtils.getExportMasksWithInitiatorPorts(dbClient, initiatorPorts);
            // Look for export mask for the storage system under processing.
            for (ExportMask mask : uriToExportMask.values()) {
                if (URIUtil.identical(mask.getStorageDevice(), storageSystem.getId())) {
                    // found managed export mask for storage system and host initiator
                    // the mask is already managed.
                    log.info("Found managed export mask for host {} and array {} --- {}." + " We will process this host export data to see if we can add volumes to this mask.", hostName, storageSystem.getNativeId(), mask.getId());
                    // check that this managed mask has the same initiators and ports as in the hostExportInfo
                    StringSet storagePortsUris = mask.getStoragePorts();
                    StringSet initiatorsUris = mask.getInitiators();
                    List<com.emc.storageos.db.client.model.StoragePort> ports = dbClient.queryObjectField(com.emc.storageos.db.client.model.StoragePort.class, "nativeId", StringSetUtil.stringSetToUriList(storagePortsUris));
                    List<com.emc.storageos.db.client.model.Initiator> initiators = dbClient.queryObjectField(com.emc.storageos.db.client.model.Initiator.class, "iniport", StringSetUtil.stringSetToUriList(initiatorsUris));
                    Set<String> maskStoragePortsNativeIds = new HashSet<>();
                    Set<String> maskInitiatorPorts = new HashSet<>();
                    for (com.emc.storageos.db.client.model.StoragePort storagePort : ports) {
                        maskStoragePortsNativeIds.add(storagePort.getNativeId());
                    }
                    for (com.emc.storageos.db.client.model.Initiator initiator : initiators) {
                        maskInitiatorPorts.add(initiator.getInitiatorPort());
                    }
                    log.info("Managed ExportMask {} has the following storage ports {}", mask.getId(), maskStoragePortsNativeIds);
                    log.info("Managed ExportMask {} has the following initiator ports {}", mask.getId(), maskInitiatorPorts);
                    // check that hostExportInfo has the same ports and initiators as in the export mask
                    isValid = verifyHostExports(maskInitiatorPorts, maskStoragePortsNativeIds, hostExportInfo);
                    if (isValid) {
                        // we will create unmanaged mask for this hostExportInfo
                        // we rely on ingestion to add new volumes to the managed mask.
                        log.info("Managed export mask {} has the same initiators and ports as in hostExportInfo. We will create unmanaged mask for new volumes.", mask.getId());
                        break;
                    } else {
                        log.info("Managed export mask {} has different initiators or ports as those in hostExportInfo.", mask.getId());
                    }
                }
            }
        }
        if (!isValid) {
            // invalid, continue to the next host
            // add host to invalid hosts list, so we do not process any export volume
            // info for this host in the future (for volumes found on next pages).
            log.info("Found export info for host {} invalid. Export info: {}." + " We will not process this host export data.", hostName, hostExportInfo);
            invalidExportHosts.add(hostName);
            continue;
        }
        if (unManagedMask != null) {
            // we will update this mask with additional volumes.
            URI maskId = unManagedMask.getId();
            masksToUpdateForVolumes.put(maskId, hostExportInfo);
        } else {
            // we will create new unManaged mask for host/array.
            masksToCreateForVolumes.add(hostExportInfo);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) URI(java.net.URI) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap)

Example 4 with StoragePort

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

the class HP3PARExpUnexpHelper method exportVolumesToInitiators.

/**
 *******USE CASES**********
 *
 *    EXCLUSIVE EXPORT: Will include port number of host
 *
 *    1 Export volume to existing host
 *    2 Export volume to non-existing host
 *    3 Add initiator to existing host
 *    4 Remove initiator from host
 *    5 Unexport volume
 *
 *    A 1-5 can be done with single/multiple volumes,initiators as applicable
 *    B Does not depend on host name
 *    C Adding an initiator in matched-set will not do anything further.
 *      All volumes have to be exported to new initiator explicitly.
 *      In host-sees 3PAR will automatically export the volumes to newly added initiator.
 *    -------------------------------------------
 *    SHARED EXPORT: Will not include port number, exported to all ports, the cluster can see
 *
 *    1 Export volume to existing cluster
 *    2 Export volume to non-existing cluster
 *    3 Add initiator to existing host in cluster
 *    4 Remove initiator from host in cluster
 *    5 Unexport volume from cluster
 *    6 Export a private volume to a host in a cluster
 *    7 Unexport a private volume from a host in a cluster
 *    8 Add a host to cluster
 *    9 Remove a host from a cluster
 *    10 Add a host having private export
 *    11 Remove a host having private export
 *    12 Move a host from one cluster to another
 *
 *    A 1-12 can be done with single/multiple volumes,initiators,hosts as applicable
 *    B Cluster name in ViPR and 3PAR has to be identical with case
 *    C Adding a new host to host-set will automatically export all volumes to the new host(initial export must have been host-set)
 */
/*
   * All volumes in the list will be exported to all initiators using recommended ports. If a volume can not be exported to 'n' 
   * initiators the same will be tried with available ports  
   */
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, DriverTask task, Registry driverRegistry, LockManager driverLockManager) {
    _log.info("3PARDriver:exportVolumesToInitiators enter");
    String host = null;
    host = doHostProcessing(initiators, volumes, driverRegistry, driverLockManager);
    if (host == null) {
        task.setMessage("exportVolumesToInitiators error: Processing hosts, Unable to export");
        task.setStatus(DriverTask.TaskStatus.FAILED);
        return task;
    }
    /*
         Export will be done keeping volumes as the starting point
         */
    Integer totalExport = recommendedPorts.size();
    for (StorageVolume vol : volumes) {
        Integer currExport = 0;
        Integer hlu = Integer.parseInt(volumeToHLUMap.get(vol.getNativeId()));
        try {
            // volume could belong to different storage system; get specific api client;
            HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(vol.getStorageSystemId(), driverRegistry);
            /*
                 export for INDIVIDUAL HOST=exclusive 
                 Some code is repeated with cluster for simplicity
                 */
            if (!host.startsWith("set:")) {
                // try with recommended ports
                for (StoragePort port : recommendedPorts) {
                    // volume and port belong to same storage system
                    String message = String.format("3PARDriver:exportVolumesToInitiators using recommendedPorts for " + "storage system %s, volume %s host %s hlu %s port %s", port.getStorageSystemId(), vol.getNativeId(), host, hlu.toString(), port.getNativeId());
                    _log.info(message);
                    VlunResult vlunRes = hp3parApi.createVlun(vol.getNativeId(), hlu, host, port.getNativeId());
                    if (vlunRes != null && vlunRes.getStatus()) {
                        currExport++;
                        usedRecommendedPorts.setValue(true);
                        // update hlu obtained as lun from 3apr & add the selected port if required
                        volumeToHLUMap.put(vol.getNativeId(), vlunRes.getAssignedLun());
                        if (!selectedPorts.contains(port)) {
                            selectedPorts.add(port);
                        }
                    } else {
                        task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
                        _log.warn("3PARDriver: Could not export " + message);
                    }
                }
                // now try with available ports
                for (StoragePort port : availablePorts) {
                    if (currExport == totalExport) {
                        task.setStatus(DriverTask.TaskStatus.READY);
                        break;
                    }
                    // Make sure this port is not used for earlier export
                    if (selectedPorts.contains(port)) {
                        continue;
                    }
                    // verify volume and port belong to same storage
                    if (!vol.getStorageSystemId().equalsIgnoreCase(port.getStorageSystemId())) {
                        continue;
                    }
                    String message = String.format("3PARDriver:exportVolumesToInitiators using availablePorts for " + "storage system %s, volume %s host %s hlu %s port %s", port.getStorageSystemId(), vol.getNativeId(), host, hlu.toString(), port.getNativeId());
                    _log.info(message);
                    VlunResult vlunRes = hp3parApi.createVlun(vol.getNativeId(), hlu, host, port.getNativeId());
                    if (vlunRes != null && vlunRes.getStatus()) {
                        currExport++;
                        usedRecommendedPorts.setValue(false);
                        // update hlu obtained as lun from 3apr & add the selected port if required
                        volumeToHLUMap.put(vol.getNativeId(), vlunRes.getAssignedLun());
                        if (!selectedPorts.contains(port)) {
                            selectedPorts.add(port);
                        }
                    } else {
                        task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
                        _log.warn("3PARDriver: Could not export " + message);
                    }
                }
            // for available ports
            } else {
                /*
                      export for CLUSTER=shared 
                      Some code is repeated with cluster for simplicity
                      
                      Cluster export will be done as host-set in 3APR for entire cluster in one go.
                      Hence requests coming for rest of the individual host exports should gracefully exit
                     */
                String lockName = volumes.get(0).getStorageSystemId() + vol.getNativeId() + host;
                if (driverLockManager.acquireLock(lockName, 10, TimeUnit.MINUTES)) {
                    _log.info("3PARDriver: Acquired lock {} to examine vlun creation", lockName);
                    /*
                          If this is the first request key gets created with export operation. 
                          other requests will gracefully exit. key will be removed in unexport.
                         */
                    String message = String.format("3PARDriver:exportVolumesToInitiators " + "storage system %s, volume %s Cluster %s hlu %s ", vol.getStorageSystemId(), vol.getNativeId(), host, hlu.toString());
                    _log.info(message);
                    String exportPath = vol.getStorageSystemId() + vol.getNativeId() + host;
                    _log.info("3PARDriver:exportPath {} for registry entry", exportPath);
                    Map<String, List<String>> attributes = new HashMap<>();
                    List<String> expValue = new ArrayList<>();
                    List<String> lunValue = new ArrayList<>();
                    boolean doExport = true;
                    attributes = driverRegistry.getDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, exportPath);
                    if (attributes != null) {
                        expValue = attributes.get("EXPORT_PATH");
                        if (expValue != null && expValue.get(0).compareTo(exportPath) == 0) {
                            doExport = false;
                            // Already exported, make hlu, port details; gracefully exit
                            lunValue = attributes.get(vol.getNativeId());
                            volumeToHLUMap.put(vol.getNativeId(), lunValue.get(0));
                            HP3PARHostNameResult hostNameResult = get3parHostname(initiators, vol.getStorageSystemId(), driverRegistry);
                            HostMember hostRes = hp3parApi.getHostDetails(hostNameResult.getHostName());
                            // get storage array ports for this host ports
                            List<StoragePort> clusterStoragePorts = new ArrayList<>();
                            getClusterStoragePorts(hostRes, availablePorts, vol.getStorageSystemId(), clusterStoragePorts);
                            for (StoragePort sp : clusterStoragePorts) {
                                // assign all these ports as selected ports
                                if (!selectedPorts.contains(sp)) {
                                    selectedPorts.add(sp);
                                }
                            }
                            // go thru all slectedports.
                            // if anyone is not part of the recommendedPorts set usedRecommendedPorts to false
                            usedRecommendedPorts.setValue(true);
                            for (StoragePort sp : selectedPorts) {
                                if (!recommendedPorts.contains(sp)) {
                                    usedRecommendedPorts.setValue(false);
                                    break;
                                }
                            }
                            task.setStatus(DriverTask.TaskStatus.READY);
                            _log.info("3PARDriver: Already exported, exiting " + message);
                        }
                    }
                    if (doExport) {
                        _log.info("3PARDriver: exporting volume {} as exportPath {} is not present in registry", vol.getNativeId(), exportPath);
                        /*
                             for cluster use host set method, We cannot specify port; 
                             determine the individual host ports used
                             */
                        VlunResult vlunRes = hp3parApi.createVlun(vol.getNativeId(), hlu, host, null);
                        if (vlunRes != null && vlunRes.getStatus()) {
                            // update hlu obtained as lun from 3apr & add the selected port if required
                            volumeToHLUMap.put(vol.getNativeId(), vlunRes.getAssignedLun());
                            HP3PARHostNameResult hostNameResult = get3parHostname(initiators, vol.getStorageSystemId(), driverRegistry);
                            HostMember hostRes = hp3parApi.getHostDetails(hostNameResult.getHostName());
                            // get storage array ports for this host ports
                            List<StoragePort> clusterStoragePorts = new ArrayList<>();
                            getClusterStoragePorts(hostRes, availablePorts, vol.getStorageSystemId(), clusterStoragePorts);
                            for (StoragePort sp : clusterStoragePorts) {
                                // assign all these ports as selected ports
                                if (!selectedPorts.contains(sp)) {
                                    selectedPorts.add(sp);
                                }
                            }
                            usedRecommendedPorts.setValue(true);
                            for (StoragePort sp : selectedPorts) {
                                if (!recommendedPorts.contains(sp)) {
                                    usedRecommendedPorts.setValue(false);
                                    break;
                                }
                            }
                            // Everything is successful, Set as exported in registry
                            attributes = new HashMap<>();
                            expValue = new ArrayList<>();
                            lunValue = new ArrayList<>();
                            expValue.add(exportPath);
                            attributes.put("EXPORT_PATH", expValue);
                            lunValue.add(vlunRes.getAssignedLun());
                            attributes.put(vol.getNativeId(), lunValue);
                            attributes.put(vol.getNativeId(), lunValue);
                            driverRegistry.setDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, exportPath, attributes);
                            task.setMessage("Successful");
                            task.setStatus(DriverTask.TaskStatus.READY);
                        } else {
                            // end createVlun
                            task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
                            _log.warn("3PARDriver: Could not export " + message);
                        }
                    }
                    // doExport
                    _log.info("3PARDriver: Releasing lock {} after examining vlun creation", lockName);
                    driverLockManager.releaseLock(lockName);
                } else {
                    _log.error("3PARDriver:exportVolumesToInitiators error: could not acquire thread lock");
                    throw new HP3PARException("3PARDriver:exportVolumesToInitiators error: could not acquire thread lock");
                }
            }
        // end cluster export
        } catch (Exception e) {
            String msg = String.format("3PARDriver: Unable to export few volumes, error: %s", e);
            _log.error(CompleteError.getStackTrace(e));
            _log.error(msg);
            task.setMessage(msg);
            task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
            e.printStackTrace();
        }
    }
    // for each volume
    _log.info("3PARDriver:exportVolumesToInitiators leave");
    return task;
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ArrayList(java.util.ArrayList) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) HostMember(com.emc.storageos.hp3par.command.HostMember) VlunResult(com.emc.storageos.hp3par.command.VlunResult) ArrayList(java.util.ArrayList) VirtualLunsList(com.emc.storageos.hp3par.command.VirtualLunsList) List(java.util.List)

Example 5 with StoragePort

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

the class HP3PARUtil method discoverStoragePortsById.

/**
 * Get storage port information
 * @throws Exception
 */
public void discoverStoragePortsById(String storageSystemId, List<StoragePort> storagePorts, Registry driverRegistery) throws Exception {
    // For this 3PAR system
    try {
        // get Api client
        HP3PARApi hp3parApi = getHP3PARDeviceFromNativeId(storageSystemId, driverRegistery);
        // get storage port details
        PortCommandResult portResult = hp3parApi.getPortDetails();
        PortStatisticsCommandResult portStatResult = hp3parApi.getPortStatisticsDetail();
        // for each ViPR Storage port = 3PAR host port
        for (PortMembers currMember : portResult.getMembers()) {
            StoragePort port = new StoragePort();
            // Consider online target ports
            if (currMember.getMode() != HP3PARConstants.MODE_TARGET || currMember.getLinkState() != HP3PARConstants.LINK_READY) {
                continue;
            }
            if (currMember.getLabel() == null) {
                String label = String.format("port:%s:%s:%s", currMember.getPortPos().getNode(), currMember.getPortPos().getSlot(), currMember.getPortPos().getCardPort());
                port.setPortName(label);
            } else {
                port.setPortName(currMember.getLabel());
            }
            port.setStorageSystemId(storageSystemId);
            switch(currMember.getProtocol()) {
                case 1:
                    port.setTransportType(TransportType.FC);
                    break;
                case 3:
                    port.setTransportType(TransportType.Ethernet);
                    break;
                case 2:
                    port.setTransportType(TransportType.IP);
                    break;
                default:
                    _log.warn("3PARDriver: discoverStoragePorts Invalid port {}", port.getPortName());
                    break;
            }
            for (PortStatMembers currStat : portStatResult.getMembers()) {
                if (currMember.getPortPos().getNode() == currStat.getNode() && currMember.getPortPos().getSlot() == currStat.getSlot() && currMember.getPortPos().getCardPort() == currStat.getCardPort()) {
                    port.setPortSpeed(currStat.getSpeed() * HP3PARConstants.MEGA_BYTE);
                }
            }
            // grouping with cluster node and slot
            port.setPortGroup(currMember.getPortPos().getNode().toString());
            port.setPortSubGroup(currMember.getPortPos().getSlot().toString());
            // set specific properties based on protocol
            if (port.getTransportType().equals(TransportType.FC.toString())) {
                port.setPortNetworkId(SanUtils.formatWWN(currMember.getPortWWN()));
                // rest of the values
                port.setEndPointID(port.getPortNetworkId());
                port.setTcpPortNumber((long) 0);
            } else if (port.getTransportType().equals(TransportType.IP.toString())) {
                port.setIpAddress(currMember.getIPAddr());
                port.setPortNetworkId(currMember.getiSCSINmae());
                port.setTcpPortNumber(currMember.getiSCSIPortInfo().getiSNSPort());
                // rest of the values
                port.setEndPointID(port.getPortNetworkId());
            }
            port.setAvgBandwidth(port.getPortSpeed());
            port.setPortHAZone(String.format("Group-%s", currMember.getPortPos().getNode()));
            String id = String.format("%s:%s:%s", currMember.getPortPos().getNode(), currMember.getPortPos().getSlot(), currMember.getPortPos().getCardPort());
            // Storage object properties
            port.setNativeId(id);
            port.setDeviceLabel(port.getPortName());
            port.setDisplayName(port.getPortName());
            port.setOperationalStatus(StoragePort.OperationalStatus.OK);
            _log.info("3PARDriver: added storage port {}, native id {}", port.getPortName(), port.getNativeId());
            storagePorts.add(port);
        }
    // for each storage pool
    } catch (Exception e) {
        throw e;
    }
}
Also used : PortMembers(com.emc.storageos.hp3par.command.PortMembers) PortCommandResult(com.emc.storageos.hp3par.command.PortCommandResult) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) PortStatMembers(com.emc.storageos.hp3par.command.PortStatMembers) HP3PARApi(com.emc.storageos.hp3par.impl.HP3PARApi) PortStatisticsCommandResult(com.emc.storageos.hp3par.command.PortStatisticsCommandResult) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException)

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