Search in sources :

Example 21 with ContainmentConstraint

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

the class VNXeExportFileSystemJob method queryFileExports.

private List<FileExportRule> queryFileExports(URI uri, DbClient dbClient) {
    List<FileExportRule> fileExportRules = null;
    try {
        ContainmentConstraint containmentConstraint;
        if (isFile) {
            _logger.info("Querying all ExportRules Using FsId {}", uri);
            containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(uri);
        } else {
            _logger.info("Querying all ExportRules Using Snapshot Id {}", uri);
            containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(uri);
        }
        fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileExportRule.class, containmentConstraint);
    } catch (Exception e) {
        _logger.error("Error while querying {}", e);
    }
    return fileExportRules;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 22 with ContainmentConstraint

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

the class TaskUtils method findTenantTasks.

/**
 * This method will find all tasks associated with a tenant.
 * NOTE: This method does NOT work well to scale if a single tenant is performing many
 * thousands of operations. Consider other constraint criteria depending on your needs.
 *
 * @param dbClient
 *            db client
 * @param tenantId
 *            tenant URI
 * @return list of Task objects associated with that tenant
 */
public static ObjectQueryResult<Task> findTenantTasks(DbClient dbClient, URI tenantId) {
    ContainmentConstraint constraint = ContainmentConstraint.Factory.getTenantOrgTaskConstraint(tenantId);
    ObjectQueryResult<Task> queryResult = new ObjectQueryResult(dbClient, constraint);
    queryResult.executeQuery();
    return queryResult;
}
Also used : Task(com.emc.storageos.db.client.model.Task) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 23 with ContainmentConstraint

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

the class DbIndexTest method testRelationIndex.

@Test
public void testRelationIndex() throws InstantiationException, IllegalAccessException, IOException {
    URI id = URIUtil.createId(StoragePool.class);
    URI pid0 = URIUtil.createId(StorageSystem.class);
    URI pid1 = URIUtil.createId(StorageSystem.class);
    ContainmentConstraint constraint0 = ContainmentConstraint.Factory.getContainedObjectsConstraint(pid0, StoragePool.class, "storageDevice");
    ContainmentConstraint constraint1 = ContainmentConstraint.Factory.getContainedObjectsConstraint(pid1, StoragePool.class, "storageDevice");
    {
        StoragePool obj = new StoragePool();
        obj.setId(id);
        obj.setStorageDevice(pid0);
        _dbClient.createObject(obj);
    }
    verifyContain(constraint0, id, 1);
    verifyContain(constraint1, null, 0);
    {
        StoragePool obj = _dbClient.queryObject(StoragePool.class, id);
        obj.setStorageDevice(pid1);
        _dbClient.persistObject(obj);
    }
    verifyContain(constraint1, id, 1);
    verifyContain(constraint0, null, 0);
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URI(java.net.URI) Test(org.junit.Test)

Example 24 with ContainmentConstraint

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

the class DbIndexTest method testRelationIndexSet.

@Test
public void testRelationIndexSet() {
    URI id = URIUtil.createId(ExportGroup.class);
    URI pid0 = URIUtil.createId(Snapshot.class);
    URI pid1 = URIUtil.createId(Snapshot.class);
    ContainmentConstraint constraint0 = ContainmentConstraint.Factory.getContainedObjectsConstraint(pid0, ExportGroup.class, "snapshots");
    ContainmentConstraint constraint1 = ContainmentConstraint.Factory.getContainedObjectsConstraint(pid1, ExportGroup.class, "snapshots");
    {
        ExportGroup obj = new ExportGroup();
        obj.setId(id);
        obj.setSnapshots(new StringSet());
        obj.getSnapshots().add(pid0.toString());
        _dbClient.createObject(obj);
    }
    verifyContain(constraint0, id, 1);
    verifyContain(constraint1, null, 0);
    {
        ExportGroup obj = _dbClient.queryObject(ExportGroup.class, id);
        obj.getSnapshots().add(pid1.toString());
        _dbClient.persistObject(obj);
    }
    verifyContain(constraint0, id, 1);
    verifyContain(constraint1, id, 1);
    {
        ExportGroup obj = _dbClient.queryObject(ExportGroup.class, id);
        // assertTrue(obj.getSnapshots() != null);
        obj.getSnapshots().remove(pid0.toString());
        _dbClient.persistObject(obj);
    }
    verifyContain(constraint1, id, 1);
    verifyContain(constraint0, null, 0);
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URI(java.net.URI) Test(org.junit.Test)

Example 25 with ContainmentConstraint

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

the class FileOperationUtils method queryDBHostMounts.

/**
 * Method to get the list file system mounts which are mount on a host
 *
 * @param host
 *            host system URI
 * @return List<MountInfo> List of mount infos
 */
public static List<MountInfo> queryDBHostMounts(URI host, DbClient dbClient) {
    _log.info("Querying NFS mounts for host {}", host);
    List<MountInfo> hostMounts = new ArrayList<MountInfo>();
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getHostFileMountsConstraint(host);
        List<FileMountInfo> fileMounts = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileMountInfo.class, containmentConstraint);
        if (fileMounts != null && !fileMounts.isEmpty()) {
            for (FileMountInfo dbMount : fileMounts) {
                MountInfo mountInfo = new MountInfo();
                getMountInfo(dbMount, mountInfo);
                hostMounts.add(mountInfo);
            }
        }
        return hostMounts;
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return hostMounts;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Aggregations

ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)47 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)18 ArrayList (java.util.ArrayList)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 URI (java.net.URI)15 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)11 URISyntaxException (java.net.URISyntaxException)11 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 FileShare (com.emc.storageos.db.client.model.FileShare)7 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 WorkflowException (com.emc.storageos.workflow.WorkflowException)6 ContainmentConstraintImpl (com.emc.storageos.db.client.constraint.impl.ContainmentConstraintImpl)5 FileMountInfo (com.emc.storageos.db.client.model.FileMountInfo)5 CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)4 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)4 ExportRule (com.emc.storageos.model.file.ExportRule)4 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)4