Search in sources :

Example 1 with StorageSystemConnectivityRestRep

use of com.emc.storageos.model.systems.StorageSystemConnectivityRestRep in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method getStorageSystemConnectivity.

@Override
public StorageSystemConnectivityList getStorageSystemConnectivity(final StorageSystem system) {
    StorageSystemConnectivityList connectivityList = new StorageSystemConnectivityList();
    // Set used to ensure unique values are added to the connectivity list
    Set<String> existing = new HashSet<String>();
    if (system.getRemotelyConnectedTo() != null) {
        for (String remoteSystemUri : system.getRemotelyConnectedTo()) {
            if (remoteSystemUri == null || NullColumnValueGetter.getNullStr().equals(remoteSystemUri)) {
                continue;
            }
            StorageSystem remoteSystem = _dbClient.queryObject(StorageSystem.class, URI.create(remoteSystemUri));
            if (remoteSystem != null) {
                StorageSystemConnectivityRestRep connection = new StorageSystemConnectivityRestRep();
                connection.getConnectionTypes().add(SupportedReplicationTypes.SRDF.toString());
                connection.setProtectionSystem(toNamedRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, URI.create(remoteSystemUri), remoteSystem.getSerialNumber()));
                connection.setStorageSystem(toNamedRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, system.getId(), system.getSerialNumber()));
                // The key is a transient unique ID, since none of the actual fields guarantee
                // uniqueness.
                // We use this to make sure we don't add the same storage system more than once
                // for the same
                // protection system and connection type.
                String key = connection.getProtectionSystem().toString() + connection.getConnectionTypes() + connection.getStorageSystem().toString();
                if (!existing.contains(key)) {
                    existing.add(key);
                    connectivityList.getConnections().add(connection);
                }
            }
        }
    }
    return connectivityList;
}
Also used : StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) StorageSystemConnectivityRestRep(com.emc.storageos.model.systems.StorageSystemConnectivityRestRep) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with StorageSystemConnectivityRestRep

use of com.emc.storageos.model.systems.StorageSystemConnectivityRestRep in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method getStorageSystemConnectivity.

@Override
public StorageSystemConnectivityList getStorageSystemConnectivity(StorageSystem storageSystem) {
    // Connectivity list to return
    StorageSystemConnectivityList connectivityList = new StorageSystemConnectivityList();
    // Set used to ensure unique values are added to the connectivity list
    Set<String> existing = new HashSet<String>();
    // List to store all vplexes found
    List<StorageSystem> vplexes = new ArrayList<StorageSystem>();
    // First determine whether or not this Storage System is a VPLEX
    if (ConnectivityUtil.isAVPlex(storageSystem)) {
        vplexes.add(storageSystem);
    } else {
        // If it's not a VPLEX find any associated VPLEXs for this Storage System
        Set<URI> vplexSystems = ConnectivityUtil.getVPlexSystemsAssociatedWithArray(_dbClient, storageSystem.getId());
        for (URI uri : vplexSystems) {
            StorageSystem vplexSystem = _dbClient.queryObject(StorageSystem.class, uri);
            vplexes.add(vplexSystem);
        }
    }
    // result list.
    for (StorageSystem vplexSystem : vplexes) {
        // Loop through the associated Storage Systems to build the connectivity response list.
        // Only store unique responses.
        Set<URI> associatedSystemURIs = ConnectivityUtil.getStorageSystemAssociationsByNetwork(_dbClient, vplexSystem.getId(), StoragePort.PortType.backend);
        for (URI associatedStorageSystemURI : associatedSystemURIs) {
            StorageSystem associatedStorageSystem = _dbClient.queryObject(StorageSystem.class, associatedStorageSystemURI);
            if (associatedStorageSystem == null || associatedStorageSystem.getInactive() || ConnectivityUtil.isAVPlex(associatedStorageSystem) || storageSystem.getId().equals(associatedStorageSystemURI)) {
                continue;
            }
            StorageSystemConnectivityRestRep connection = new StorageSystemConnectivityRestRep();
            connection.getConnectionTypes().add(DiscoveredDataObject.Type.vplex.toString());
            connection.setProtectionSystem(toNamedRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, vplexSystem.getId(), vplexSystem.getNativeGuid()));
            connection.setStorageSystem(toNamedRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, associatedStorageSystem.getId(), associatedStorageSystem.getNativeGuid()));
            // The key is a transient unique ID, since none of the actual fields guarantee uniqueness.
            // We use this to make sure we don't add the same storage system more than once for the same
            // protection system and connection type.
            String key = connection.getProtectionSystem().toString() + connection.getConnectionTypes() + connection.getStorageSystem().toString();
            if (!existing.contains(key)) {
                existing.add(key);
                connectivityList.getConnections().add(connection);
            }
        }
    }
    return connectivityList;
}
Also used : StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) StorageSystemConnectivityRestRep(com.emc.storageos.model.systems.StorageSystemConnectivityRestRep) ArrayList(java.util.ArrayList) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with StorageSystemConnectivityRestRep

use of com.emc.storageos.model.systems.StorageSystemConnectivityRestRep in project coprhd-controller by CoprHD.

the class StorageSystemUtils method mapProtectionSystemConnectivity.

private static Map<String, Set<NamedRelatedResourceRep>> mapProtectionSystemConnectivity(List<StorageSystemConnectivityRestRep> connectivityList) {
    Map<String, Set<NamedRelatedResourceRep>> results = Maps.newTreeMap();
    for (StorageSystemConnectivityRestRep connectivity : connectivityList) {
        for (String connectionType : connectivity.getConnectionTypes()) {
            if (connectivity.getProtectionSystem() == null) {
                continue;
            }
            Set<NamedRelatedResourceRep> values = results.get(connectionType);
            if (values == null) {
                values = Sets.newTreeSet(new RelatedResourceComparator());
                results.put(connectionType, values);
            }
            values.add(connectivity.getProtectionSystem());
        }
    }
    return results;
}
Also used : StorageSystemConnectivityRestRep(com.emc.storageos.model.systems.StorageSystemConnectivityRestRep) Set(java.util.Set) RelatedResourceComparator(com.emc.vipr.client.core.util.RelatedResourceComparator) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 4 with StorageSystemConnectivityRestRep

use of com.emc.storageos.model.systems.StorageSystemConnectivityRestRep in project coprhd-controller by CoprHD.

the class StorageSystemUtils method getProtectionConnectivityMap.

public static Map<String, Set<NamedRelatedResourceRep>> getProtectionConnectivityMap(StorageSystemRestRep storageSystem) {
    Map<String, Set<NamedRelatedResourceRep>> connectivityMap = Maps.newTreeMap();
    for (StorageSystemConnectivityRestRep connectivity : getConnectivity(storageSystem)) {
        for (String type : connectivity.getConnectionTypes()) {
            Set<NamedRelatedResourceRep> resources = connectivityMap.get(type);
            if (resources == null) {
                resources = Sets.newTreeSet(new NamedRelatedResourceComparator());
                connectivityMap.put(type, resources);
            }
            resources.add(connectivity.getProtectionSystem());
        }
    }
    return connectivityMap;
}
Also used : StorageSystemConnectivityRestRep(com.emc.storageos.model.systems.StorageSystemConnectivityRestRep) Set(java.util.Set) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 5 with StorageSystemConnectivityRestRep

use of com.emc.storageos.model.systems.StorageSystemConnectivityRestRep in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method getStorageSystemConnectivity.

@Override
public StorageSystemConnectivityList getStorageSystemConnectivity(StorageSystem system) {
    _log.debug("getStorageSystemConnectivity START");
    // Connectivity list to return
    StorageSystemConnectivityList connectivityList = new StorageSystemConnectivityList();
    // Set used to ensure unique values are added to the connectivity list
    Set<String> existing = new HashSet<String>();
    // Get all the RPSiteArrays that contain this Storage System
    List<RPSiteArray> rpSiteArrays = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, RPSiteArray.class, AlternateIdConstraint.Factory.getConstraint(RPSiteArray.class, "storageSystem", system.getId().toString()));
    Map<URI, ProtectionSystem> protSysMap = new HashMap<URI, ProtectionSystem>();
    Map<String, StorageSystem> storageSystemBySerialNumber = new HashMap<String, StorageSystem>();
    // For each of the RPSiteArrays get the Protection System
    for (RPSiteArray rpSiteArray : rpSiteArrays) {
        if ((rpSiteArray.getRpProtectionSystem() != null)) {
            ProtectionSystem protectionSystem = protSysMap.get(rpSiteArray.getRpProtectionSystem());
            if (protectionSystem == null) {
                protectionSystem = _dbClient.queryObject(ProtectionSystem.class, rpSiteArray.getRpProtectionSystem());
                protSysMap.put(protectionSystem.getId(), protectionSystem);
            }
            // connectivity response list. Only store unique responses.
            for (String associatedStorageSystemStr : protectionSystem.getAssociatedStorageSystems()) {
                String associatedStorageSystemSerialNumber = ProtectionSystem.getAssociatedStorageSystemSerialNumber(associatedStorageSystemStr);
                StorageSystem associatedStorageSystem = storageSystemBySerialNumber.get(associatedStorageSystemSerialNumber);
                if (associatedStorageSystem == null) {
                    URI associatedStorageSystemURI = ConnectivityUtil.findStorageSystemBySerialNumber(associatedStorageSystemSerialNumber, _dbClient, StorageSystemType.BLOCK);
                    associatedStorageSystem = _dbClient.queryObject(StorageSystem.class, associatedStorageSystemURI);
                    if (associatedStorageSystem == null || associatedStorageSystem.getInactive()) {
                        continue;
                    }
                    storageSystemBySerialNumber.put(associatedStorageSystemSerialNumber, associatedStorageSystem);
                }
                if (ConnectivityUtil.isAVPlex(associatedStorageSystem)) {
                    continue;
                }
                StorageSystemConnectivityRestRep connection = new StorageSystemConnectivityRestRep();
                connection.getConnectionTypes().add(ProtectionSystem._RP);
                connection.setProtectionSystem(toNamedRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, rpSiteArray.getRpProtectionSystem(), protectionSystem.getLabel()));
                connection.setStorageSystem(toNamedRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, associatedStorageSystem.getId(), associatedStorageSystem.getSerialNumber()));
                // The key is a transient unique ID, since none of the actual fields guarantee uniqueness.
                // We use this to make sure we don't add the same storage system more than once for the same
                // protection system and connection type.
                String key = connection.getProtectionSystem().toString() + connection.getConnectionTypes() + connection.getStorageSystem().toString();
                if (!existing.contains(key)) {
                    existing.add(key);
                    connectivityList.getConnections().add(connection);
                }
            }
        }
    }
    _log.debug("getStorageSystemConnectivity END");
    return connectivityList;
}
Also used : RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) StorageSystemConnectivityRestRep(com.emc.storageos.model.systems.StorageSystemConnectivityRestRep) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystemConnectivityRestRep (com.emc.storageos.model.systems.StorageSystemConnectivityRestRep)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 StorageSystemConnectivityList (com.emc.storageos.model.systems.StorageSystemConnectivityList)3 HashSet (java.util.HashSet)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 URI (java.net.URI)2 Set (java.util.Set)2 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)1 RPSiteArray (com.emc.storageos.db.client.model.RPSiteArray)1 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)1 FCTN_VPLEX_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI)1 RelatedResourceComparator (com.emc.vipr.client.core.util.RelatedResourceComparator)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1