Search in sources :

Example 16 with CifsShareACL

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

the class CifsShareUtility method getExistingACL.

private CifsShareACL getExistingACL(ShareACL requestAcl) {
    CifsShareACL acl = null;
    String domainOfReqAce = requestAcl.getDomain();
    if (domainOfReqAce == null) {
        domainOfReqAce = "";
    }
    String userOrGroup = requestAcl.getUser() == null ? requestAcl.getGroup() : requestAcl.getUser();
    // Construct ACL Index
    StringBuffer aclIndex = new StringBuffer();
    aclIndex.append(this.fs == null ? this.snapshot.getId().toString() : this.fs.getId().toString());
    aclIndex.append(this.shareName).append(domainOfReqAce).append(userOrGroup);
    acl = this.queryACLByIndex(aclIndex.toString());
    return acl;
}
Also used : CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 17 with CifsShareACL

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

the class FileDeviceController method queryDBShareAcls.

private List<CifsShareACL> queryDBShareAcls(FileDeviceInputOutput args) {
    List<CifsShareACL> acls = new ArrayList<CifsShareACL>();
    try {
        ContainmentConstraint containmentConstraint = null;
        if (args.getFileOperation()) {
            FileShare fs = args.getFs();
            _log.info("Querying DB for Share ACLs of share {} of filesystemId {} ", args.getShareName(), fs.getId());
            containmentConstraint = ContainmentConstraint.Factory.getFileCifsShareAclsConstraint(fs.getId());
        } else {
            URI snapshotId = args.getSnapshotId();
            _log.info("Querying DB for Share ACLs of share {} of snapshotId {} ", args.getShareName(), snapshotId);
            containmentConstraint = ContainmentConstraint.Factory.getSnapshotCifsShareAclsConstraint(snapshotId);
        }
        List<CifsShareACL> shareAclList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, CifsShareACL.class, containmentConstraint);
        Iterator<CifsShareACL> shareAclIter = shareAclList.iterator();
        while (shareAclIter.hasNext()) {
            CifsShareACL shareAcl = shareAclIter.next();
            if (shareAcl != null && args.getShareName().equals(shareAcl.getShareName())) {
                acls.add(shareAcl);
            }
        }
    } catch (Exception e) {
        _log.error("Error while querying DB for ACL(s) of a share {}", e);
    }
    return acls;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) 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)

Example 18 with CifsShareACL

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

the class FileDeviceController method deleteShareACLsFromDB.

private void deleteShareACLsFromDB(FileDeviceInputOutput args) {
    List<CifsShareACL> existingDBAclList = queryDBShareAcls(args);
    List<CifsShareACL> deleteAclList = new ArrayList<CifsShareACL>();
    _log.debug("Inside deleteShareACLsFromDB() to delete ACL of share {} from DB", args.getShareName());
    for (Iterator<CifsShareACL> iterator = existingDBAclList.iterator(); iterator.hasNext(); ) {
        CifsShareACL cifsShareACL = iterator.next();
        if (args.getShareName().equals(cifsShareACL.getShareName())) {
            cifsShareACL.setInactive(true);
            deleteAclList.add(cifsShareACL);
        }
    }
    if (!deleteAclList.isEmpty()) {
        _log.info("Deleting ACL of share {}", args.getShareName());
        _dbClient.updateObject(deleteAclList);
    }
}
Also used : ArrayList(java.util.ArrayList) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 19 with CifsShareACL

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

the class FileDeviceController method createDefaultACEForSMBShare.

/**
 * Creates default share ACE for fileshares on VNXe, VXFile and Datadomain
 *
 * @param id
 *            URI of filesystem or snapshot
 * @param fileShare
 * @param storageType
 */
private void createDefaultACEForSMBShare(URI id, FileSMBShare fileShare, String storageType) {
    StorageSystem.Type storageSystemType = StorageSystem.Type.valueOf(storageType);
    if (storageSystemType.equals(Type.vnxe) || storageSystemType.equals(Type.vnxfile) || storageSystemType.equals(Type.datadomain)) {
        SMBFileShare share = fileShare.getSMBFileShare();
        CifsShareACL ace = new CifsShareACL();
        ace.setUser(FileControllerConstants.CIFS_SHARE_USER_EVERYONE);
        String permission = null;
        switch(share.getPermission()) {
            case "read":
                permission = FileControllerConstants.CIFS_SHARE_PERMISSION_READ;
                break;
            case "change":
                permission = FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE;
                break;
            case "full":
                permission = FileControllerConstants.CIFS_SHARE_PERMISSION_FULLCONTROL;
                break;
        }
        ace.setPermission(permission);
        ace.setId(URIUtil.createId(CifsShareACL.class));
        ace.setShareName(share.getName());
        if (URIUtil.isType(id, FileShare.class)) {
            ace.setFileSystemId(id);
        } else {
            ace.setSnapshotId(id);
        }
        _log.info("Creating default ACE for the share: {}", ace);
        _dbClient.createObject(ace);
    }
}
Also used : SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 20 with CifsShareACL

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

the class FileDeviceController method updateShareACLsInDB.

private void updateShareACLsInDB(CifsShareACLUpdateParams param, FileShare fs, FileDeviceInputOutput args) {
    try {
        // Create new Acls
        ShareACLs shareAcls = param.getAclsToAdd();
        List<ShareACL> shareAclList = null;
        if (shareAcls != null) {
            shareAclList = shareAcls.getShareACLs();
            if (shareAclList != null && !shareAclList.isEmpty()) {
                for (ShareACL acl : shareAclList) {
                    CifsShareACL dbShareAcl = new CifsShareACL();
                    dbShareAcl.setId(URIUtil.createId(CifsShareACL.class));
                    copyPropertiesToSave(acl, dbShareAcl, fs, args);
                    _log.info("Storing new acl in DB: {}", dbShareAcl);
                    _dbClient.createObject(dbShareAcl);
                }
            }
        }
        // Modify existing acls
        shareAcls = param.getAclsToModify();
        if (shareAcls != null) {
            shareAclList = shareAcls.getShareACLs();
            if (shareAclList != null && !shareAclList.isEmpty()) {
                for (ShareACL acl : shareAclList) {
                    CifsShareACL dbShareAcl = new CifsShareACL();
                    copyPropertiesToSave(acl, dbShareAcl, fs, args);
                    CifsShareACL dbShareAclTemp = getExistingShareAclFromDB(dbShareAcl, args);
                    dbShareAcl.setId(dbShareAclTemp.getId());
                    _log.info("Updating acl in DB: {}", dbShareAcl);
                    _dbClient.updateObject(dbShareAcl);
                }
            }
        }
        // Delete existing acls
        shareAcls = param.getAclsToDelete();
        if (shareAcls != null) {
            shareAclList = shareAcls.getShareACLs();
            if (shareAclList != null && !shareAclList.isEmpty()) {
                for (ShareACL acl : shareAclList) {
                    CifsShareACL dbShareAcl = new CifsShareACL();
                    copyPropertiesToSave(acl, dbShareAcl, fs, args);
                    CifsShareACL dbShareAclTemp = getExistingShareAclFromDB(dbShareAcl, args);
                    dbShareAcl.setId(dbShareAclTemp.getId());
                    dbShareAcl.setInactive(true);
                    _log.info("Marking acl inactive in DB: {}", dbShareAcl);
                    _dbClient.updateObject(dbShareAcl);
                }
            }
        }
    } catch (Exception e) {
        _log.error("Error While executing CRUD Operations {}", e);
    }
}
Also used : ShareACLs(com.emc.storageos.model.file.ShareACLs) 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