Search in sources :

Example 36 with URIQueryResultList

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

the class FileDeviceController method getExistingNfsAclFromDB.

/**
 * Get the DB object to modify it
 *
 * @param dbShareAcl
 *            the DB object which need to be searched
 * @param isFile
 *            it is file or snapshot operation
 * @return
 */
private NFSShareACL getExistingNfsAclFromDB(NFSShareACL dbShareAcl, boolean isFile) {
    NFSShareACL acl = null;
    String index = null;
    URIQueryResultList result = new URIQueryResultList();
    if (isFile) {
        index = dbShareAcl.getFileSystemNfsACLIndex();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemNfsACLConstraint(index), result);
    } else {
        index = dbShareAcl.getSnapshotNfsACLIndex();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotNfsACLConstraint(index), result);
    }
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        acl = _dbClient.queryObject(NFSShareACL.class, it.next());
        if (acl != null && !acl.getInactive()) {
            _log.info("Existing ACE found in DB: {}", acl);
            return acl;
        }
    }
    return null;
}
Also used : URI(java.net.URI) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 37 with URIQueryResultList

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

the class FileDeviceController method getAvailableExportRule.

private FileExportRule getAvailableExportRule(FileExportRule exportRule, FileDeviceInputOutput args) throws URISyntaxException {
    String exportIndex = exportRule.getFsExportIndex();
    if (!args.getFileOperation()) {
        exportIndex = exportRule.getSnapshotExportIndex();
    }
    _log.info("Retriving DB Model using its index {}", exportIndex);
    FileExportRule rule = null;
    URIQueryResultList result = new URIQueryResultList();
    if (!args.getFileOperation()) {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotExportRuleConstraint(exportIndex), result);
    } else {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileExportRuleConstraint(exportIndex), result);
    }
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        if (result.iterator().hasNext()) {
            rule = _dbClient.queryObject(FileExportRule.class, it.next());
            if (rule != null && !rule.getInactive()) {
                _log.info("Existing DB Model found {}", rule);
                break;
            }
        }
    }
    return rule;
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 38 with URIQueryResultList

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

the class FileDeviceController method quotaDirectoriesExistsOnFS.

private boolean quotaDirectoriesExistsOnFS(FileShare fs) {
    _log.info(" Setting Snapshots to InActive with Force Delete ");
    URIQueryResultList qdIDList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getQuotaDirectoryConstraint(fs.getId()), qdIDList);
    _log.info("getQuotaDirectories : FS {}: {} ", fs.getId().toString(), qdIDList.toString());
    List<QuotaDirectory> qdList = _dbClient.queryObject(QuotaDirectory.class, qdIDList);
    if (qdList != null) {
        for (QuotaDirectory qd : qdList) {
            if (!qd.getInactive()) {
                return true;
            }
        }
    }
    return false;
}
Also used : QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 39 with URIQueryResultList

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

the class ControllerLockingUtil method getHostStorageLockKeys.

/**
 * Returns a list of lock keys for export of Hosts to StorageSystems.
 * This is constructed from a list of Initiators.
 * All the host URIs are collected from the Initiators.
 * If an Initiator does not have a host URI, its hostName is converted to a URI and used.
 * iF export type is Cluster, the clusters are looked up, and all hosts in the
 * cluster are used.
 * The keys are constructed from a concatenation of the host URI and the storage system URI.
 *
 * @param dbClient
 * @param type
 *            ExportGroup.ExportGroupType -- used to determine if cluster export
 * @param initiatorURIs
 *            -- set of Initiators to consider
 * @param storageURI
 *            -- URI of storage system
 *            (could be a Protection System or null in which case only host in key)
 * @return List<String> where each item in list is a lockKey
 */
public static List<String> getHostStorageLockKeys(DbClient dbClient, ExportGroup.ExportGroupType type, Collection<URI> initiatorURIs, URI storageURI) {
    String storageKey = getStorageKey(dbClient, storageURI);
    List<String> lockKeys = new ArrayList<String>();
    // Collect the needed hosts, which can be specified either by URI or string name.
    Set<URI> hostURIs = new HashSet<URI>();
    Set<String> hostNames = new HashSet<String>();
    for (URI initiatorURI : initiatorURIs) {
        Initiator initiator = dbClient.queryObject(Initiator.class, initiatorURI);
        if (initiator == null || initiator.getInactive()) {
            continue;
        }
        hostURIs.add(initiator.getHost());
        hostNames.add(initiator.getHostName());
    }
    // If the export is type cluster, we want to add ALL the hosts in the clusters.
    if (type.equals(ExportGroup.ExportGroupType.Cluster)) {
        Set<URI> clusterURIs = new HashSet<URI>();
        // First determine the clusters for each real host.
        for (URI hostURI : hostURIs) {
            Host host = dbClient.queryObject(Host.class, hostURI);
            if (host == null || host.getInactive()) {
                continue;
            }
            if (!NullColumnValueGetter.isNullURI(host.getCluster())) {
                clusterURIs.add(host.getCluster());
            }
        }
        // add those hosts if not already present.
        for (URI clusterURI : clusterURIs) {
            URIQueryResultList result = new URIQueryResultList();
            dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(clusterURI, Host.class, "cluster"), result);
            Iterator<URI> iter = result.iterator();
            while (iter.hasNext()) {
                Host host = dbClient.queryObject(Host.class, iter.next());
                if (host == null || host.getInactive()) {
                    continue;
                }
                hostNames.add(host.getHostName());
            }
        }
    }
    // Now make a key for every host / storage pair
    for (String hostName : hostNames) {
        String key = hostName + DELIMITER + storageKey;
        key = key.replaceAll("\\s", "");
        if (!lockKeys.contains(key)) {
            lockKeys.add(key);
        }
    }
    log.info("Lock keys: " + lockKeys.toString());
    return lockKeys;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 40 with URIQueryResultList

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

the class ControllerUtils method getVolumesPartOfRG.

/**
 * Gets the volumes part of a given replication group.
 * and add system check.
 *
 * @param system the storage system where the replication group resides
 * @param replicationGroupInstance the replication group instance
 * @param dbClient the db client
 * @return the volumes part of replication group
 */
public static List<Volume> getVolumesPartOfRG(URI system, String replicationGroupInstance, DbClient dbClient) {
    List<Volume> volumes = new ArrayList<Volume>();
    URIQueryResultList uriQueryResultList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeReplicationGroupInstanceConstraint(replicationGroupInstance), uriQueryResultList);
    Iterator<Volume> volumeIterator = dbClient.queryIterativeObjects(Volume.class, uriQueryResultList, true);
    while (volumeIterator.hasNext()) {
        Volume volume = volumeIterator.next();
        if (volume != null && system.toString().equals(volume.getStorageController().toString())) {
            volumes.add(volume);
        }
    }
    return volumes;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

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