Search in sources :

Example 6 with ContainmentConstraint

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

the class FileQuotaDirectoryService method queryDBQuotaDirectories.

private List<QuotaDirectory> queryDBQuotaDirectories(FileShare fs) {
    _log.info("Querying all quota directories Using FsId {}", fs.getId());
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getQuotaDirectoryConstraint(fs.getId());
        List<QuotaDirectory> fsQuotaDirs = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, QuotaDirectory.class, containmentConstraint);
        return fsQuotaDirs;
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return null;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) MapQuotaDirectory(com.emc.storageos.api.mapper.functions.MapQuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 7 with ContainmentConstraint

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

the class ComputeSystemControllerImpl method removeMountDBEntry.

private void removeMountDBEntry(URI resId, URI hostId, String mountPath) {
    ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(resId);
    List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
    if (fsDBMounts != null && !fsDBMounts.isEmpty()) {
        for (FileMountInfo dbMount : fsDBMounts) {
            if (dbMount.getHostId().toString().equalsIgnoreCase(hostId.toString()) && dbMount.getMountPath().equalsIgnoreCase(mountPath)) {
                _log.debug("Found DB entry with mountpath {} " + mountPath);
                // Deactivate the entry!!
                dbMount.setInactive(true);
                _dbClient.updateObject(dbMount);
            }
        }
    }
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo)

Example 8 with ContainmentConstraint

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

the class UnManagedFilesystemService method queryDBCifsShares.

private List<UnManagedCifsShareACL> queryDBCifsShares(UnManagedFileSystem fs) {
    _logger.info("Querying All Cifs Share ACLs Using FsId {}", fs.getId());
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getUnManagedCifsShareAclsConstraint(fs.getId());
        List<UnManagedCifsShareACL> cifsShareACLList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, UnManagedCifsShareACL.class, containmentConstraint);
        return cifsShareACLList;
    } catch (Exception e) {
        _logger.error("Error while querying {}", e);
    }
    return new ArrayList<UnManagedCifsShareACL>();
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException)

Example 9 with ContainmentConstraint

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

the class BucketACLUtility method queryDbBucketACL.

private List<ObjectBucketACL> queryDbBucketACL() {
    try {
        ContainmentConstraint containmentConstraint = null;
        _log.info("Querying DB for ACL of bucket {} ", this.bucketName);
        containmentConstraint = ContainmentConstraint.Factory.getBucketAclsConstraint(this.bucketId);
        List<ObjectBucketACL> dbBucketBucketAcl = CustomQueryUtility.queryActiveResourcesByConstraint(this.dbClient, ObjectBucketACL.class, containmentConstraint);
        return dbBucketBucketAcl;
    } catch (Exception e) {
        _log.error("Error while querying DB for ACL of a bucket {}", e);
    }
    return null;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 10 with ContainmentConstraint

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

the class ExportUtils method getBlockObjectExportMasks.

/**
 * Fetches all the export masks in which a block object is member
 *
 * @param blockObject the block object
 * @param dbClient an instance of {@link DbClient}
 * @return a map of export masks in which a block object is member
 */
private static Map<ExportMask, List<ExportGroup>> getBlockObjectExportMasks(BlockObject blockObject, DbClient dbClient) {
    Map<ExportMask, List<ExportGroup>> exportMasks = new HashMap<ExportMask, List<ExportGroup>>();
    ContainmentConstraint constraint = ContainmentConstraint.Factory.getBlockObjectExportGroupConstraint(blockObject.getId());
    // permission are checked by the API service - no need to check again
    List<ExportGroup> exportGroups = getExportGroupsByConstraint(constraint, dbClient, null, null);
    List<ExportMask> masks = getMasksForExportGroups(exportGroups, dbClient);
    // Get the actual export block object associated with the snapshot (if applicable)
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        for (ExportMask exportMask : masks) {
            if (exportMask != null && !exportMask.getInactive() && exportMask.hasVolume(bo.getId()) && (exportMask.getInitiators() != null || exportMask.getExistingInitiators() != null)) {
                List<ExportGroup> maskGroups = new ArrayList<ExportGroup>();
                exportMasks.put(exportMask, maskGroups);
                for (ExportGroup group : exportGroups) {
                    if (group.getExportMasks() != null && group.getExportMasks().contains(exportMask.getId().toString())) {
                        maskGroups.add(group);
                    }
                }
            }
        }
        _log.debug("Found {} export masks for block object {}", exportMasks.size(), bo.getLabel());
    }
    return exportMasks;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

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