Search in sources :

Example 41 with StringSetMap

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

the class RPCommunicationInterface method discoverVisibleStorageSystems.

/**
 * Discovers the Storage Systems associated to the Protection System.
 *
 * @param protectionSystem A reference to the Protection System
 */
private void discoverVisibleStorageSystems(ProtectionSystem protectionSystem) {
    RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
    Map<String, Set<String>> siteStorageSystems = rp.getArraysForClusters();
    if (protectionSystem.getSiteVisibleStorageArrays() != null) {
        protectionSystem.getSiteVisibleStorageArrays().clear();
    } else {
        protectionSystem.setSiteVisibleStorageArrays(new StringSetMap());
    }
    List<URI> storageSystemIDs = _dbClient.queryByType(StorageSystem.class, true);
    if (storageSystemIDs == null) {
        return;
    }
    List<StorageSystem> storageSystems = _dbClient.queryObject(StorageSystem.class, storageSystemIDs);
    if (storageSystems == null) {
        return;
    }
    // (for the arrays ViPR knows about)
    if (siteStorageSystems != null) {
        for (Map.Entry<String, Set<String>> clusterEntry : siteStorageSystems.entrySet()) {
            if (clusterEntry.getValue() == null || clusterEntry.getValue().isEmpty()) {
                continue;
            }
            for (String serialNumber : clusterEntry.getValue()) {
                if (serialNumber == null || serialNumber.isEmpty()) {
                    continue;
                }
                // Find the storage system ID associated with this serial number
                // We have a serial number from the RP appliances, and for the most part, that works
                // with a Constraint Query, but in the case of VPLEX, the serial number object for distributed
                // VPLEX clusters will contain two serial numbers, not just one. So we need a long-form
                // way of finding those VPLEXs as well.
                Iterator<StorageSystem> activeSystemListItr = storageSystems.iterator();
                StorageSystem foundStorageSystem = null;
                while (activeSystemListItr.hasNext() && foundStorageSystem == null) {
                    StorageSystem system = activeSystemListItr.next();
                    if (NullColumnValueGetter.isNotNullValue(system.getSerialNumber()) && system.getSerialNumber().contains(serialNumber)) {
                        foundStorageSystem = system;
                    }
                }
                if (foundStorageSystem != null) {
                    protectionSystem.addSiteVisibleStorageArrayEntry(clusterEntry.getKey(), serialNumber);
                    _log.info(String.format("RP Discovery found RP cluster %s is configured to use a registered storage system: %s, %s", clusterEntry.getKey(), serialNumber, foundStorageSystem.getNativeGuid()));
                } else {
                    _log.info(String.format("RP Discovery found RP cluster %s is configured to use a storage system: %s, but it is not configured for use in ViPR", clusterEntry.getKey(), serialNumber));
                }
            }
        }
    }
    _dbClient.persistObject(protectionSystem);
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet) StringSet(com.emc.storageos.db.client.model.StringSet) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) URI(java.net.URI) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 42 with StringSetMap

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

the class VirtualPoolMapper method mapVirtualPoolFields.

private static <T extends VirtualPoolCommonRestRep> T mapVirtualPoolFields(VirtualPool from, T to, Map<URI, VpoolProtectionVarraySettings> protectionSettings) {
    mapDataObjectFieldsNoLink(from, to);
    ResourceTypeEnum type = ResourceTypeEnum.BLOCK_VPOOL;
    switch(VirtualPool.Type.valueOf(from.getType())) {
        case block:
            type = ResourceTypeEnum.BLOCK_VPOOL;
            break;
        case file:
            type = ResourceTypeEnum.FILE_VPOOL;
            break;
        case object:
            type = ResourceTypeEnum.OBJECT_VPOOL;
    }
    to.setLink(new RestLinkRep("self", RestLinkFactory.newLink(type, from.getId())));
    to.setType(from.getType());
    to.setDescription(from.getDescription());
    to.setProtocols(from.getProtocols());
    to.setProvisioningType(from.getSupportedProvisioningType());
    to.setNumPaths(from.getNumPaths());
    if (from.getArrayInfo() != null) {
        StringSetMap arrayInfo = from.getArrayInfo();
        // System Type
        StringSet systemTypes = arrayInfo.get(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE);
        if (systemTypes != null) {
            // TODO: CD - This does not seem right. Do we support many?
            for (String systemType : systemTypes) {
                to.setSystemType(systemType);
            }
        }
    }
    if (!VdcUtil.isRemoteObject(from)) {
        mapVirtualPoolCommonLocalMappings(from, to);
    }
    return to;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ResourceTypeEnum(com.emc.storageos.model.ResourceTypeEnum) RestLinkRep(com.emc.storageos.model.RestLinkRep) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 43 with StringSetMap

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

the class ExportMaskUtils method initializeExportMaskWithVolumes.

// don't want to disturb the existing method, hence overloaded
public static <T extends BlockObject> ExportMask initializeExportMaskWithVolumes(URI storage, ExportGroup exportGroup, String maskName, String maskLabel, List<Initiator> initiators, Map<URI, Integer> volumeMap, List<URI> targets, ZoneInfoMap zoneInfoMap, T volume, Set<String> unManagedInitiators, String nativeId, List<Initiator> userAddedInis, DbClient dbClient, Map<String, Integer> wwnToHluMap) throws Exception {
    ExportMask exportMask = new ExportMask();
    exportMask.setId(URIUtil.createId(ExportMask.class));
    exportMask.setMaskName(maskName);
    exportMask.setStorageDevice(storage);
    String resourceRef;
    if (exportGroup.getType() != null) {
        if (exportGroup.getType().equals(ExportGroup.ExportGroupType.Cluster.name())) {
            resourceRef = initiators.get(0).getClusterName();
        } else {
            resourceRef = initiators.get(0).getHost().toString();
        }
        exportMask.setResource(resourceRef);
    } else {
        // This resource is used when we add initiators to existing masks on VMAX, which should not be
        // case with VPLEX and RP, which do not associate their initiators with hosts or clusters.
        exportMask.setResource(NullColumnValueGetter.getNullURI().toString());
    }
    exportMask.setLabel(maskLabel);
    exportMask.setCreatedBySystem(true);
    exportMaskUpdate(exportMask, null, initiators, targets);
    StringSetMap zoneMap = getZoneMapFromZoneInfoMap(zoneInfoMap, initiators);
    if (!zoneMap.isEmpty()) {
        exportMask.setZoningMap(zoneMap);
    }
    exportMask.addToExistingInitiatorsIfAbsent(new ArrayList<String>(unManagedInitiators));
    exportMask.addToUserCreatedInitiators(userAddedInis);
    // if the block object is marked as internal, then add to existing volumes of the mask
    if (volume.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
        _log.info("Block object {} is marked internal. Adding to existing volumes of the mask {}", volume.getNativeGuid(), exportMask.getMaskName());
        String hlu = ExportGroup.LUN_UNASSIGNED_STR;
        if (wwnToHluMap.containsKey(volume.getWWN())) {
            hlu = String.valueOf(wwnToHluMap.get(volume.getWWN()));
        }
        exportMask.addToExistingVolumesIfAbsent(volume, hlu);
    } else {
        exportMask.addToUserCreatedVolumes(volume);
        exportMask.removeFromExistingVolumes(volume);
    }
    Integer hlu = wwnToHluMap.get(volume.getWWN()) != null ? wwnToHluMap.get(volume.getWWN()) : ExportGroup.LUN_UNASSIGNED;
    exportMask.addVolume(volume.getId(), hlu);
    exportMask.setNativeId(nativeId);
    // need to sync up all remaining existing volumes
    exportMask.addToExistingVolumesIfAbsent(wwnToHluMap);
    // Update the FCZoneReferences if zoning is enables for the varray
    updateFCZoneReferences(exportGroup, exportMask, volume, zoneInfoMap, initiators, dbClient);
    return exportMask;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask)

Example 44 with StringSetMap

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

the class ExportMaskUtils method getNewPaths.

/*
     * Get new paths which are not in any of the export masks zoning maps from the given paths
     * 
     * @param dbClient
     * @param exportMasks
     * @param maskURIs - OUTPUT the export masks URI list which have zoning map entries
     * @param paths - new and retained paths
     * @return - the new paths for the export masks
     */
public static Map<URI, List<URI>> getNewPaths(DbClient dbClient, List<ExportMask> exportMasks, List<URI> maskURIs, Map<URI, List<URI>> paths) {
    Map<URI, List<URI>> newPaths = new HashMap<URI, List<URI>>();
    StringSetMap allZoningMap = new StringSetMap();
    for (ExportMask mask : exportMasks) {
        StringSetMap map = mask.getZoningMap();
        if (map != null && !map.isEmpty()) {
            for (String init : map.keySet()) {
                StringSet allPorts = allZoningMap.get(init);
                if (allPorts == null) {
                    allPorts = new StringSet();
                    allZoningMap.put(init, allPorts);
                }
                allPorts.addAll(map.get(init));
            }
            maskURIs.add(mask.getId());
        }
    }
    for (Map.Entry<URI, List<URI>> entry : paths.entrySet()) {
        URI init = entry.getKey();
        List<URI> entryPorts = entry.getValue();
        StringSet zoningPorts = allZoningMap.get(init.toString());
        if (zoningPorts != null && !zoningPorts.isEmpty()) {
            List<URI> diffPorts = new ArrayList<URI>(Sets.difference(newHashSet(entryPorts), zoningPorts));
            if (diffPorts != null && !diffPorts.isEmpty()) {
                newPaths.put(init, diffPorts);
            }
        } else {
            newPaths.put(init, entryPorts);
        }
    }
    return newPaths;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) 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 45 with StringSetMap

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

the class ExportMaskUtils method initializeExportMask.

/**
 * Create and initialize the ExportMask. To do this we:
 * 1. Create and persist the ExportMask.
 * 2. Save our targets and exportMaskURI in the ExportGroupCreateData.
 *
 * @param storage - Storage System
 * @param exportGroup - ExportGroup object this ExportMask will apply to
 * @param initiators - Initiator objects pointing to initiators for this mask
 * @param volumeMap - Map of Volume URIs to Integer HLUs
 * @param targets List<URI> of StoragePorts
 * @param zoneAssignments - Map from InitiatorURI to List of assigned port URIs.
 * @param maskName the mask name
 * @param dbClient an instance of DbClient
 * @return new ExportMask object, persisted in database
 * @throws Exception
 */
public static ExportMask initializeExportMask(StorageSystem storage, ExportGroup exportGroup, List<Initiator> initiators, Map<URI, Integer> volumeMap, List<URI> targets, Map<URI, List<URI>> zoneAssignments, String maskName, DbClient dbClient) throws Exception {
    if (maskName == null) {
        maskName = ExportMaskUtils.getMaskName(dbClient, initiators, exportGroup, storage);
    }
    ExportMask exportMask = ExportMaskUtils.createExportMask(dbClient, exportGroup, storage.getId(), maskName);
    String resourceRef;
    if (exportGroup.getType() != null) {
        if (exportGroup.getType().equals(ExportGroup.ExportGroupType.Cluster.name())) {
            resourceRef = initiators.get(0).getClusterName();
        } else {
            resourceRef = initiators.get(0).getHost().toString();
        }
        exportMask.setResource(resourceRef);
    } else {
        // This resource is used when we add initiators to existing masks on VMAX, which should not be
        // case with VPLEX and RP, which do not associate their initiators with hosts or clusters.
        exportMask.setResource(NullColumnValueGetter.getNullURI().toString());
    }
    exportMask.setCreatedBySystem(true);
    exportMaskUpdate(exportMask, volumeMap, initiators, targets);
    if (!exportGroup.getZoneAllInitiators() && null != zoneAssignments) {
        StringSetMap zoneMap = getZoneMapFromAssignments(zoneAssignments);
        if (!zoneMap.isEmpty()) {
            exportMask.setZoningMap(zoneMap);
        }
    }
    dbClient.updateObject(exportMask);
    return exportMask;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask)

Aggregations

StringSetMap (com.emc.storageos.db.client.model.StringSetMap)158 StringSet (com.emc.storageos.db.client.model.StringSet)95 URI (java.net.URI)72 ArrayList (java.util.ArrayList)68 List (java.util.List)49 HashMap (java.util.HashMap)43 StoragePort (com.emc.storageos.db.client.model.StoragePort)37 Map (java.util.Map)32 Initiator (com.emc.storageos.db.client.model.Initiator)31 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 StringMap (com.emc.storageos.db.client.model.StringMap)31 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)26 ExportMask (com.emc.storageos.db.client.model.ExportMask)25 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)25 HashSet (java.util.HashSet)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)18 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)17 Test (org.junit.Test)16