Search in sources :

Example 6 with ShareACL

use of com.emc.storageos.model.file.ShareACL 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 7 with ShareACL

use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method deleteShareACLs.

@Override
public BiosCommandResult deleteShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
    BiosCommandResult result = new BiosCommandResult();
    List<ShareACL> existingAcls = new ArrayList<ShareACL>();
    existingAcls = args.getExistingShareAcls();
    NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
    try {
        deleteShareAcl(nApi, args.getShareName(), existingAcls);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::Delete All ACL failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteCIFSShareAcl();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) NetAppApi(com.emc.storageos.netapp.NetAppApi) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 8 with ShareACL

use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method addShareAcl.

private void addShareAcl(NetAppApi nApi, String shareName, List<ShareACL> aclsToAdd) {
    if (aclsToAdd == null || aclsToAdd.isEmpty()) {
        return;
    }
    List<CifsAcl> acls = new ArrayList<CifsAcl>();
    for (ShareACL newAcl : aclsToAdd) {
        CifsAcl cif_new = new CifsAcl();
        String domain = newAcl.getDomain();
        String userOrGroup = newAcl.getGroup() == null ? newAcl.getUser() : newAcl.getGroup();
        if (domain != null && !domain.isEmpty()) {
            userOrGroup = domain + "\\" + userOrGroup;
        }
        // for netapp api user and group are same.and need to set only user
        cif_new.setUserName(userOrGroup);
        cif_new.setShareName(shareName);
        cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
        acls.add(cif_new);
    }
    nApi.modifyCIFSShareAcl(shareName, acls);
}
Also used : CifsAcl(com.iwave.ext.netapp.model.CifsAcl) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL)

Example 9 with ShareACL

use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method deleteShareAcl.

private void deleteShareAcl(NetAppApi nApi, String shareName, List<ShareACL> aclsToDelete) {
    if (aclsToDelete == null || aclsToDelete.isEmpty()) {
        return;
    }
    List<CifsAcl> acls = new ArrayList<CifsAcl>();
    for (ShareACL newAcl : aclsToDelete) {
        CifsAcl cif_new = new CifsAcl();
        String domain = newAcl.getDomain();
        String userOrGroup = newAcl.getGroup() == null ? newAcl.getUser() : newAcl.getGroup();
        if (domain != null && !domain.isEmpty()) {
            userOrGroup = domain + "\\" + userOrGroup;
        }
        // for netapp api user and group are same.and need to set only user
        cif_new.setUserName(userOrGroup);
        cif_new.setShareName(shareName);
        cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
        acls.add(cif_new);
    }
    nApi.deleteCIFSShareAcl(shareName, acls);
}
Also used : CifsAcl(com.iwave.ext.netapp.model.CifsAcl) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL)

Example 10 with ShareACL

use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method forceDeleteShareAcl.

private void forceDeleteShareAcl(NetAppApi nApi, String shareName, List<ShareACL> aclsToDelete) {
    if (aclsToDelete == null || aclsToDelete.isEmpty()) {
        return;
    }
    List<CifsAcl> acls = new ArrayList<CifsAcl>();
    for (ShareACL newAcl : aclsToDelete) {
        CifsAcl cif_new = new CifsAcl();
        String domain = newAcl.getDomain();
        String userOrGroup = newAcl.getGroup() == null ? newAcl.getUser() : newAcl.getGroup();
        if (domain != null && !domain.isEmpty()) {
            userOrGroup = domain + "\\" + userOrGroup;
        }
        // for netapp api user and group are same.and need to set only user
        cif_new.setUserName(userOrGroup);
        cif_new.setShareName(shareName);
        cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
        acls.add(cif_new);
    }
    for (CifsAcl cifsAcl : acls) {
        try {
            List<CifsAcl> singleACL = new ArrayList<CifsAcl>();
            singleACL.add(cifsAcl);
            nApi.deleteCIFSShareAcl(shareName, singleACL);
        } catch (Exception e) {
            _log.error("NetAppFileStorageDevice:: Force delete of ACL for user [" + cifsAcl.getUserName() + "] failed with an Exception", e);
        }
    }
}
Also used : CifsAcl(com.iwave.ext.netapp.model.CifsAcl) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Aggregations

ShareACL (com.emc.storageos.model.file.ShareACL)36 ArrayList (java.util.ArrayList)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 ShareACLs (com.emc.storageos.model.file.ShareACLs)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)10 NetAppException (com.emc.storageos.netapp.NetAppException)9 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)7 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)7 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 NetAppCException (com.emc.storageos.netappc.NetAppCException)4 CifsAcl (com.iwave.ext.netapp.model.CifsAcl)4 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)3 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 IsilonSMBShare (com.emc.storageos.isilon.restapi.IsilonSMBShare)3 Permission (com.emc.storageos.isilon.restapi.IsilonSMBShare.Permission)3 ShareACLOperationErrorType (com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType)3 FileCifsShareACLUpdateParams (com.emc.storageos.model.file.FileCifsShareACLUpdateParams)3 NetAppApi (com.emc.storageos.netapp.NetAppApi)3 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)3