Search in sources :

Example 11 with URIQueryResultList

use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.

the class RegistryImpl method getDriverAttributes.

@Override
public Map<String, Map<String, List<String>>> getDriverAttributes(String driverName) {
    Map<String, Map<String, List<String>>> keyMap = new HashMap<>();
    // find existing entries for driver name
    URIQueryResultList registryEntriesUris = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
    while (registryEntriesUris.iterator().hasNext()) {
        Map<String, List<String>> attributesMap = new HashMap<>();
        URI registryEntryUri = registryEntriesUris.iterator().next();
        DriverRegistryRecord registryEntry = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
        StringSetMap attributes = registryEntry.getAttributes();
        for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : attributes.entrySet()) {
            attributesMap.put(entry.getKey(), new ArrayList<>(entry.getValue()));
        }
        keyMap.put(registryEntry.getRegistryKey(), attributesMap);
    }
    return keyMap;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Map(java.util.Map) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 12 with URIQueryResultList

use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.

the class RegistryImpl method clearDriverAttributesForKey.

@Override
public void clearDriverAttributesForKey(String driverName, String key) {
    validateRegistryRequest(driverName, key);
    URIQueryResultList registryEntriesUris = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
    while (registryEntriesUris.iterator().hasNext()) {
        URI registryEntryUri = registryEntriesUris.iterator().next();
        DriverRegistryRecord registryEntry = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
        if (registryEntry.getRegistryKey().equals(key)) {
            // remove this entry from db
            dbClient.markForDeletion(registryEntry);
            break;
        }
    }
}
Also used : DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 13 with URIQueryResultList

use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.

the class ConnectivityUtil method getStoragePortsForSystem.

/**
 * Retrieve all the storage ports of a given StorageSystem and type.
 *
 * @param storage -- StorageSystem URI
 * @return List<StoragePort> -- A list of the the Storage Ports in that Network
 */
public static List<StoragePort> getStoragePortsForSystem(DbClient dbClient, URI storage) {
    List<StoragePort> ports = new ArrayList<StoragePort>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(storage), storagePortURIs);
    Iterator<URI> storagePortsIter = storagePortURIs.iterator();
    while (storagePortsIter.hasNext()) {
        URI portURI = storagePortsIter.next();
        StoragePort port = dbClient.queryObject(StoragePort.class, portURI);
        if (port == null || port.getInactive() == true) {
            continue;
        }
        if (!DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name().equals(port.getCompatibilityStatus())) {
            continue;
        }
        if (false == port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name())) {
            continue;
        }
        if (!DiscoveryStatus.VISIBLE.name().equals(port.getDiscoveryStatus())) {
            continue;
        }
        ports.add(port);
    }
    return ports;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 14 with URIQueryResultList

use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.

the class ConnectivityUtil method getProtectionSystemsAssociatedWithArray.

/**
 * Get all protection systems associated with an array.
 *
 * @param dbClient - db client
 * @param storageSystem - storage array
 * @return list of URIs corresponding to rp systems
 */
public static Set<URI> getProtectionSystemsAssociatedWithArray(DbClient dbClient, URI storageSystem) {
    Set<URI> rpSystemIds = new HashSet<URI>();
    // Get the Source Storage System in question
    StorageSystem sourceStorageSystem = dbClient.queryObject(StorageSystem.class, storageSystem);
    // Get all the RPSiteArrays associated to this Storage System
    URIQueryResultList sitelist = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getRPSiteArrayByStorageSystemConstraint(storageSystem.toString()), sitelist);
    Iterator<URI> it = sitelist.iterator();
    while (it.hasNext()) {
        URI rpSiteArrayId = it.next();
        RPSiteArray rpSiteArray = dbClient.queryObject(RPSiteArray.class, rpSiteArrayId);
        if (rpSiteArray != null) {
            // Find source RPSiteArrays that qualify and get the Protection System
            if (sourceStorageSystem.getId().equals(rpSiteArray.getStorageSystem())) {
                rpSystemIds.add(rpSiteArray.getRpProtectionSystem());
            }
        }
    }
    return rpSystemIds;
}
Also used : RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 15 with URIQueryResultList

use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.

the class ConnectivityUtil method findAllVirtualArraysForRPSiteArray.

/**
 * Find all the associated VSA URIs for the passed in RPSiteArray
 *
 * @param dbClient
 * @param siteArray
 * @param ids virtual array ids collected
 * @return void
 */
private static void findAllVirtualArraysForRPSiteArray(DbClient dbClient, RPSiteArray siteArray, Collection<URI> ids) {
    if (siteArray != null) {
        // Find all the Storage Pools associated to this RPSiteArray
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(siteArray.getStorageSystem()), storagePoolURIs);
        Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
        while (storagePoolIter.hasNext()) {
            URI storagePoolURI = storagePoolIter.next();
            StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
            // For each Storage Pool get all the connected VSAs
            if (storagePool != null && !storagePool.getInactive() && storagePool.getConnectedVirtualArrays() != null) {
                for (String vArrayId : storagePool.getConnectedVirtualArrays()) {
                    ids.add(URI.create(vArrayId));
                }
            }
        }
        // If the rpsite array storage system is vplex check virtual array
        // connectivity to rpsite using front end storage ports
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, siteArray.getStorageSystem());
        if (storageSystem != null && isAVPlex(storageSystem)) {
            Map<URI, List<StoragePort>> storagePortMap = ConnectivityUtil.getStoragePortsOfType(dbClient, storageSystem.getId(), PortType.frontend);
            for (Map.Entry<URI, List<StoragePort>> storagePortEntry : storagePortMap.entrySet()) {
                for (StoragePort storagePort : storagePortEntry.getValue()) {
                    // For each Storage Port get all the connected VSAs
                    if (storagePort.getConnectedVirtualArrays() != null && !storagePort.getConnectedVirtualArrays().isEmpty() && !ids.containsAll(URIUtil.toURIList(storagePort.getConnectedVirtualArrays()))) {
                        _log.info(String.format("Vplex System [%s] has connectvity to RP Site [%s]", storageSystem.getLabel(), siteArray.getRpSiteName()));
                        ids.addAll(URIUtil.toURIList(storagePort.getConnectedVirtualArrays()));
                    }
                    if (storagePort.getAssignedVirtualArrays() != null && !storagePort.getAssignedVirtualArrays().isEmpty() && !ids.containsAll(URIUtil.toURIList(storagePort.getAssignedVirtualArrays()))) {
                        _log.info(String.format("Vplex System [%s] has connectvity to RP Site [%s]", storageSystem.getLabel(), siteArray.getRpSiteName()));
                        ids.addAll(URIUtil.toURIList(storagePort.getAssignedVirtualArrays()));
                    }
                }
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) HashMap(java.util.HashMap) Map(java.util.Map) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)664 URI (java.net.URI)497 ArrayList (java.util.ArrayList)258 HashMap (java.util.HashMap)107 Volume (com.emc.storageos.db.client.model.Volume)97 NamedURI (com.emc.storageos.db.client.model.NamedURI)96 HashSet (java.util.HashSet)92 StoragePort (com.emc.storageos.db.client.model.StoragePort)91 StringSet (com.emc.storageos.db.client.model.StringSet)83 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)64 Produces (javax.ws.rs.Produces)55 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)54 Path (javax.ws.rs.Path)54 List (java.util.List)53 StoragePool (com.emc.storageos.db.client.model.StoragePool)49 Initiator (com.emc.storageos.db.client.model.Initiator)47 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)45 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)39 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)38