Search in sources :

Example 16 with ShareACL

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

the class FileSnapshots method createSnapshotCifsShareAclParams.

private static SnapshotCifsShareACLUpdateParams createSnapshotCifsShareAclParams(String formData) {
    String[] uiAcls = formData.split(",");
    List<ShareACL> acls = new ArrayList<ShareACL>();
    for (String uiAce : uiAcls) {
        String[] uiData = uiAce.split("~~~");
        String uiType = uiData[0];
        String uiName = uiData[1];
        String uiDomain = uiData[2];
        String uiPermission = uiData[3];
        ShareACL shareAcl = new ShareACL();
        if ("GROUP".equalsIgnoreCase(uiType)) {
            shareAcl.setGroup(uiName);
        } else {
            shareAcl.setUser(uiName);
        }
        shareAcl.setPermission(uiPermission);
        if (uiDomain != null && !"".equals(uiDomain)) {
            shareAcl.setDomain(uiDomain);
        }
        acls.add(shareAcl);
    }
    SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
    ShareACLs aclsToAdd = new ShareACLs();
    aclsToAdd.setShareACLs(acls);
    input.setAclsToAdd(aclsToAdd);
    return input;
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL)

Example 17 with ShareACL

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

the class FileSystems method listAclJson.

/**
 * This method called during population of Datatable for ACL data.
 *
 * @param aclURL
 *            URL of the file system share.
 */
public static void listAclJson(String aclURL) {
    String fileSystem = null;
    String shareName = null;
    if (StringUtils.isNotBlank(aclURL)) {
        String[] parts = aclURL.split("/");
        if (parts.length == 7) {
            fileSystem = parts[3];
            shareName = parts[5];
        }
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<ShareACL> shareAcls = client.fileSystems().getShareACLs(uri(fileSystem), shareName);
    List<ShareACLDataTable.AclInfo> acl = Lists.newArrayList();
    for (ShareACL shareAcl : shareAcls) {
        String userOrGroup = shareAcl.getUser();
        String type = "User";
        if (shareAcl.getGroup() != null && shareAcl.getGroup() != "") {
            type = "Group";
            userOrGroup = shareAcl.getGroup();
        }
        acl.add(new ShareACLDataTable.AclInfo(userOrGroup, type, shareAcl.getPermission(), fileSystem, shareName, shareAcl.getDomain()));
    }
    renderJSON(DataTablesSupport.createJSON(acl, params));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ShareACL(com.emc.storageos.model.file.ShareACL) ShareACLDataTable(models.datatable.ShareACLDataTable)

Example 18 with ShareACL

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

the class NetAppClusterModeDevice method updateShareAcl.

/**
 * updateShareAcl is method to perform add, modify and delete acl operation based
 * on the param action
 *
 * @param ncApi
 * @param shareName
 * @param inputAcls
 * @param action
 */
private void updateShareAcl(NetAppClusterApi ncApi, String shareName, List<ShareACL> inputAcls, AclOperation action) {
    if (inputAcls.isEmpty()) {
        return;
    }
    List<CifsAcl> acls = new ArrayList<CifsAcl>();
    for (ShareACL newAcl : inputAcls) {
        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;
        }
        cif_new.setUserName(userOrGroup);
        cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
        acls.add(cif_new);
    }
    switch(action) {
        case ADD:
            ncApi.addCIFSShareAcl(shareName, acls);
            break;
        case MODIFY:
            ncApi.modifyCIFSShareAcl(shareName, acls);
            break;
        case DELETE:
            ncApi.deleteCIFSShareAcl(shareName, acls);
            break;
        case FORCE_ADD:
            for (CifsAcl cifsAcl : acls) {
                try {
                    List<CifsAcl> singleACL = new ArrayList<CifsAcl>();
                    singleACL.add(cifsAcl);
                    ncApi.addCIFSShareAcl(shareName, singleACL);
                } catch (Exception e) {
                    _log.error("NetAppClusterModeDevice:: Force add of ACL for user [" + cifsAcl.getUserName() + "] failed with an Exception", e);
                }
            }
            break;
        case FORCE_DELETE:
            for (CifsAcl cifsAcl : acls) {
                try {
                    List<CifsAcl> singleACL = new ArrayList<CifsAcl>();
                    singleACL.add(cifsAcl);
                    ncApi.deleteCIFSShareAcl(shareName, singleACL);
                } catch (Exception e) {
                    _log.error("NetAppClusterModeDevice:: Force delete of ACL for user [" + cifsAcl.getUserName() + "] failed with an Exception", e);
                }
            }
            break;
        default:
            throw new IllegalArgumentException(action + " is not a valid action for acl");
    }
}
Also used : CifsAcl(com.iwave.ext.netappc.model.CifsAcl) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 19 with ShareACL

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

the class NetAppClusterModeDevice method updateShareACLs.

@Override
public BiosCommandResult updateShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
    List<ShareACL> existingAcls = new ArrayList<ShareACL>();
    existingAcls = args.getExistingShareAcls();
    String portGroup = findSVMName(args.getFs());
    BiosCommandResult result = new BiosCommandResult();
    NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
    try {
        processAclsForShare(ncApi, args);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::updateShareACLs failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToUpdateCIFSShareAcl();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
        // if delete or modify fails , revert to old acl
        rollbackShareACLs(storage, args, existingAcls);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 20 with ShareACL

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

the class IsilonFileStorageDevice method extraShareACLFromArray.

/**
 * Get the Share ACL which are present in array but not in CoprHD Database.
 *
 * @param storage
 * @param args
 * @return Map with domain+ group or username with ShareACL
 */
private Map<String, ShareACL> extraShareACLFromArray(StorageSystem storage, FileDeviceInputOutput args) {
    // get all Share ACL from CoprHD data base
    List<ShareACL> existingDBShareACL = args.getExistingShareAcls();
    Map<String, ShareACL> arrayShareACLMap = new HashMap<>();
    // get the all the Share ACL from the storage system.
    IsilonApi isi = getIsilonDevice(storage);
    String zoneName = getZoneName(args.getvNAS());
    IsilonSMBShare share = null;
    if (zoneName != null) {
        share = isi.getShare(args.getShareName(), zoneName);
    } else {
        share = isi.getShare(args.getShareName());
    }
    if (share != null) {
        List<Permission> permissions = share.getPermissions();
        for (Permission perm : permissions) {
            if (perm.getPermissionType().equalsIgnoreCase(Permission.PERMISSION_TYPE_ALLOW)) {
                ShareACL shareACL = new ShareACL();
                shareACL.setPermission(perm.getPermission());
                String userAndDomain = perm.getTrustee().getName();
                String[] trustees = new String[2];
                trustees = userAndDomain.split("\\\\");
                String trusteesType = perm.getTrustee().getType();
                if (trustees.length > 1) {
                    shareACL.setDomain(trustees[0]);
                    if (trusteesType.equals("group")) {
                        shareACL.setGroup(trustees[1]);
                    } else {
                        shareACL.setUser(trustees[1]);
                    }
                } else {
                    if (trusteesType.equals("group")) {
                        shareACL.setGroup(trustees[0]);
                    } else {
                        shareACL.setUser(trustees[0]);
                    }
                }
                arrayShareACLMap.put(perm.getTrustee().getName(), shareACL);
            }
        }
        for (Iterator iterator = existingDBShareACL.iterator(); iterator.hasNext(); ) {
            ShareACL shareACL = (ShareACL) iterator.next();
            String key = "";
            String domain = "";
            String user = shareACL.getUser();
            String group = shareACL.getGroup();
            if (shareACL.getDomain() != null && !shareACL.getDomain().isEmpty()) {
                domain = shareACL.getDomain() + "\\";
            }
            if (user != null && !user.isEmpty()) {
                key = domain + user;
            } else if (group != null && !group.isEmpty()) {
                key = domain + group;
            }
            if (arrayShareACLMap.containsKey(key)) {
                arrayShareACLMap.remove(key);
            }
        }
    }
    return arrayShareACLMap;
}
Also used : HashMap(java.util.HashMap) IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) Permission(com.emc.storageos.isilon.restapi.IsilonSMBShare.Permission) Iterator(java.util.Iterator) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) ShareACL(com.emc.storageos.model.file.ShareACL)

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