Search in sources :

Example 6 with CifsAcl

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

the class FlexFileShare method listCIFSAcls.

public List<CifsAcl> listCIFSAcls(String shareName) {
    List<CifsAcl> acls = new ArrayList<CifsAcl>();
    String tagNext = null;
    NaElement elem = new NaElement("cifs-share-access-control-get-iter");
    if (shareName != null && !shareName.isEmpty()) {
        NaElement accessAttr = new NaElement("cifs-share-access-control");
        accessAttr.addNewChild("share", shareName);
        NaElement query = new NaElement("query");
        query.addChildElem(accessAttr);
        elem.addChildElem(query);
    }
    try {
        do {
            NaElement result = server.invokeElem(elem);
            tagNext = result.getChildContent("next-tag");
            NaElement cifsAcl = result.getChildByName("attributes-list");
            if (cifsAcl != null) {
                List<NaElement> cifacls = cifsAcl.getChildren();
                for (NaElement shareElem : cifacls) {
                    NaElement permission = shareElem.getChildByName("permission");
                    String name = shareElem.getChildContent("share");
                    CifsAcl acl = new CifsAcl();
                    try {
                        acl.setAccess(CifsAccess.valueOfAccess(permission.getContent()));
                    } catch (IllegalArgumentException e) {
                        log.warn("Invalid permission for a CIFS share: " + name, e);
                        log.info("Continue with next acl");
                        continue;
                    }
                    acl.setShareName(name);
                    String userorgroup = shareElem.getChildContent("user-or-group");
                    acl.setUserName(userorgroup);
                    acls.add(acl);
                }
            } else {
                return acls;
            }
            if (tagNext != null && !tagNext.isEmpty()) {
                elem = new NaElement("cifs-share-access-control-get-iter");
                if (shareName != null && !shareName.isEmpty()) {
                    NaElement accessAttr = new NaElement("cifs-share-access-control");
                    accessAttr.addNewChild("share", shareName);
                    NaElement query = new NaElement("query");
                    query.addChildElem(accessAttr);
                    elem.addChildElem(query);
                }
                elem.addNewChild("tag-next", tagNext);
            }
        } while (tagNext != null && !tagNext.isEmpty());
        return acls;
    } catch (Exception e) {
        String msg = "Failed to list CIFS ACLs.";
        log.error(msg, e);
        throw new NetAppCException(msg, e);
    }
}
Also used : CifsAcl(com.iwave.ext.netappc.model.CifsAcl) ArrayList(java.util.ArrayList) NaElement(netapp.manage.NaElement) NaAPIFailedException(netapp.manage.NaAPIFailedException)

Example 7 with CifsAcl

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

the class NetAppClusterApi method listCIFSShareAcl.

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

Example 8 with CifsAcl

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

the class NetAppClusterApi method addCIFSShareAcl.

public boolean addCIFSShareAcl(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.addCIFSAcl(acl);
        }
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppCException.exceptions.addCifsShareAclFailed(shareName, e.getMessage());
    }
    return true;
}
Also used : CifsAcl(com.iwave.ext.netappc.model.CifsAcl) NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade)

Example 9 with CifsAcl

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

the class NetAppClusterModeCommIntf method getACLs.

/**
 * get ACLs for smb shares of fs object
 *
 * @param unManagedSMBFileShareHashSet
 * @param netAppClusterApi
 * @param fsId
 * @return
 */
private List<UnManagedCifsShareACL> getACLs(HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet, NetAppClusterApi netAppClusterApi, StorageSystem storageSystem, URI fsId) {
    _logger.info("gets all acls of fileshares given fsid ", fsId);
    // get list of acls for given set of shares
    UnManagedCifsShareACL unManagedCifsShareACL = null;
    List<UnManagedCifsShareACL> unManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
    // get acls for each share
    List<CifsAcl> cifsAclList = null;
    for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBFileShareHashSet) {
        // find acl for given share
        String unManagedSMBFileShareName = unManagedSMBFileShare.getName();
        _logger.info("new smb share name: {} and fs: {}", unManagedSMBFileShareName, fsId);
        cifsAclList = netAppClusterApi.listCIFSShareAcl(unManagedSMBFileShareName);
        if (cifsAclList != null && !cifsAclList.isEmpty()) {
            for (CifsAcl cifsAcl : cifsAclList) {
                _logger.info("cifs share ACL: {} ", cifsAcl.toString());
                unManagedCifsShareACL = new UnManagedCifsShareACL();
                unManagedCifsShareACL.setShareName(unManagedSMBFileShareName);
                String user = cifsAcl.getUserName();
                if (user != null) {
                    unManagedCifsShareACL.setUser(user);
                } else {
                    unManagedCifsShareACL.setGroup(cifsAcl.getGroupName());
                }
                // permission
                unManagedCifsShareACL.setPermission(cifsAcl.getAccess().name());
                unManagedCifsShareACL.setId(URIUtil.createId(UnManagedCifsShareACL.class));
                // filesystem id
                unManagedCifsShareACL.setFileSystemId(fsId);
                // set the native guid
                String fsShareNativeId = unManagedCifsShareACL.getFileSystemShareACLIndex();
                // _logger.info("UMFS Share ACL index {}", fsShareNativeId);
                String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
                _logger.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
                unManagedCifsShareACL.setNativeGuid(fsUnManagedFileShareNativeGuid);
                // add the acl to acl-list
                unManagedCifsShareACLList.add(unManagedCifsShareACL);
            }
            _logger.info("new smb share name-: {} and ACL count: {}", unManagedSMBFileShareName, cifsAclList.size());
        }
    }
    return unManagedCifsShareACLList;
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) CifsAcl(com.iwave.ext.netappc.model.CifsAcl) ArrayList(java.util.ArrayList)

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