Search in sources :

Example 71 with Initiator

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

the class VolumeIngestionUtil method updateExportGroup.

/**
 * Update an ExportGroup.
 *
 * @param exportGroup the ExportGroup to update
 * @param volume a BlockObject for the ExportGroup
 * @param wwnToHluMap the wwn to hlu map
 * @param dbClient a reference to the database client
 * @param allInitiators a List of all initiators for the ExportGroup
 * @param hosts a List of Hosts for the ExportGroup
 * @param cluster a Cluster for the ExportGroup
 */
public static <T extends BlockObject> void updateExportGroup(ExportGroup exportGroup, T volume, Map<String, Integer> wwnToHluMap, DbClient dbClient, List<Initiator> allInitiators, List<Host> hosts, Cluster cluster) {
    for (Host host : hosts) {
        if (null == exportGroup.getHosts() || !exportGroup.getHosts().contains(host.getId().toString())) {
            exportGroup.addHost(host);
        }
    }
    if (null != cluster && (null == exportGroup.getClusters() || !exportGroup.getClusters().contains(cluster.getId().toString()))) {
        exportGroup.addCluster(cluster);
    }
    for (Initiator ini : allInitiators) {
        if (exportGroup.getInitiators() == null || !exportGroup.getInitiators().contains(ini.getId().toString())) {
            exportGroup.addInitiator(ini);
        }
    }
    // Do not add the block object to the export group if it is partially ingested
    if (!volume.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
        _logger.info("adding volume {} to export group {}", volume.forDisplay(), exportGroup.forDisplay());
        Integer hlu = ExportGroup.LUN_UNASSIGNED;
        if (wwnToHluMap.containsKey(volume.getWWN())) {
            hlu = wwnToHluMap.get(volume.getWWN());
        }
        exportGroup.addVolume(volume.getId(), hlu);
    } else {
        _logger.info("volume {} is partially ingested, so not adding to export group {}", volume.forDisplay(), exportGroup.forDisplay());
    }
    if (volume instanceof Volume) {
        Volume vol = (Volume) volume;
        URI haVarray = checkVplexHighAvailabilityArray(vol, dbClient);
        if (null != haVarray) {
            exportGroup.putAltVirtualArray(volume.getStorageController().toString(), haVarray.toString());
        }
    }
}
Also used : BigInteger(java.math.BigInteger) Initiator(com.emc.storageos.db.client.model.Initiator) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) Host(com.emc.storageos.db.client.model.Host) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 72 with Initiator

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

the class VolumeIngestionUtil method createExportMask.

/**
 * Creates an ExportMask for the given arguments and returns the BlockObject.
 *
 * @param eligibleMask an UnManagedExportMask to base the ExportMask on
 * @param unManagedVolume the UnManagedVolume being ingested
 * @param exportGroup the ExportGroup for the ExportMask
 * @param volume the Volume object for the ExportMask
 * @param dbClient a reference to the database client
 * @param hosts a List of Hosts for the ExportMask
 * @param cluster a Cluster for the ExportMask
 * @param exportMaskLabel the name of the ExportMask
 * @throws Exception
 */
public static <T extends BlockObject> ExportMask createExportMask(UnManagedExportMask eligibleMask, UnManagedVolume unManagedVolume, ExportGroup exportGroup, T volume, DbClient dbClient, List<Host> hosts, Cluster cluster, String exportMaskLabel) throws Exception {
    _logger.info("Creating ExportMask for unManaged Mask {}", eligibleMask.getMaskName());
    List<URI> initiatorUris = new ArrayList<URI>(Collections2.transform(eligibleMask.getKnownInitiatorUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
    List<Initiator> allInitiators = dbClient.queryObject(Initiator.class, initiatorUris);
    List<Initiator> userAddedInis = VolumeIngestionUtil.findUserAddedInisFromExistingIniListInMask(allInitiators, eligibleMask.getId(), dbClient);
    List<URI> storagePortUris = new ArrayList<URI>(Collections2.transform(eligibleMask.getKnownStoragePortUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
    Map<String, Integer> wwnToHluMap = extractWwnToHluMap(eligibleMask, dbClient);
    ExportMask exportMask = ExportMaskUtils.initializeExportMaskWithVolumes(eligibleMask.getStorageSystemUri(), exportGroup, eligibleMask.getMaskName(), exportMaskLabel, allInitiators, null, storagePortUris, eligibleMask.getZoningMap(), volume, eligibleMask.getUnmanagedInitiatorNetworkIds(), eligibleMask.getNativeId(), userAddedInis, dbClient, wwnToHluMap);
    // remove unmanaged mask if created if the block object is not marked as internal
    if (!volume.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
        _logger.info("breaking relationship between UnManagedExportMask {} and UnManagedVolume {}", eligibleMask.getMaskName(), unManagedVolume.getLabel());
        unManagedVolume.getUnmanagedExportMasks().remove(eligibleMask.getId().toString());
        eligibleMask.getUnmanagedVolumeUris().remove(unManagedVolume.getId().toString());
    }
    updateExportGroup(exportGroup, volume, wwnToHluMap, dbClient, allInitiators, hosts, cluster);
    return exportMask;
}
Also used : BigInteger(java.math.BigInteger) Initiator(com.emc.storageos.db.client.model.Initiator) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 73 with Initiator

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

the class VolumeIngestionUtil method groupInitiatorsByHost.

/**
 * Group Initiators by Host containing them and return a
 * Map of Host to Initiators the Host contains.
 *
 * @param iniStrList a set of Initiator URI Strings
 * @param dbClient a reference to the database client
 * @return a Map of Host to Initiators the Host contains
 */
private static Map<String, Set<String>> groupInitiatorsByHost(Set<String> iniStrList, DbClient dbClient) {
    Map<String, Set<String>> iniByHost = new HashMap<String, Set<String>>();
    List<URI> iniList = new ArrayList<URI>(Collections2.transform(iniStrList, CommonTransformerFunctions.FCTN_STRING_TO_URI));
    List<Initiator> initiators = dbClient.queryObject(Initiator.class, iniList);
    for (Initiator ini : initiators) {
        if (null == ini.getHost()) {
            _logger.warn("Initiator {} with Host set to Null", ini.getId());
            continue;
        }
        if (!iniByHost.containsKey(ini.getHost())) {
            iniByHost.put(ini.getHost().toString(), new HashSet<String>());
        }
        iniByHost.get(ini.getHost().toString()).add(ini.getId().toString());
    }
    return iniByHost;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 74 with Initiator

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

the class VolumeIngestionUtil method findUnManagedExportMasksForHost.

/**
 * Returns a List of the UnManagedExportMasks associated with a given Host URI.
 *
 * @param hostUri the Host URI to check
 * @param dbClient a reference to the database client
 * @return a List of the UnManagedExportMasks associated with a given Host URI
 */
public static List<UnManagedExportMask> findUnManagedExportMasksForHost(URI hostUri, DbClient dbClient) {
    _logger.info("finding unmanaged export masks for host " + hostUri);
    List<UnManagedExportMask> uems = new ArrayList<UnManagedExportMask>();
    List<Initiator> initiators = ComputeSystemHelper.queryInitiators(dbClient, hostUri);
    Set<URI> uemUris = new HashSet<URI>();
    URIQueryResultList results = new URIQueryResultList();
    for (Initiator initiator : initiators) {
        _logger.info("      looking at initiator " + initiator.getInitiatorPort());
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedExportMaskKnownInitiatorConstraint(initiator.getInitiatorPort()), results);
        if (results.iterator() != null) {
            for (URI uri : results) {
                _logger.info("      found UnManagedExportMask " + uri);
                uemUris.add(uri);
            }
        }
    }
    for (URI uemUri : uemUris) {
        UnManagedExportMask uem = dbClient.queryObject(UnManagedExportMask.class, uemUri);
        if (uem == null || uem.getInactive() == true) {
            continue;
        }
        uems.add(uem);
        _logger.info("   maskName: " + uem.getMaskName() + " nativeGuid: " + uem.getNativeGuid());
    }
    if (uems.isEmpty()) {
        _logger.info("   did not find any unmanaged export masks for this host");
    }
    return uems;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) HashSet(java.util.HashSet)

Example 75 with Initiator

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

the class VolumeIngestionUtil method verifyHostNumPath.

/**
 * Given the zoneInfoMap, check the existing paths to make sure they
 * comply with the ingestion vpool requirements.
 *
 * @param pathParams the ingestion parameter
 * @param initiators the host initiators to be checked
 * @param zoneInfoMap the zoneInfoMap that is stored in the UnManagedExportMask
 * @param dbClient a reference to the database client
 * @return true if the host paths are compliant. False otherwise.
 */
private static boolean verifyHostNumPath(ExportPathParams pathParams, List<Initiator> initiators, ZoneInfoMap zoneInfoMap, DbClient dbClient) {
    _logger.info("verifyHostNumPath for initiators {} with zoningMap {}", initiators, zoneInfoMap);
    if (initiators == null || initiators.isEmpty()) {
        _logger.error("Host has no initiators configured.");
        throw IngestionException.exceptions.hostHasNoInitiators();
    }
    int unassignedInitiators = 0;
    int totalPaths = 0;
    StringSetMap zoningMap = ExportMaskUtils.getZoneMapFromZoneInfoMap(zoneInfoMap, initiators);
    if (null == zoningMap || zoningMap.isEmpty()) {
        _logger.error("No zoning information found for the initiators");
        List<String> messageArray = new ArrayList<String>();
        for (Initiator init : initiators) {
            messageArray.add(init.getHostName() + ":" + init.getInitiatorPort());
        }
        throw IngestionException.exceptions.hostHasNoZoning(Joiner.on(", ").join(messageArray));
    }
    if (VPlexControllerUtils.isVplexInitiator(initiators.get(0), dbClient)) {
        _logger.info("these are VPLEX backend initiators, " + "so no need to validate against virtual pool path params");
        return true;
    }
    String hostName = initiators.get(0).getHostName();
    URI hostURI = initiators.get(0).getHost() == null ? URIUtil.NULL_URI : initiators.get(0).getHost();
    _logger.info("Checking numpath for host {}", hostName);
    for (Initiator initiator : initiators) {
        if (initiator.getHostName() != null) {
            hostName = initiator.getHostName();
        }
        StringSet ports = zoningMap.get(initiator.getId().toString());
        if (ports == null || ports.isEmpty()) {
            unassignedInitiators++;
            _logger.info("Initiator {} of host {} is not assigned to any ports.", new Object[] { initiator.getInitiatorPort(), hostName });
        } else if (ports.size() < pathParams.getPathsPerInitiator()) {
            _logger.error("Initiator {} of host {} has fewer SAN paths than what is required according to the virtual pool " + "({} are zoned, but {} are required)", new Object[] { initiator.getInitiatorPort(), hostName, ports.size(), pathParams.getPathsPerInitiator() });
            throw IngestionException.exceptions.hostZoningHasDifferentPortCount(initiator.getInitiatorPort(), hostName, String.valueOf(ports.size()), String.valueOf(pathParams.getPathsPerInitiator()));
        } else {
            totalPaths += ports.size();
            _logger.info("Initiator {} of host {} has {} paths", new Object[] { initiator.getInitiatorPort(), hostName, ports.size(), ports.size() });
        }
    }
    if (totalPaths < pathParams.getMinPaths()) {
        _logger.error(String.format("Host %s (%s) has fewer paths assigned %d than min_paths %d", hostName, hostURI.toString(), totalPaths, pathParams.getMinPaths()));
        throw IngestionException.exceptions.hostZoningHasFewerPorts(hostName, String.valueOf(totalPaths), String.valueOf(pathParams.getMinPaths()));
    }
    if (totalPaths > pathParams.getMaxPaths()) {
        _logger.warn(String.format("Host %s (%s) has more paths assigned %d than max_paths %d", hostName, hostURI.toString(), totalPaths, pathParams.getMaxPaths()));
    }
    if (unassignedInitiators > 0) {
        _logger.info(String.format("Host %s (%s) has %d unassigned initiators", hostName, hostURI.toString(), unassignedInitiators));
    }
    return true;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) DataObject(com.emc.storageos.db.client.model.DataObject) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Aggregations

Initiator (com.emc.storageos.db.client.model.Initiator)487 URI (java.net.URI)345 ArrayList (java.util.ArrayList)266 HashMap (java.util.HashMap)170 HashSet (java.util.HashSet)161 ExportMask (com.emc.storageos.db.client.model.ExportMask)156 List (java.util.List)119 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)102 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)98 Map (java.util.Map)85 StringSet (com.emc.storageos.db.client.model.StringSet)83 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)82 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)81 StoragePort (com.emc.storageos.db.client.model.StoragePort)78 NamedURI (com.emc.storageos.db.client.model.NamedURI)73 Set (java.util.Set)72 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)58 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)57 StringMap (com.emc.storageos.db.client.model.StringMap)55 Host (com.emc.storageos.db.client.model.Host)54