Search in sources :

Example 1 with VPlexTargetInfo

use of com.emc.storageos.vplex.api.VPlexTargetInfo in project coprhd-controller by CoprHD.

the class VPlexCommunicationInterface method getPortOperationalStatus.

/**
 * Gets the operational status for the passed port based on whether it is
 * a frontend or backend port.
 *
 * @param portInfo Port info for the port.
 * @param portTargetMap The port target info for frontend ports.
 *
 * @return A String representing the ViPR port status.
 */
private String getPortOperationalStatus(VPlexPortInfo portInfo, Map<String, VPlexTargetInfo> portTargetMap) {
    s_logger.info("Port status for port {}", portInfo.getPath());
    if (portInfo.isFrontendPort()) {
        s_logger.info("Port is front end");
        // We use the export status of the frontend port from the
        // associated target info for the port to determine the
        // operational status for the port.
        VPlexTargetInfo portTargetInfo = portTargetMap.get(portInfo.getPortWwn());
        if (null == portTargetInfo) {
            // which indicate no exports are present on this port
            return StoragePort.OperationalStatus.UNKNOWN.name();
        }
        String portExportStatus = portTargetInfo.getExportStatus();
        s_logger.info("Export status is {}", portExportStatus);
        if (VPlexTargetInfo.ExportStatus.ok.name().equals(portExportStatus)) {
            return StoragePort.OperationalStatus.OK.name();
        } else {
            return StoragePort.OperationalStatus.NOT_OK.name();
        }
    } else {
        // For backend ports we simply use the operation status
        // of the port.
        String portOperationalStatus = portInfo.getOperationalStatus();
        s_logger.info("Operational status is {}", portOperationalStatus);
        if (VPlexPortInfo.OperationalStatus.ok.name().equals(portOperationalStatus)) {
            return StoragePort.OperationalStatus.OK.name();
        } else {
            return StoragePort.OperationalStatus.NOT_OK.name();
        }
    }
}
Also used : VPlexTargetInfo(com.emc.storageos.vplex.api.VPlexTargetInfo)

Example 2 with VPlexTargetInfo

use of com.emc.storageos.vplex.api.VPlexTargetInfo in project coprhd-controller by CoprHD.

the class VPlexCommunicationInterface method discoverPorts.

/**
 * Discovers and creates the ports for the passed VPlex virtual storage
 * system.
 *
 * @param client The VPlex API client.
 * @param vplexStorageSystem A reference to the VPlex storage system.
 * @param autoUpgradePortsMap a map of port wwns to StoragePorts from the
 *            original cluster in a local to metro auto upgrade situation
 *
 * @throws VPlexCollectionException When an error occurs discovering the
 *             VPlex ports.
 */
private void discoverPorts(VPlexApiClient client, StorageSystem vplexStorageSystem, List<StoragePort> allPorts, Map<String, StoragePort> autoUpgradePortsMap) throws VPlexCollectionException {
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    List<Initiator> newInitiatorPorts = new ArrayList<Initiator>();
    try {
        // Get the port information from the VPlex.
        String initiatorHostName = null;
        List<VPlexPortInfo> portInfoList = client.getPortInfo(false);
        Map<String, VPlexTargetInfo> portTargetMap = client.getTargetInfoForPorts(portInfoList);
        for (VPlexPortInfo portInfo : portInfoList) {
            s_logger.debug("VPlex port info: {}", portInfo.toString());
            if (null == portInfo.getPortWwn()) {
                s_logger.info("Not a FC port, skipping port {}", portInfo.getName());
                continue;
            }
            // StoragePort instances for these ports.
            if ((!portInfo.isFrontendPort()) && (!portInfo.isBackendPort())) {
                s_logger.debug("Not a front/back-end port, skipping port {}", portInfo.getName());
                continue;
            }
            String portWWN = WWNUtility.getWWNWithColons(portInfo.getPortWwn());
            String portType = portInfo.isBackendPort() ? PortType.backend.name() : PortType.frontend.name();
            s_logger.info("Found {} port {}", portType, portWWN);
            // WWN.
            if ((portWWN == null) || (portWWN.equals(OFFLINE_PORT_WWN))) {
                s_logger.info("Skipping port {} with WWN {}", portInfo.getName(), portWWN);
                continue;
            }
            // See if the port already exists in the DB. If not we need to
            // create it.
            StoragePort storagePort = findPortInDB(vplexStorageSystem, portInfo, autoUpgradePortsMap);
            if (storagePort == null) {
                s_logger.info("Creating new port {}", portWWN);
                storagePort = new StoragePort();
                storagePort.setId(URIUtil.createId(StoragePort.class));
                storagePort.setPortNetworkId(portWWN);
                storagePort.setPortName(portInfo.getName());
                storagePort.setStorageDevice(vplexStorageSystem.getId());
                String nativeGuid = NativeGUIDGenerator.generateNativeGuid(_dbClient, storagePort);
                storagePort.setNativeGuid(nativeGuid);
                storagePort.setLabel(nativeGuid);
                storagePort.setPortType(portType);
                // Always FC
                storagePort.setTransportType(StorageProtocol.Block.FC.name());
                setHADomainForStoragePort(vplexStorageSystem, storagePort, portInfo);
                storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                newStoragePorts.add(storagePort);
            } else {
                existingStoragePorts.add(storagePort);
            }
            // CTRL-4701 - if we got to this point, the VPLEX firmware was validated as compatible,
            // so, the storage port should be marked compatible as well
            storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
            storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            // Port speed is current port speed and should be updated
            // for existing ports.
            storagePort.setPortSpeed(portInfo.getCurrentSpeed(SpeedUnits.GBITS_PER_SECOND));
            // Set or update the port operational status.
            storagePort.setOperationalStatus(getPortOperationalStatus(portInfo, portTargetMap));
            // list.
            if (portInfo.isBackendPort()) {
                Initiator initiatorPort = findInitiatorInDB(portInfo);
                if (initiatorPort == null) {
                    s_logger.info("Creating initiator for backend port", portWWN);
                    if (initiatorHostName == null) {
                        initiatorHostName = getInitiatorHostName(vplexStorageSystem);
                    }
                    s_logger.info("Host name is {}", initiatorHostName);
                    initiatorPort = new Initiator(StorageProtocol.Block.FC.name(), portWWN, WWNUtility.getWWNWithColons(portInfo.getNodeWwn()), initiatorHostName, false);
                    initiatorPort.setId(URIUtil.createId(Initiator.class));
                    newInitiatorPorts.add(initiatorPort);
                }
            }
        }
        // Persist changes to new and exiting ports and initiators.
        _dbClient.createObject(newStoragePorts);
        _dbClient.updateObject(existingStoragePorts);
        _dbClient.createObject(newInitiatorPorts);
        allPorts.addAll(newStoragePorts);
        allPorts.addAll(existingStoragePorts);
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, vplexStorageSystem.getId());
        if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
            allPorts.addAll(notVisiblePorts);
        }
    } catch (Exception e) {
        s_logger.error("Error discovering ports for the VPLEX storage system {}:", vplexStorageSystem.getIpAddress(), e);
        throw VPlexCollectionException.exceptions.failedPortsDiscovery(vplexStorageSystem.getId().toString(), e.getLocalizedMessage(), e);
    }
}
Also used : VPlexPortInfo(com.emc.storageos.vplex.api.VPlexPortInfo) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexTargetInfo(com.emc.storageos.vplex.api.VPlexTargetInfo) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) IOException(java.io.IOException)

Example 3 with VPlexTargetInfo

use of com.emc.storageos.vplex.api.VPlexTargetInfo in project coprhd-controller by CoprHD.

the class VPlexControllerUtils method getTargetPortToPwwnMap.

/**
 * Creates a Map of target-port to port-wwn values for a VPLEX device
 * For example: target port - P0000000046E01E80-A0-FC02
 *              port wwn    - 0x50001442601e8002
 *
 * @param client a reference to the VPlexApiClient to query for port info
 * @param clusterName the cluster for this port name search; port names can potentially be different
 *                    across clusters.
 * @return a Map of target-port to port-wwn values for a VPLEX device
 */
public static Map<String, String> getTargetPortToPwwnMap(VPlexApiClient client, String clusterName) {
    Map<String, String> targetPortToPwwnMap = new HashMap<String, String>();
    List<VPlexTargetInfo> targetInfos = client.getTargetInfoForCluster(clusterName);
    if (targetInfos != null) {
        for (VPlexTargetInfo vplexTargetPortInfo : targetInfos) {
            if (null != vplexTargetPortInfo.getPortWwn()) {
                targetPortToPwwnMap.put(vplexTargetPortInfo.getName(), vplexTargetPortInfo.getPortWwn());
            }
        }
    }
    log.info("target port map for cluster {} is {}", clusterName, targetPortToPwwnMap);
    return targetPortToPwwnMap;
}
Also used : HashMap(java.util.HashMap) VPlexTargetInfo(com.emc.storageos.vplex.api.VPlexTargetInfo)

Aggregations

VPlexTargetInfo (com.emc.storageos.vplex.api.VPlexTargetInfo)3 Initiator (com.emc.storageos.db.client.model.Initiator)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 VPlexCollectionException (com.emc.storageos.plugins.metering.vplex.VPlexCollectionException)1 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)1 VPlexPortInfo (com.emc.storageos.vplex.api.VPlexPortInfo)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1