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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations