Search in sources :

Example 96 with StoragePort

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

the class VPlexCommunicationInterface method discoverUnmanagedStorageViews.

/**
 * Discovers storage views on the VPLEX and creates UnManagedExportMasks for any
 * that are not managed by ViPR.
 *
 * @param accessProfile providing context for this discovery session
 * @param client a reference to the VPLEX API client
 * @param vvolMap map of virtual volume names to virtual volume info objects
 * @param volumeToExportMasksMap map of volumes to a set of associated UnManagedExportMasks
 * @param volumeToStorageViewMap map of volumes to a set of associated VPlexStorageViewInfos
 * @param recoverpointExportMasks recoverpoint export mask uris
 * @throws BaseCollectionException
 */
private void discoverUnmanagedStorageViews(AccessProfile accessProfile, VPlexApiClient client, Map<String, VPlexVirtualVolumeInfo> vvolMap, Map<String, Set<UnManagedExportMask>> volumeToExportMasksMap, Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap, Set<String> recoverPointExportMasks) throws BaseCollectionException {
    String statusMessage = "Starting discovery of Unmanaged VPLEX Storage Views.";
    s_logger.info(statusMessage + " Access Profile Details :  IpAddress : " + "PortNumber : {}, namespace : {}", accessProfile.getIpAddress() + accessProfile.getPortNumber(), accessProfile.getnamespace());
    URI vplexUri = accessProfile.getSystemId();
    StorageSystem vplex = _dbClient.queryObject(StorageSystem.class, vplexUri);
    if (null == vplex) {
        s_logger.error("No VPLEX Device was found in ViPR for URI: " + vplexUri);
        s_logger.error("Unmanaged VPLEX StorageView discovery cannot continue.");
        return;
    }
    try {
        // this is a map of cluster id (1 or 2) to the actual cluster name
        Map<String, String> clusterIdToNameMap = client.getClusterIdToNameMap();
        // this is a map of the cluster names to a map of its target port names to wwpns
        Map<String, Map<String, String>> clusterPortMap = new HashMap<String, Map<String, String>>();
        for (String clusterName : clusterIdToNameMap.values()) {
            Map<String, String> targetPortToPwwnMap = VPlexControllerUtils.getTargetPortToPwwnMap(client, clusterName);
            clusterPortMap.put(clusterName, targetPortToPwwnMap);
        }
        Set<URI> allCurrentUnManagedExportMaskUris = new HashSet<URI>();
        List<UnManagedExportMask> unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
        List<UnManagedExportMask> unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
        Set<URI> rpPortInitiators = RPHelper.getBackendPortInitiators(_dbClient);
        for (String clusterName : clusterIdToNameMap.values()) {
            List<VPlexStorageViewInfo> storageViews = client.getStorageViewsForCluster(clusterName);
            for (VPlexStorageViewInfo storageView : storageViews) {
                s_logger.info("discovering storage view: " + storageView.toString());
                List<Initiator> knownInitiators = new ArrayList<Initiator>();
                List<StoragePort> knownPorts = new ArrayList<StoragePort>();
                UnManagedExportMask uem = getUnManagedExportMaskFromDb(storageView);
                if (uem != null) {
                    s_logger.info("found an existing unmanaged export mask for storage view " + storageView.getName());
                    unManagedExportMasksToUpdate.add(uem);
                    // clean up collections (we'll be refreshing them)
                    uem.getKnownInitiatorUris().clear();
                    uem.getKnownInitiatorNetworkIds().clear();
                    uem.getKnownStoragePortUris().clear();
                    uem.getKnownVolumeUris().clear();
                    uem.getUnmanagedInitiatorNetworkIds().clear();
                    uem.getUnmanagedStoragePortNetworkIds().clear();
                    uem.getUnmanagedVolumeUris().clear();
                } else {
                    s_logger.info("creating a new unmanaged export mask for storage view " + storageView.getName());
                    uem = new UnManagedExportMask();
                    unManagedExportMasksToCreate.add(uem);
                }
                // set basic info
                uem.setNativeId(storageView.getPath());
                uem.setMaskingViewPath(storageView.getPath());
                uem.setMaskName(storageView.getName());
                uem.setStorageSystemUri(accessProfile.getSystemId());
                s_logger.info("now discovering host initiators in storage view " + storageView.getName());
                for (String initiatorNetworkId : storageView.getInitiatorPwwns()) {
                    s_logger.info("looking at initiator network id " + initiatorNetworkId);
                    if (initiatorNetworkId != null && initiatorNetworkId.matches(ISCSI_PATTERN) && (iSCSIUtility.isValidIQNPortName(initiatorNetworkId) || iSCSIUtility.isValidEUIPortName(initiatorNetworkId))) {
                        s_logger.info("\tiSCSI network id normalized to " + initiatorNetworkId);
                    } else if (initiatorNetworkId != null && initiatorNetworkId.matches(REGISTERED_PATTERN)) {
                        initiatorNetworkId = initiatorNetworkId.substring(REGISTERED_PORT_PREFIX.length());
                        initiatorNetworkId = WWNUtility.getWWNWithColons(initiatorNetworkId);
                        s_logger.info("\tRegistered network id normalized to " + initiatorNetworkId);
                    } else if (WWNUtility.isValidWWNAlias(initiatorNetworkId)) {
                        initiatorNetworkId = WWNUtility.getWWNWithColons(initiatorNetworkId);
                        s_logger.info("\twwn normalized to " + initiatorNetworkId);
                    } else {
                        s_logger.warn("\tthis is not a valid network id format, skipping");
                        continue;
                    }
                    // check if a host initiator exists for this id
                    // if so, add to _knownInitiators
                    // otherwise, add to _unmanagedInitiators
                    Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, _dbClient);
                    if (knownInitiator != null) {
                        s_logger.info("   found an initiator in ViPR on host " + knownInitiator.getHostName());
                        uem.getKnownInitiatorUris().add(knownInitiator.getId().toString());
                        uem.getKnownInitiatorNetworkIds().add(knownInitiator.getInitiatorPort());
                        knownInitiators.add(knownInitiator);
                    } else {
                        s_logger.info("   no hosts in ViPR found configured for initiator " + initiatorNetworkId);
                        uem.getUnmanagedInitiatorNetworkIds().add(initiatorNetworkId);
                    }
                }
                s_logger.info("now discovering storage ports in storage view " + storageView.getName());
                List<String> targetPortNames = storageView.getPorts();
                if (targetPortNames.isEmpty()) {
                    s_logger.info("no storage ports found in storage view " + storageView.getName());
                // continue; ?
                }
                // target port has value like - P0000000046E01E80-A0-FC02
                // PortWwn has value like - 0x50001442601e8002
                List<String> portWwns = new ArrayList<String>();
                for (String targetPortName : targetPortNames) {
                    Map<String, String> portToWwpnMap = clusterPortMap.get(clusterName);
                    if (portToWwpnMap.keySet().contains(targetPortName)) {
                        portWwns.add(WwnUtils.convertWWN(portToWwpnMap.get(targetPortName), WwnUtils.FORMAT.COLON));
                    }
                }
                for (String portNetworkId : portWwns) {
                    s_logger.info("looking at storage port network id " + portNetworkId);
                    // check if a storage port exists for this id in ViPR
                    // if so, add to _storagePorts
                    StoragePort knownStoragePort = NetworkUtil.getStoragePort(portNetworkId, _dbClient);
                    if (knownStoragePort != null) {
                        s_logger.info("   found a matching storage port in ViPR " + knownStoragePort.getLabel());
                        uem.getKnownStoragePortUris().add(knownStoragePort.getId().toString());
                        knownPorts.add(knownStoragePort);
                    } else {
                        s_logger.info("   no storage port in ViPR found matching portNetworkId " + portNetworkId);
                        uem.getUnmanagedStoragePortNetworkIds().add(portNetworkId);
                    }
                }
                s_logger.info("now discovering storage volumes in storage view " + storageView.getName());
                for (String volumeNameStr : storageView.getVirtualVolumes()) {
                    s_logger.info("found volume " + volumeNameStr);
                    // volumeNameStr contains value like
                    // (161,dd_V000195701573-00D57_VAPM00140801303-00614_vol,VPD83T3:6000144000000010f07dc46a0717e61d,2G)
                    String[] tokens = volumeNameStr.split(",");
                    String volumeName = tokens[1];
                    VPlexVirtualVolumeInfo vvol = vvolMap.get(volumeName);
                    Volume volume = findVirtualVolumeManagedByVipr(vvol);
                    if (volume != null) {
                        s_logger.info("this is a volume already managed by ViPR: " + volume.getLabel());
                        uem.getKnownVolumeUris().add(volume.getId().toString());
                    }
                    // add to map of volume paths to export masks
                    if (vvol != null) {
                        String nativeGuid = vvol.getPath();
                        s_logger.info("nativeGuid UnManagedVolume key for locating UnManagedExportMasks is " + nativeGuid);
                        Set<UnManagedExportMask> maskSet = volumeToExportMasksMap.get(nativeGuid);
                        if (maskSet == null) {
                            maskSet = new HashSet<UnManagedExportMask>();
                            s_logger.info("   creating new maskSet for nativeGuid " + nativeGuid);
                            volumeToExportMasksMap.put(nativeGuid, maskSet);
                        }
                        maskSet.add(uem);
                    }
                    // add this storage view to the volume to storage view map for this volume
                    Set<VPlexStorageViewInfo> storageViewSet = volumeToStorageViewMap.get(volumeName);
                    if (storageViewSet == null) {
                        storageViewSet = new HashSet<VPlexStorageViewInfo>();
                    }
                    storageViewSet.add(storageView);
                    volumeToStorageViewMap.put(volumeName, storageViewSet);
                }
                if (uem.getId() == null) {
                    uem.setId(URIUtil.createId(UnManagedExportMask.class));
                }
                if (checkRecoverPointExportMask(uem, knownInitiators, rpPortInitiators)) {
                    recoverPointExportMasks.add(uem.getId().toString());
                }
                updateZoningMap(uem, knownInitiators, knownPorts);
                persistUnManagedExportMasks(unManagedExportMasksToCreate, unManagedExportMasksToUpdate, false);
                allCurrentUnManagedExportMaskUris.add(uem.getId());
            }
        }
        persistUnManagedExportMasks(unManagedExportMasksToCreate, unManagedExportMasksToUpdate, true);
        cleanUpOrphanedExportMasks(vplexUri, allCurrentUnManagedExportMaskUris);
    } catch (Exception ex) {
        s_logger.error(ex.getLocalizedMessage(), ex);
        String vplexLabel = vplexUri.toString();
        if (null != vplex) {
            vplexLabel = vplex.getLabel();
        }
        throw VPlexCollectionException.exceptions.vplexUnmanagedExportMaskDiscoveryFailed(vplexLabel, ex.getLocalizedMessage());
    } finally {
        if (null != vplex) {
            try {
                vplex.setLastDiscoveryStatusMessage(statusMessage);
                _dbClient.updateObject(vplex);
            } catch (Exception ex) {
                s_logger.error("Error while saving VPLEX discovery status message: {} - Exception: {}", statusMessage, ex.getLocalizedMessage());
            }
        }
    }
}
Also used : VPlexStorageViewInfo(com.emc.storageos.vplex.api.VPlexStorageViewInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) Initiator(com.emc.storageos.db.client.model.Initiator) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) 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) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TreeMap(java.util.TreeMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 97 with StoragePort

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

the class XtremIOCommunicationInterface method discoverXtremIOSystem.

private void discoverXtremIOSystem(XtremIOClient restClient, StorageSystem systemInDB) {
    try {
        List<StoragePool> pools = new ArrayList<StoragePool>();
        XtremIOSystem clusterObject = restClient.getClusterDetails(systemInDB.getSerialNumber());
        updateStorageSystemAndPools(clusterObject, systemInDB, pools);
        Map<String, List<StoragePort>> portMap = discoverPorts(restClient, systemInDB);
        List<StoragePort> allPorts = new ArrayList<StoragePort>();
        allPorts.addAll(portMap.get(NEW));
        allPorts.addAll(portMap.get(EXISTING));
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, systemInDB.getId());
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(portMap.get(EXISTING));
        if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
            allExistingPorts.addAll(notVisiblePorts);
        }
        StoragePortAssociationHelper.runUpdatePortAssociationsProcess(portMap.get(NEW), allExistingPorts, _dbClient, _coordinator, pools);
        discoverInitiators(restClient, systemInDB);
    } catch (Exception e) {
        _logger.error("Error discovering XtremIO cluster", e);
        // throw exception only if system discovery failed.
        throw XtremIOApiException.exceptions.discoveryFailed(systemInDB.toString());
    }
}
Also used : XtremIOSystem(com.emc.storageos.xtremio.restapi.model.response.XtremIOSystem) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 98 with StoragePort

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

the class ProtocolEndPointToPortProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        CIMObjectPath protocolEndPointPath = getObjectPathfromCIMArgument(args);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        String protocolEndPointId = protocolEndPointPath.getKey(Constants.NAME).getValue().toString();
        _log.info("Protocol End Point ID :" + protocolEndPointId);
        @SuppressWarnings("unchecked") Map<String, URI> volumeToRAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
        URI remoteRAGroupUri = volumeToRAGroupMap.get(protocolEndPointId);
        _log.info("Remote RA Group URI :" + remoteRAGroupUri);
        String sourceSystemSerialId = keyMap.get(Constants._serialID).toString();
        _log.info("Source Serial ID :" + sourceSystemSerialId);
        RemoteDirectorGroup remoteGroup = _dbClient.queryObject(RemoteDirectorGroup.class, remoteRAGroupUri);
        if (remoteGroup == null) {
            _log.info("RA Group Not Found {}", remoteRAGroupUri);
        }
        while (it.hasNext()) {
            CIMInstance portInstance = it.next();
            StoragePort port = checkStoragePortExistsInDB(portInstance, device, _dbClient);
            if (null == port) {
                _log.info("RA Group Port Not Found {}", portInstance.getObjectPath());
                continue;
            }
            if (portInstance.getObjectPath().toString().contains(sourceSystemSerialId)) {
                remoteGroup.setSourcePort(port.getId());
                _log.info("Source Port added :" + portInstance.getObjectPath());
            } else {
                remoteGroup.setRemotePort(port.getId());
                _log.info("Remote Port added :" + portInstance.getObjectPath());
            }
            _dbClient.persistObject(remoteGroup);
        }
    } catch (Exception e) {
        _log.error("Discovering Ports for RA Groups failed", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) StoragePort(com.emc.storageos.db.client.model.StoragePort) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 99 with StoragePort

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

the class CIMStoragePortUpdatableDeviceEvent method updateStoragePortOperationalStatus.

/**
 * Updates Port's operational status based on the indication received from SMI-S provider.
 *
 * @return true if success.
 */
public Boolean updateStoragePortOperationalStatus() {
    _logger.info("Updating operationalStatus for the StoragePort initiated");
    boolean updateStatus = false;
    StoragePort storagePort = getStoargePortFromDBBasedOnPortName();
    OperationalStatus operationalStatus = StoragePortProcessor.getPortOperationalStatus(getOperationalStatusCodesArray());
    newOperationalStatus = operationalStatus.name();
    storagePort.setOperationalStatus(newOperationalStatus);
    _dbClient.persistObject(storagePort);
    updateStatus = true;
    _logger.info("Updating operationalStatus for the StoragePort completed status:{}", updateStatus);
    return updateStatus;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) OperationalStatus(com.emc.storageos.db.client.model.StoragePort.OperationalStatus)

Example 100 with StoragePort

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

the class NetAppFileStorageDevice method findVfilerName.

/**
 * Return the vFiler name associated with the file system. If a vFiler is not associated with
 * this file system, then it will return null.
 */
private String findVfilerName(FileShare fs) {
    String portGroup = null;
    URI port = fs.getStoragePort();
    if (port == null) {
        _log.info("No storage port URI to retrieve vFiler name");
    } else {
        StoragePort stPort = _dbClient.queryObject(StoragePort.class, port);
        if (stPort != null) {
            URI haDomainUri = stPort.getStorageHADomain();
            if (haDomainUri == null) {
                _log.info("No Port Group URI for port {}", port);
            } else {
                StorageHADomain haDomain = _dbClient.queryObject(StorageHADomain.class, haDomainUri);
                if (haDomain != null && haDomain.getVirtual() == true) {
                    portGroup = stPort.getPortGroup();
                    _log.debug("using port {} and vFiler {}", stPort.getPortNetworkId(), portGroup);
                }
            }
        }
    }
    return portGroup;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI)

Aggregations

StoragePort (com.emc.storageos.db.client.model.StoragePort)477 URI (java.net.URI)285 ArrayList (java.util.ArrayList)261 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)143 HashMap (java.util.HashMap)134 List (java.util.List)130 NetworkLite (com.emc.storageos.util.NetworkLite)110 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 StringSet (com.emc.storageos.db.client.model.StringSet)92 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)84 HashSet (java.util.HashSet)81 Initiator (com.emc.storageos.db.client.model.Initiator)78 Map (java.util.Map)64 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)62 StoragePool (com.emc.storageos.db.client.model.StoragePool)51 IOException (java.io.IOException)48 StringMap (com.emc.storageos.db.client.model.StringMap)45 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)34