Search in sources :

Example 1 with CifsAcl

use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.

the class NetAppClusterModeDevice method createNtpShare.

/**
 * create NetAppC share with right permissions
 *
 * @param StorageSystem mount path of the fileshare
 * @param args containing input/out arguments of filedevice
 * @param smbFileShare smbFileshare object
 * @param forceGroup Name of the group the fileshare belongs.
 * @return
 */
private Boolean createNtpShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare, String forceGroup) throws NetAppCException {
    String shareId = null;
    String portGroup = findSVMName(args.getFs());
    NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
    shareId = smbFileShare.getPath();
    _log.info("NetAppClusterModeDevice doShare for {} with id {}", shareId, args.getFileObjId());
    if (!ncApi.doShare(shareId, smbFileShare.getName(), smbFileShare.getDescription(), smbFileShare.getMaxUsers(), smbFileShare.getPermission(), forceGroup)) {
        _log.info("NetAppClusterModeDevice doShare for {} with id {} - failed", shareId, args.getFileObjId());
        return false;
    } else {
        // permission.
        if (!ncApi.modifyShare(shareId, smbFileShare.getName(), smbFileShare.getDescription(), smbFileShare.getMaxUsers(), smbFileShare.getPermission(), forceGroup)) {
            // Cleanup the share if permission update is
            // unsuccessful.
            doDeleteShare(storage, args, smbFileShare);
            _log.info("NetAppClusterModeDevice doShare for {} with id {} - failed", shareId, args.getFileObjId());
            return false;
        } else {
            smbFileShare.setNativeId(shareId);
            // share creation is successful,no need to set permission,clear the default one.
            List<CifsAcl> existingAcls = new ArrayList<CifsAcl>();
            CifsAcl defaultAcl = new CifsAcl();
            // By default NetApp share get everyone full access.
            defaultAcl.setUserName("everyone");
            defaultAcl.setAccess(CifsAccess.full);
            existingAcls.add(defaultAcl);
            ncApi.deleteCIFSShareAcl(smbFileShare.getName(), existingAcls);
            smbFileShare.setNetBIOSName(ncApi.getNetBiosName());
            _log.info("NetAppClusterModeDevice doShare for {} with id {} - complete", shareId, args.getFileObjId());
            return true;
        }
    }
}
Also used : NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) CifsAcl(com.iwave.ext.netappc.model.CifsAcl) ArrayList(java.util.ArrayList)

Example 2 with CifsAcl

use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.

the class NetAppClusterApi method modifyShare.

public Boolean modifyShare(String mntpath, String shareName, String comment, int maxusers, String permission, String forcegroup) throws NetAppCException {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        CifsAcl acl = new CifsAcl();
        acl.setShareName(shareName);
        acl.setAccess(CifsAccess.valueOfAccess(cifsPermissionMap.get(permission)));
        acl.setUserName(CIFS_DEFAULT_GROUP);
        netAppClusterFacade.setCIFSAcl(acl);
        return true;
    } catch (Exception e) {
        throw NetAppCException.exceptions.modifyShareFailed(_ipAddress, e.getMessage());
    }
}
Also used : CifsAcl(com.iwave.ext.netappc.model.CifsAcl) NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade)

Example 3 with CifsAcl

use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.

the class NetAppClusterApi method modifyCIFSShareAcl.

public boolean modifyCIFSShareAcl(String shareName, List<CifsAcl> acls) {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        _logger.info("Facade created : {} ", netAppClusterFacade);
        for (CifsAcl acl : acls) {
            acl.setShareName(shareName);
            netAppClusterFacade.setCIFSAcl(acl);
        }
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppCException.exceptions.modifyCifsShareAclFailed(shareName, e.getMessage());
    }
    return true;
}
Also used : CifsAcl(com.iwave.ext.netappc.model.CifsAcl) NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade)

Example 4 with CifsAcl

use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.

the class NetAppClusterApi method deleteCIFSShareAcl.

public boolean deleteCIFSShareAcl(String shareName, List<CifsAcl> acls) {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        _logger.info("Facade created : {} ", netAppClusterFacade);
        for (CifsAcl acl : acls) {
            acl.setShareName(shareName);
            netAppClusterFacade.deleteCIFSAcl(acl);
        }
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppCException.exceptions.deleteCIFSShareAclFailed(shareName, e.getMessage());
    }
    return true;
}
Also used : CifsAcl(com.iwave.ext.netappc.model.CifsAcl) NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade)

Example 5 with CifsAcl

use of com.iwave.ext.netappc.model.CifsAcl 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)

Aggregations

CifsAcl (com.iwave.ext.netappc.model.CifsAcl)9 NetAppClusterFacade (com.iwave.ext.netappc.NetAppClusterFacade)5 ArrayList (java.util.ArrayList)4 UnManagedCifsShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL)1 UnManagedSMBFileShare (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ShareACL (com.emc.storageos.model.file.ShareACL)1 NetAppException (com.emc.storageos.netapp.NetAppException)1 NetAppCException (com.emc.storageos.netappc.NetAppCException)1 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 NaAPIFailedException (netapp.manage.NaAPIFailedException)1 NaElement (netapp.manage.NaElement)1