Search in sources :

Example 6 with VNXeHost

use of com.emc.storageos.vnxe.models.VNXeHost in project coprhd-controller by CoprHD.

the class VNXeApiClient method getHostLUNWWNs.

/**
 * Get host LUN WWN and HLU
 *
 * @param hostId
 * @return host LUN WWN to HLU map
 */
public Map<String, Integer> getHostLUNWWNs(String hostId) {
    Map<String, Integer> lunWWNToHLUs = new HashMap<>();
    VNXeHost host = getHostById(hostId);
    if (host != null) {
        List<VNXeBase> hostLunIds = host.getHostLUNs();
        if (hostLunIds != null && !hostLunIds.isEmpty()) {
            for (VNXeBase hostLunId : hostLunIds) {
                HostLun hostLun = getHostLun(hostLunId.getId());
                String wwn = null;
                if (hostLun.getType() == HostLUNTypeEnum.LUN_SNAP.getValue()) {
                    VNXeBase snapId = hostLun.getSnap();
                    wwn = getSnapWWN(snapId.getId());
                } else {
                    VNXeBase lunId = hostLun.getLun();
                    VNXeLun vnxeLun = getLun(lunId.getId());
                    wwn = vnxeLun.getWwn();
                }
                lunWWNToHLUs.put(wwn, hostLun.getHlu());
            }
        }
    }
    return lunWWNToHLUs;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) HashMap(java.util.HashMap) HostLun(com.emc.storageos.vnxe.models.HostLun) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost)

Example 7 with VNXeHost

use of com.emc.storageos.vnxe.models.VNXeHost in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverUnmanagedExportMasks.

/**
 * Create unmanaged export masks per host
 *
 * @param systemId
 * @param hostVolumesMap
 *            host-- exportedvolume list
 * @param apiClient
 * @param dbClient
 * @param partitionManager
 * @throws Exception
 */
private void discoverUnmanagedExportMasks(URI systemId, Map<String, List<UnManagedVolume>> hostVolumesMap, VNXeApiClient apiClient, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
    unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
    List<UnManagedVolume> unManagedExportVolumesToUpdate = new ArrayList<UnManagedVolume>();
    // In Unity, the volumes are exposed through all the storage ports.
    // Get all the storage ports to be added as known ports in the unmanaged export mask
    // If the host ports are FC, then add all FC storage ports to the mask
    // else add all IP ports
    StringSet knownFCStoragePortUris = new StringSet();
    StringSet knownIPStoragePortUris = new StringSet();
    List<StoragePort> matchedFCPorts = new ArrayList<StoragePort>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(systemId), storagePortURIs);
    Iterator<URI> portsItr = storagePortURIs.iterator();
    while (portsItr.hasNext()) {
        URI storagePortURI = portsItr.next();
        StoragePort port = dbClient.queryObject(StoragePort.class, storagePortURI);
        if (TransportType.FC.toString().equals(port.getTransportType())) {
            knownFCStoragePortUris.add(storagePortURI.toString());
            matchedFCPorts.add(port);
        } else if (TransportType.IP.toString().equals(port.getTransportType())) {
            knownIPStoragePortUris.add(storagePortURI.toString());
        }
    }
    for (Map.Entry<String, List<UnManagedVolume>> entry : hostVolumesMap.entrySet()) {
        String hostId = entry.getKey();
        List<UnManagedVolume> volumes = entry.getValue();
        StringSet knownInitSet = new StringSet();
        StringSet knownNetworkIdSet = new StringSet();
        StringSet knownVolumeSet = new StringSet();
        List<Initiator> matchedFCInitiators = new ArrayList<Initiator>();
        VNXeHost host = apiClient.getHostById(hostId);
        List<VNXeBase> fcInits = host.getFcHostInitiators();
        List<VNXeBase> iScsiInits = host.getIscsiHostInitiators();
        boolean isVplexHost = false;
        boolean isRPHost = false;
        Set<URI> hostURIs = new HashSet<>();
        if (fcInits != null && !fcInits.isEmpty()) {
            for (VNXeBase init : fcInits) {
                VNXeHostInitiator initiator = apiClient.getHostInitiator(init.getId());
                String portwwn = initiator.getPortWWN();
                if (portwwn == null || portwwn.isEmpty()) {
                    continue;
                }
                Initiator knownInitiator = NetworkUtil.getInitiator(portwwn, dbClient);
                if (knownInitiator != null) {
                    knownInitSet.add(knownInitiator.getId().toString());
                    knownNetworkIdSet.add(portwwn);
                    matchedFCInitiators.add(knownInitiator);
                    URI hostURI = knownInitiator.getHost();
                    if (!NullColumnValueGetter.isNullURI(hostURI) && URIUtil.isType(hostURI, Host.class)) {
                        hostURIs.add(hostURI);
                    }
                } else {
                    knownInitiator = new Initiator();
                    knownInitiator.setInitiatorPort(portwwn);
                }
                if (!isVplexHost && VPlexControllerUtils.isVplexInitiator(knownInitiator, dbClient)) {
                    isVplexHost = true;
                }
            }
        }
        if (!matchedFCInitiators.isEmpty() && ExportUtils.checkIfInitiatorsForRP(matchedFCInitiators)) {
            log.info("host {} contains RP initiators, " + "so this mask contains RP protected volumes", host.getName());
            isRPHost = true;
        }
        if (iScsiInits != null && !iScsiInits.isEmpty()) {
            for (VNXeBase init : iScsiInits) {
                VNXeHostInitiator initiator = apiClient.getHostInitiator(init.getId());
                String portwwn = initiator.getInitiatorId();
                if (portwwn == null || portwwn.isEmpty()) {
                    continue;
                }
                Initiator knownInitiator = NetworkUtil.getInitiator(portwwn, dbClient);
                if (knownInitiator != null) {
                    knownInitSet.add(knownInitiator.getId().toString());
                    knownNetworkIdSet.add(portwwn);
                    URI hostURI = knownInitiator.getHost();
                    if (!NullColumnValueGetter.isNullURI(hostURI) && URIUtil.isType(hostURI, Host.class)) {
                        hostURIs.add(hostURI);
                    }
                }
            }
        }
        if (knownNetworkIdSet.isEmpty()) {
            log.info(String.format("The host %s does not have any known initiators", hostId));
            continue;
        }
        if (hostURIs.size() > 1) {
            log.warn(String.format("Skip export on host %s as the initiators on the host belong to more than one hosts in DB %s", hostId, Joiner.on(",").join(hostURIs)));
            continue;
        }
        String firstNetworkId = knownNetworkIdSet.iterator().next();
        UnManagedExportMask mask = getUnManagedExportMask(firstNetworkId, dbClient, systemId);
        mask.setStorageSystemUri(systemId);
        // set the host name as the mask name
        mask.setMaskName(host.getName());
        allCurrentUnManagedExportMaskUris.add(mask.getId());
        for (UnManagedVolume hostUnManagedVol : volumes) {
            hostUnManagedVol.getInitiatorNetworkIds().addAll(knownNetworkIdSet);
            hostUnManagedVol.getInitiatorUris().addAll(knownInitSet);
            hostUnManagedVol.getUnmanagedExportMasks().add(mask.getId().toString());
            if (isVplexHost) {
                log.info("marking unmanaged unity volume {} as a VPLEX backend volume", hostUnManagedVol.getLabel());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VPLEX_BACKEND_VOLUME.toString(), Boolean.TRUE.toString());
            }
            if (isRPHost) {
                log.info("unmanaged volume {} is an RP volume", hostUnManagedVol.getLabel());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), Boolean.TRUE.toString());
            } else {
                log.info("unmanaged volume {} is exported to something other than RP.  Marking IS_NONRP_EXPORTED.", hostUnManagedVol.forDisplay());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), Boolean.TRUE.toString());
            }
            mask.getUnmanagedVolumeUris().add(hostUnManagedVol.getId().toString());
            // update mask to HLU information
            StringSet nativeId = hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.NATIVE_ID.name());
            String nativeGuid = hostUnManagedVol.getNativeGuid();
            String lunId = (nativeId != null && nativeId.iterator().hasNext()) ? nativeId.iterator().next() : nativeGuid.substring(nativeGuid.lastIndexOf(Constants.PLUS) + 1);
            String idCharSequence = HostLunRequests.ID_SEQUENCE_LUN;
            if (Boolean.valueOf(hostUnManagedVol.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_SNAP_SHOT.name()))) {
                idCharSequence = HostLunRequests.ID_SEQUENCE_SNAP;
                Snap snap = apiClient.getSnapshot(lunId);
                // get snap's parent id
                lunId = snap.getLun().getId();
            }
            HostLun hostLun = apiClient.getHostLun(lunId, hostId, idCharSequence);
            if (hostLun != null) {
                String hostHlu = host.getName() + "=" + hostLun.getHlu();
                StringSet existingHostHlu = hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name());
                if (existingHostHlu != null) {
                    existingHostHlu.add(hostHlu);
                } else {
                    hostUnManagedVol.getVolumeInformation().put(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name(), hostHlu);
                }
            }
            unManagedExportVolumesToUpdate.add(hostUnManagedVol);
        }
        mask.replaceNewWithOldResources(knownInitSet, knownNetworkIdSet, knownVolumeSet, !matchedFCInitiators.isEmpty() ? knownFCStoragePortUris : knownIPStoragePortUris);
        updateZoningMap(mask, matchedFCInitiators, matchedFCPorts);
    }
    if (!unManagedExportMasksToCreate.isEmpty()) {
        partitionManager.insertInBatches(unManagedExportMasksToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
        unManagedExportMasksToCreate.clear();
    }
    if (!unManagedExportMasksToUpdate.isEmpty()) {
        partitionManager.updateInBatches(unManagedExportMasksToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
        unManagedExportMasksToUpdate.clear();
    }
    if (!unManagedExportVolumesToUpdate.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(unManagedExportVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedExportVolumesToUpdate.clear();
    }
    DiscoveryUtils.markInActiveUnManagedExportMask(systemId, allCurrentUnManagedExportMaskUris, dbClient, partitionManager);
}
Also used : ArrayList(java.util.ArrayList) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) Snap(com.emc.storageos.vnxe.models.Snap) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) 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) StoragePort(com.emc.storageos.db.client.model.StoragePort) HostLun(com.emc.storageos.vnxe.models.HostLun) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) Host(com.emc.storageos.db.client.model.Host) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 8 with VNXeHost

use of com.emc.storageos.vnxe.models.VNXeHost in project coprhd-controller by CoprHD.

the class VNXeExportMaskVolumesValidator method validate.

@Override
public boolean validate() throws Exception {
    log.info("Initiating volume validation of VNXe ExportMask: " + getId());
    DbClient dbClient = getDbClient();
    VNXeApiClient apiClient = getApiClient();
    ExportMask exportMask = getExportMask();
    try {
        String vnxeHostId = getHostId();
        if (vnxeHostId != null) {
            VNXeHost vnxeHost = apiClient.getHostById(vnxeHostId);
            if (vnxeHost != null) {
                Set<String> lunIds = ExportUtils.getAllLUNsForHost(dbClient, exportMask);
                Set<String> lunIdsOnArray = apiClient.getHostLUNIds(vnxeHostId);
                lunIdsOnArray.removeAll(lunIds);
                if (!lunIdsOnArray.isEmpty()) {
                    String unknownLUNs = Joiner.on(',').join(lunIdsOnArray);
                    log.info("Unknown LUN/LUN Snap {}", unknownLUNs);
                    getLogger().logDiff(exportMask.getId().toString(), "volumes", ValidatorLogger.NO_MATCHING_ENTRY, unknownLUNs);
                }
            }
        }
    } catch (Exception ex) {
        log.error("Unexpected exception validating ExportMask volumes: " + ex.getMessage(), ex);
        throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask volumes: " + ex.getMessage());
    }
    setRemediation(unknownLUNRemediation);
    checkForErrors();
    log.info("Completed volume validation of VNXe ExportMask: " + getId());
    return true;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 9 with VNXeHost

use of com.emc.storageos.vnxe.models.VNXeHost in project coprhd-controller by CoprHD.

the class VNXeExportOperations method refreshExportMask.

@Override
public ExportMask refreshExportMask(StorageSystem storage, ExportMask mask) throws DeviceControllerException {
    _logger.info("Refreshing export mask {}", mask.getMaskName());
    try {
        VNXeApiClient apiClient = getVnxeClient(storage);
        List<Initiator> initiatorList = ExportUtils.getExportMaskInitiators(mask, _dbClient);
        String vnxeHostId = getHostIdFromInitiators(initiatorList, apiClient);
        if (vnxeHostId != null) {
            VNXeHost vnxeHost = apiClient.getHostById(vnxeHostId);
            if (vnxeHost != null) {
                Map<String, Integer> discoveredVolumes = apiClient.getHostLUNWWNs(vnxeHostId);
                // Clear the existing volumes to update with the latest info
                if (mask.getExistingVolumes() != null && !mask.getExistingVolumes().isEmpty()) {
                    mask.getExistingVolumes().clear();
                }
                // COP-27296 fix
                if (null == mask.getUserAddedVolumes()) {
                    mask.setUserAddedVolumes(new StringMap());
                }
                Set<String> existingVolumes = Sets.difference(discoveredVolumes.keySet(), mask.getUserAddedVolumes().keySet());
                _logger.info(String.format("VNXe discovered volumes: {%s}%n", Joiner.on(',').join(discoveredVolumes.keySet())));
                _logger.info(String.format("%nVNXe existing volumes : {%s}%n", Joiner.on(',').join(existingVolumes)));
                for (String lunId : existingVolumes) {
                    mask.addToExistingVolumesIfAbsent(lunId, discoveredVolumes.get(lunId).toString());
                }
                // Update user added volume's HLU information in ExportMask and ExportGroup
                ExportMaskUtils.updateHLUsInExportMask(mask, discoveredVolumes, _dbClient);
                _dbClient.updateObject(mask);
            }
        }
    } catch (Exception e) {
        _logger.warn("Error on refreshing export mask {}", mask.getMaskName());
    }
    return mask;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 10 with VNXeHost

use of com.emc.storageos.vnxe.models.VNXeHost in project coprhd-controller by CoprHD.

the class VNXUnityArrayAffinityDiscoverer method getHostURI.

/**
 * Find host URI from host Id on array
 *
 * @param apiClient
 * @param hostId
 * @param dbClient
 * @param hostIdToHostURIMap
 * @return host URI or NULL_URI
 */
private URI getHostURI(VNXeApiClient apiClient, String hostId, DbClient dbClient, Map<String, URI> hostIdToHostURIMap) {
    if (hostIdToHostURIMap.containsKey(hostId)) {
        return hostIdToHostURIMap.get(hostId);
    }
    VNXeHost vnxeHost = apiClient.getHostById(hostId);
    URI hostURI = findHostURI(vnxeHost.getFcHostInitiators(), apiClient, dbClient);
    if (hostURI == null) {
        hostURI = findHostURI(vnxeHost.getIscsiHostInitiators(), apiClient, dbClient);
    }
    if (hostURI == null) {
        hostURI = NullColumnValueGetter.getNullURI();
    }
    hostIdToHostURIMap.put(hostId, hostURI);
    return hostURI;
}
Also used : VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) URI(java.net.URI)

Aggregations

VNXeHost (com.emc.storageos.vnxe.models.VNXeHost)12 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)6 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 HostLun (com.emc.storageos.vnxe.models.HostLun)5 Initiator (com.emc.storageos.db.client.model.Initiator)4 VNXeHostInitiator (com.emc.storageos.vnxe.models.VNXeHostInitiator)4 ArrayList (java.util.ArrayList)4 StringMap (com.emc.storageos.db.client.model.StringMap)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 VNXeException (com.emc.storageos.vnxe.VNXeException)3 URI (java.net.URI)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)2 ExportRule (com.emc.storageos.model.file.ExportRule)2 VNXeLun (com.emc.storageos.vnxe.models.VNXeLun)2 VNXeNfsShare (com.emc.storageos.vnxe.models.VNXeNfsShare)2 List (java.util.List)2 Map (java.util.Map)2