Search in sources :

Example 1 with CifsShareACL

use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.

the class CifsShareUtility method verifyAddShareACLs.

private void verifyAddShareACLs(List<ShareACL> shareAclList) {
    if (shareAclList == null) {
        return;
    }
    _log.info("Number of share ACL(s) to add {} ", shareAclList.size());
    for (ShareACL acl : shareAclList) {
        acl.proceedToNextStep();
        _log.info("Verifying ACL {}", acl.toString());
        // Are there same user or group found in other acls. If so, report
        // error
        verifyUserGroup(acl);
        if (!acl.canProceedToNextStep()) {
            break;
        }
        validatePermissions(acl);
        if (!acl.canProceedToNextStep()) {
            break;
        }
        // Verify with existing ACL
        CifsShareACL dbShareAcl = getExistingACL(acl);
        // If same acl exists, don't allow to add again.
        if (dbShareAcl != null) {
            _log.error("Duplicate ACL in add request. User/group in ACL for share already exists: {}", dbShareAcl);
            acl.cancelNextStep(ShareACLOperationErrorType.ACL_EXISTS);
            break;
        } else // If not found proceed for further verifications.
        {
            if (acl.canProceedToNextStep()) {
                _log.info("No existing ACL found in DB {}", acl);
            }
        }
    }
}
Also used : ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 2 with CifsShareACL

use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.

the class CifsShareUtility method verifyDeleteShareACLs.

private void verifyDeleteShareACLs(List<ShareACL> shareAclList) {
    if (shareAclList == null) {
        return;
    }
    _log.info("Number of share ACL(s) to delete {} ", shareAclList.size());
    for (ShareACL acl : shareAclList) {
        acl.proceedToNextStep();
        _log.info("Verifying ACL {}", acl.toString());
        // Are there same user or group found in other acls. If so, report
        // error
        verifyUserGroup(acl);
        if (!acl.canProceedToNextStep()) {
            break;
        }
        // Verify with existing ACL
        CifsShareACL dbShareAcl = getExistingACL(acl);
        // If same acl exists, allow to modify
        if (dbShareAcl != null) {
            _log.info("Existing ACL found in delete request: {}", dbShareAcl);
            acl.proceedToNextStep();
        } else {
            // If not found, don't allow to proceed further
            if (acl.canProceedToNextStep()) {
                _log.error("No existing ACL found in DB to delete {}", acl);
                acl.cancelNextStep(ShareACLOperationErrorType.ACL_NOT_FOUND);
            }
        }
    }
}
Also used : ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 3 with CifsShareACL

use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.

the class CifsShareUtility method verifyModifyShareACLs.

private void verifyModifyShareACLs(List<ShareACL> shareAclList) {
    if (shareAclList == null) {
        return;
    }
    _log.info("Number of share ACL(s) to modify {} ", shareAclList.size());
    for (ShareACL acl : shareAclList) {
        acl.proceedToNextStep();
        _log.info("Verifying ACL {}", acl.toString());
        // Are there same user or group found in other acls. If so, report
        // error
        verifyUserGroup(acl);
        if (!acl.canProceedToNextStep()) {
            break;
        }
        validatePermissions(acl);
        if (!acl.canProceedToNextStep()) {
            break;
        }
        // Verify with existing ACL
        CifsShareACL dbShareAcl = getExistingACL(acl);
        // If same acl exists, allow to modify
        if (dbShareAcl != null) {
            _log.info("Existing ACL in modify request: {}", dbShareAcl);
            acl.proceedToNextStep();
        } else {
            // If not found, don't allow to proceed further
            if (acl.canProceedToNextStep()) {
                _log.error("No existing ACL found in DB to modify {}", acl);
                acl.cancelNextStep(ShareACLOperationErrorType.ACL_NOT_FOUND);
            }
        }
    }
}
Also used : ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 4 with CifsShareACL

use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.

the class FileDeviceController method getExistingShareAclFromDB.

private CifsShareACL getExistingShareAclFromDB(CifsShareACL dbShareAcl, FileDeviceInputOutput args) {
    CifsShareACL acl = null;
    String index = null;
    URIQueryResultList result = new URIQueryResultList();
    if (args.getFileOperation()) {
        index = dbShareAcl.getFileSystemShareACLIndex();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemShareACLConstraint(index), result);
    } else {
        index = dbShareAcl.getSnapshotShareACLIndex();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotShareACLConstraint(index), result);
    }
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        if (result.iterator().hasNext()) {
            acl = _dbClient.queryObject(CifsShareACL.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) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 5 with CifsShareACL

use of com.emc.storageos.db.client.model.CifsShareACL in project coprhd-controller by CoprHD.

the class FileDeviceController method queryExistingShareAcls.

private List<ShareACL> queryExistingShareAcls(FileDeviceInputOutput args) {
    _log.info("Querying for Share ACLs of share {}", args.getShareName());
    List<ShareACL> acls = new ArrayList<ShareACL>();
    try {
        List<CifsShareACL> dbShareAclList = queryDBShareAcls(args);
        Iterator<CifsShareACL> dbShareAclIter = dbShareAclList.iterator();
        while (dbShareAclIter.hasNext()) {
            CifsShareACL dbShareAcl = dbShareAclIter.next();
            ShareACL shareAcl = new ShareACL();
            shareAcl.setDomain(dbShareAcl.getDomain());
            if (args.getFileOperation()) {
                shareAcl.setFileSystemId(dbShareAcl.getFileSystemId());
            } else {
                shareAcl.setSnapshotId(dbShareAcl.getSnapshotId());
            }
            shareAcl.setGroup(dbShareAcl.getGroup());
            shareAcl.setPermission(dbShareAcl.getPermission());
            shareAcl.setShareName(dbShareAcl.getShareName());
            shareAcl.setUser(dbShareAcl.getUser());
            acls.add(shareAcl);
        }
    } catch (Exception e) {
        _log.error("Error while querying ACL(s) of a share {}", e);
    }
    return acls;
}
Also used : ArrayList(java.util.ArrayList) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) ShareACL(com.emc.storageos.model.file.ShareACL) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Aggregations

CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)20 ArrayList (java.util.ArrayList)8 ShareACL (com.emc.storageos.model.file.ShareACL)7 URI (java.net.URI)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)4 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)4 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 FileShare (com.emc.storageos.db.client.model.FileShare)3 UnManagedCifsShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 ControllerException (com.emc.storageos.volumecontroller.ControllerException)3 WorkflowException (com.emc.storageos.workflow.WorkflowException)3 URISyntaxException (java.net.URISyntaxException)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 DbClient (com.emc.storageos.db.client.DbClient)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1