Search in sources :

Example 1 with CifsServerMap

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

the class IsilonFileStorageDevice method getIdForDomainUserOrGroup.

/**
 * It search all the provider configured in NASServer and gives sid for the user/group and Domain
 * if checkUidRange is enable and uid value is between 1,000,000-2,000,000 return sid,.Otherwise uid or gid
 *
 * @param isi Isilon Api to connect with Isilon
 * @param nas - NASServer object to get all the provider info.
 * @param domain -domain should be in FQDN format
 * @param user name of the user
 * @param type can be user or group
 * @param checkUidRangeEnable to enable the uid range check
 * @return sidOrUid if found or else empty String
 */
private String getIdForDomainUserOrGroup(IsilonApi isi, NASServer nas, String domain, String user, String type, boolean checkUidRangeEnable) {
    // we can get all auth providers and zone name from NASServer
    String sidOrUid = "";
    boolean sidOrUidfound = false;
    try {
        String zone = nas.getNasName();
        List<String> authProviders = new ArrayList<String>();
        CifsServerMap cifsServersMap = nas.getCifsServersMap();
        authProviders = getAuthProviderListFromCifsServerMap(cifsServersMap);
        _log.info("Auth providers for NASServer {} are {} ", nas.getNasName(), authProviders);
        for (String provider : authProviders) {
            if ("user".equals(type)) {
                // no need of resume token as we are expecting only one result.
                List<IsilonUser> userDetails = isi.getUsersDetail(zone, provider, domain, user, "");
                if (!CollectionUtils.isEmpty(userDetails)) {
                    IsilonIdentity sid = userDetails.get(0).getSid();
                    sidOrUid = sid.getId();
                    sidOrUidfound = true;
                    // Range check is only done for nfsacl, should be true for it.
                    if (checkUidRangeEnable) {
                        // For gid, check what range it�s in. If it�s 1,000,000-2,000,000,
                        // it�s generated by OneFS and you should use the SID. Otherwise you should use the unix gid.
                        IsilonIdentity uid = userDetails.get(0).getUid();
                        if (isUidInRange(uid)) {
                            _log.debug("using uid {} instead of sid {} ", uid.getId(), sidOrUid);
                            sidOrUid = uid.getId();
                        }
                    }
                    _log.info("For user name {} and domain {} sid/uid is {}", user, domain, sidOrUid);
                    break;
                }
            } else {
                List<IsilonGroup> groupDetails = isi.getGroupsDetail(zone, provider, domain, user, "");
                // no need of resume token as we are expecting only one result.
                if (!CollectionUtils.isEmpty(groupDetails)) {
                    IsilonIdentity id = groupDetails.get(0).getSid();
                    sidOrUid = id.getId();
                    sidOrUidfound = true;
                    if (checkUidRangeEnable) {
                        // For gid, check what range it�s in. If it�s 1,000,000-2,000,000,
                        // it�s generated by OneFS and you should use the SID. Otherwise you should use the unix gid.
                        IsilonIdentity gid = groupDetails.get(0).getGid();
                        if (isUidInRange(gid)) {
                            _log.debug("using gid {} instead of sid {} ", gid.getId(), sidOrUid);
                            sidOrUid = gid.getId();
                        }
                    }
                    _log.info("For group name {} and domain {} sid is {}", user, domain, sidOrUid);
                    break;
                }
            }
        }
    } catch (IsilonException e) {
        _log.error("Error while finding sid/uid for name {} and domain {} ", user, domain, e);
    }
    if (sidOrUidfound) {
        _log.info("Sid/uid for user name {}, type {} and domain {} is {}", user, type, domain, sidOrUid);
    } else {
        _log.error("No sid/uid found for user name {}, type {} and domain {} ", user, type, domain);
    }
    return sidOrUid;
}
Also used : CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) ArrayList(java.util.ArrayList) IsilonUser(com.emc.storageos.isilon.restapi.IsilonUser) IsilonIdentity(com.emc.storageos.isilon.restapi.IsilonIdentity) IsilonGroup(com.emc.storageos.isilon.restapi.IsilonGroup) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 2 with CifsServerMap

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

the class VNXFileCommunicationInterface method discoverVdmPortGroups.

/**
 * Discover the Data Movers (Port Groups) for the specified VNX File storage array.
 *
 * @param system storage system information including credentials.
 * @param movers Collection of all DataMovers in the VNX File storage array
 * @return Map of New and Existing VDM port groups
 * @throws VNXFileCollectionException
 */
private HashMap<String, List<StorageHADomain>> discoverVdmPortGroups(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException {
    HashMap<String, List<StorageHADomain>> portGroups = new HashMap();
    List<StorageHADomain> newPortGroups = new ArrayList<StorageHADomain>();
    List<StorageHADomain> existingPortGroups = new ArrayList<StorageHADomain>();
    _logger.info("Start vdm port group discovery for storage system {}", system.getId());
    List<VirtualNAS> newNasServers = new ArrayList<VirtualNAS>();
    List<VirtualNAS> existingNasServers = new ArrayList<VirtualNAS>();
    List<VNXVdm> vdms = getVdmPortGroups(system);
    _logger.debug("Number VDM found: {}", vdms.size());
    VNXFileSshApi sshDmApi = new VNXFileSshApi();
    sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
    for (VNXVdm vdm : vdms) {
        StorageHADomain portGroup = null;
        // Check supported network file sharing protocols.
        StringSet protocols = new StringSet();
        if (null == vdm) {
            _logger.debug("Null vdm in list of port groups.");
            continue;
        }
        // Check if port group was previously discovered
        URIQueryResultList results = new URIQueryResultList();
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vdm.getVdmName(), NativeGUIDGenerator.ADAPTER);
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
        Iterator<URI> iter = results.iterator();
        while (iter.hasNext()) {
            StorageHADomain tmpGroup = _dbClient.queryObject(StorageHADomain.class, iter.next());
            if (tmpGroup != null && !tmpGroup.getInactive() && tmpGroup.getStorageDeviceURI().equals(system.getId())) {
                portGroup = tmpGroup;
                _logger.debug("Found duplicate {} ", vdm.getVdmName());
                break;
            }
        }
        Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
        Set<String> intfs = null;
        if (vdmIntfs != null) {
            intfs = vdmIntfs.keySet();
        }
        // if NFS Interfaces are not there ignore this..
        if (vdmIntfs == null || intfs.isEmpty()) {
            // There are no interfaces for this VDM via nas_server command
            // so ignore this
            _logger.info("Ignoring VDM {} because no NFS interfaces found via ssh query", vdm.getVdmName());
        } else {
            _logger.info("Process VDM {} because  interfaces found {}", vdm.getVdmName(), vdmIntfs.keySet().size());
        }
        for (String intf : intfs) {
            String vdmCapability = vdmIntfs.get(intf);
            _logger.info("Interface {} capability [{}]", vdm.getVdmName() + ":" + intf, vdmCapability);
            if (vdmCapability.contains("cifs")) {
                _logger.info("{} has CIFS Enabled since interfaces are found ", vdm.getVdmName(), intf + ":" + vdmCapability);
                protocols.add(StorageProtocol.File.CIFS.name());
            }
            if (vdmCapability.contains("vdm")) {
                _logger.info("{} has NFS Enabled since interfaces are found ", vdm.getVdmName(), intf + ":" + vdmCapability);
                protocols.add(StorageProtocol.File.NFS.name());
            }
        }
        List<VNXCifsServer> cifsServers = getCifServers(system, vdm.getVdmId(), "true");
        CifsServerMap cifsServersMap = new CifsServerMap();
        for (VNXCifsServer cifsServer : cifsServers) {
            _logger.info("Cifs Server {} for {} ", cifsServer.getName(), vdm.getVdmName());
            if (!cifsServer.getInterfaces().isEmpty()) {
                _logger.info("{} has CIFS Enabled since interfaces are found ", vdm.getVdmName(), cifsServer.getName() + ":" + cifsServer.getInterfaces());
                protocols.add(StorageProtocol.File.CIFS.name());
                NasCifsServer nasCifsServer = new NasCifsServer();
                nasCifsServer.setId(cifsServer.getId());
                nasCifsServer.setInterfaces(cifsServer.getInterfaces());
                nasCifsServer.setMoverIdIsVdm(cifsServer.getMoverIdIsVdm());
                nasCifsServer.setName(cifsServer.getName());
                nasCifsServer.setType(cifsServer.getType());
                nasCifsServer.setDomain(cifsServer.getDomain());
                cifsServersMap.put(cifsServer.getName(), nasCifsServer);
            }
        }
        if (protocols.isEmpty()) {
            // No valid interfaces found and ignore this
            _logger.info("Ignoring VDM {} because no NFS/CIFS interfaces found ", vdm.getVdmName());
            continue;
        }
        // If the data mover (aka port group) was not previously discovered
        if (portGroup == null) {
            portGroup = new StorageHADomain();
            portGroup.setId(URIUtil.createId(StorageHADomain.class));
            portGroup.setNativeGuid(adapterNativeGuid);
            portGroup.setStorageDeviceURI(system.getId());
            portGroup.setAdapterName(vdm.getVdmName());
            portGroup.setName(vdm.getVdmId());
            portGroup.setFileSharingProtocols(protocols);
            portGroup.setVirtual(true);
            portGroup.setAdapterType(StorageHADomain.HADomainType.VIRTUAL.toString());
            // Get parent Data Mover
            StorageHADomain matchingParentMover = getMatchingMoverById(movers, vdm.getMoverId());
            // Check for valid data mover
            if (null != matchingParentMover) {
                portGroup.setParentHADomainURI(matchingParentMover.getId());
            } else {
                _logger.info("Matching parent DataMover {} for {} not found ", vdm.getMoverId(), vdm.getVdmName());
            }
            _logger.info("Found Vdm {} at {}", vdm.getVdmName(), vdm.getVdmId() + "@" + vdm.getMoverId());
            newPortGroups.add(portGroup);
        } else {
            // For rediscovery if cifs is not enabled
            portGroup.setFileSharingProtocols(protocols);
            existingPortGroups.add(portGroup);
        }
        VirtualNAS existingNas = findvNasByNativeId(system, vdm.getVdmId());
        if (existingNas != null) {
            existingNas.setProtocols(protocols);
            existingNas.setCifsServersMap(cifsServersMap);
            existingNas.setNasState(vdm.getState());
            existingNas.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            PhysicalNAS parentNas = findPhysicalNasByNativeId(system, vdm.getMoverId());
            if (parentNas != null) {
                existingNas.setParentNasUri(parentNas.getId());
            }
            existingNasServers.add(existingNas);
        } else {
            VirtualNAS vNas = createVirtualNas(system, vdm);
            if (vNas != null) {
                vNas.setProtocols(protocols);
                vNas.setCifsServersMap(cifsServersMap);
                newNasServers.add(vNas);
            }
        }
    }
    List<VirtualNAS> discoveredVNasServers = new ArrayList<VirtualNAS>();
    // Persist the NAS servers!!!
    if (existingNasServers != null && !existingNasServers.isEmpty()) {
        _logger.info("discoverVdmPortGroups - modified VirtualNAS servers size {}", existingNasServers.size());
        _dbClient.persistObject(existingNasServers);
        discoveredVNasServers.addAll(existingNasServers);
    }
    if (newNasServers != null && !newNasServers.isEmpty()) {
        _logger.info("discoverVdmPortGroups - new VirtualNAS servers size {}", newNasServers.size());
        _dbClient.createObject(newNasServers);
        discoveredVNasServers.addAll(newNasServers);
    }
    // Verify the existing vnas servers!!!
    DiscoveryUtils.checkVirtualNasNotVisible(discoveredVNasServers, _dbClient, system.getId());
    _logger.info("Vdm Port group discovery for storage system {} complete.", system.getId());
    for (StorageHADomain newDomain : newPortGroups) {
        _logger.debug("New Storage Domain : {} : {}", newDomain.getNativeGuid(), newDomain.getAdapterName() + ":" + newDomain.getId());
    }
    for (StorageHADomain domain : existingPortGroups) {
        _logger.debug("Old Storage Domain : {} : {}", domain.getNativeGuid(), domain.getAdapterName() + ":" + domain.getId());
    }
    // return portGroups;
    portGroups.put(NEW, newPortGroups);
    portGroups.put(EXISTING, existingPortGroups);
    return portGroups;
}
Also used : VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 3 with CifsServerMap

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

the class VNXFileCommunicationInterface method discoverPortGroups.

/**
 * Discover the Data Movers (Port Groups) for the specified VNX File storage array.
 *
 * @param system storage system information including credentials.
 * @return Map of New and Existing port groups
 * @throws VNXFileCollectionException
 */
private HashMap<String, List<StorageHADomain>> discoverPortGroups(StorageSystem system, StringSet fileSharingProtocols) throws VNXFileCollectionException, VNXException {
    HashMap<String, List<StorageHADomain>> portGroups = new HashMap<String, List<StorageHADomain>>();
    List<StorageHADomain> newPortGroups = new ArrayList<StorageHADomain>();
    List<StorageHADomain> existingPortGroups = new ArrayList<StorageHADomain>();
    boolean isNfsCifsSupported = false;
    List<PhysicalNAS> newNasServers = new ArrayList<PhysicalNAS>();
    List<PhysicalNAS> existingNasServers = new ArrayList<PhysicalNAS>();
    _logger.info("Start port group discovery for storage system {}", system.getId());
    List<VNXDataMover> dataMovers = getPortGroups(system);
    _logger.debug("Number movers found: {}", dataMovers.size());
    for (VNXDataMover mover : dataMovers) {
        StorageHADomain portGroup = null;
        if (null == mover) {
            _logger.debug("Null data mover in list of port groups.");
            continue;
        }
        if (mover.getRole().equals(DM_ROLE_STANDBY)) {
            _logger.debug("Found standby data mover");
            continue;
        }
        // Check if port group was previously discovered
        URIQueryResultList results = new URIQueryResultList();
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, mover.getName(), NativeGUIDGenerator.ADAPTER);
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
        Iterator<URI> iter = results.iterator();
        while (iter.hasNext()) {
            StorageHADomain tmpGroup = _dbClient.queryObject(StorageHADomain.class, iter.next());
            if (tmpGroup != null && !tmpGroup.getInactive() && tmpGroup.getStorageDeviceURI().equals(system.getId())) {
                portGroup = tmpGroup;
                _logger.debug("Found duplicate {} ", mover.getName());
            }
        }
        List<VNXCifsServer> cifsServers = getCifServers(system, String.valueOf(mover.getId()), "false");
        CifsServerMap cifsServersMap = new CifsServerMap();
        for (VNXCifsServer cifsServer : cifsServers) {
            _logger.info("Cifs Server {} for {} ", cifsServer.getName(), mover.getName());
            NasCifsServer nasCifsServer = new NasCifsServer();
            nasCifsServer.setId(cifsServer.getId());
            nasCifsServer.setInterfaces(cifsServer.getInterfaces());
            nasCifsServer.setMoverIdIsVdm(cifsServer.getMoverIdIsVdm());
            nasCifsServer.setName(cifsServer.getName());
            nasCifsServer.setType(cifsServer.getType());
            nasCifsServer.setDomain(cifsServer.getDomain());
            cifsServersMap.put(cifsServer.getName(), nasCifsServer);
        }
        // Check supported network file sharing protocols.
        StringSet protocols = new StringSet();
        protocols.add(StorageProtocol.File.NFS.name());
        protocols.add(StorageProtocol.File.CIFS.name());
        // If the data mover (aka port group) was not previously discovered
        if (portGroup == null) {
            portGroup = new StorageHADomain();
            portGroup.setId(URIUtil.createId(StorageHADomain.class));
            portGroup.setNativeGuid(adapterNativeGuid);
            portGroup.setStorageDeviceURI(system.getId());
            portGroup.setAdapterName(mover.getName());
            portGroup.setVirtual(false);
            portGroup.setName((Integer.toString(mover.getId())));
            portGroup.setFileSharingProtocols(protocols);
            _logger.info("Found data mover {} at {}", mover.getName(), mover.getId());
            newPortGroups.add(portGroup);
        } else {
            // Set protocols if it has changed between discoveries or a upgrade scenario
            portGroup.setFileSharingProtocols(protocols);
            existingPortGroups.add(portGroup);
        }
        PhysicalNAS existingNas = findPhysicalNasByNativeId(system, String.valueOf(mover.getId()));
        if (existingNas != null) {
            existingNas.setProtocols(protocols);
            existingNas.setCifsServersMap(cifsServersMap);
            existingNasServers.add(existingNas);
        } else {
            PhysicalNAS physicalNas = createPhysicalNas(system, mover);
            if (physicalNas != null) {
                physicalNas.setProtocols(protocols);
                physicalNas.setCifsServersMap(cifsServersMap);
                newNasServers.add(physicalNas);
            }
        }
    }
    // Persist the NAS servers!!!
    if (existingNasServers != null && !existingNasServers.isEmpty()) {
        _logger.info("discoverPortGroups - modified PhysicalNAS servers size {}", existingNasServers.size());
        _dbClient.persistObject(existingNasServers);
    }
    if (newNasServers != null && !newNasServers.isEmpty()) {
        _logger.info("discoverPortGroups - new PhysicalNAS servers size {}", newNasServers.size());
        _dbClient.createObject(newNasServers);
    }
    // With current API, NFS/CIFS is assumed to be always supported.
    fileSharingProtocols.add(StorageProtocol.File.NFS.name());
    fileSharingProtocols.add(StorageProtocol.File.CIFS.name());
    _logger.info("Port group discovery for storage system {} complete.", system.getId());
    for (StorageHADomain newDomain : newPortGroups) {
        _logger.info("New Storage Domain : {} : {}", newDomain.getNativeGuid(), newDomain.getAdapterName() + ":" + newDomain.getId());
    }
    for (StorageHADomain domain : existingPortGroups) {
        _logger.info("Old Storage Domain : {} : {}", domain.getNativeGuid(), domain.getAdapterName() + ":" + domain.getId());
    }
    // return portGroups;
    portGroups.put(NEW, newPortGroups);
    portGroups.put(EXISTING, existingPortGroups);
    return portGroups;
}
Also used : VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXDataMover(com.emc.storageos.vnx.xmlapi.VNXDataMover) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 4 with CifsServerMap

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

the class VNXUnityCommunicationInterface method discoverNasServers.

/**
 * Discover the NasServer (Port Groups) for the specified VNXe storage
 * array.
 *
 * @param system
 *            storage system information
 * @param client
 *            VNXeServiceClient
 * @param nasServerIdMap
 *            all valid nasServer id map
 * @param arraySupportedProtocol
 *            array supported protocol
 * @return Map of New and Existing NasServers
 * @throws VNXeException
 */
private HashMap<String, List<StorageHADomain>> discoverNasServers(StorageSystem system, VNXeApiClient client, Map<String, URI> nasServerIdMap, StringSet arraySupportedProtocols) throws VNXeException {
    HashMap<String, List<StorageHADomain>> allNasServers = new HashMap<String, List<StorageHADomain>>();
    List<StorageHADomain> newNasServers = new ArrayList<StorageHADomain>();
    List<StorageHADomain> existingNasServers = new ArrayList<StorageHADomain>();
    List<VirtualNAS> newVirtualNas = new ArrayList<VirtualNAS>();
    List<VirtualNAS> existingVirtualNas = new ArrayList<VirtualNAS>();
    boolean isNFSSupported = false;
    boolean isCIFSSupported = false;
    boolean isBothSupported = false;
    _logger.info("Start NasServer discovery for storage system {}", system.getId());
    List<VNXeNasServer> nasServers = client.getNasServers();
    List<VNXeCifsServer> cifsServers = client.getCifsServers();
    List<VNXeNfsServer> nfsServers = client.getNfsServers();
    for (VNXeNasServer nasServer : nasServers) {
        StorageHADomain haDomain = null;
        if (null == nasServer) {
            _logger.debug("Null data mover in list of port groups.");
            continue;
        }
        if ((nasServer.getMode() == VNXeNasServer.NasServerModeEnum.DESTINATION) || nasServer.getIsReplicationDestination()) {
            _logger.debug("Found a replication destination NasServer");
            // On failover the existing Nas server becomes the destination. So changing state to unknown as it
            // should not be picked for provisioning.
            VirtualNAS vNas = findvNasByNativeId(system, nasServer.getId());
            if (vNas != null) {
                vNas.setNasState(VirtualNasState.UNKNOWN.name());
                existingVirtualNas.add(vNas);
            }
            continue;
        }
        if (nasServer.getIsSystem()) {
            // skip system nasServer
            continue;
        }
        StringSet protocols = new StringSet();
        // Check if port group was previously discovered
        URIQueryResultList results = new URIQueryResultList();
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nasServer.getName(), NativeGUIDGenerator.ADAPTER);
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
        Iterator<URI> it = results.iterator();
        if (it.hasNext()) {
            StorageHADomain tmpDomain = _dbClient.queryObject(StorageHADomain.class, it.next());
            if (tmpDomain.getStorageDeviceURI().equals(system.getId())) {
                haDomain = tmpDomain;
                _logger.debug("Found duplicate {} ", nasServer.getName());
            }
        }
        // get the supported protocol on the nasServer
        if (cifsServers != null && !cifsServers.isEmpty()) {
            for (VNXeCifsServer cifsServer : cifsServers) {
                if (cifsServer.getNasServer().getId().equals(nasServer.getId())) {
                    protocols.add(StorageProtocol.File.CIFS.name());
                    isCIFSSupported = true;
                    break;
                }
            }
        }
        if (nfsServers != null && !nfsServers.isEmpty()) {
            for (VNXeNfsServer nfsServer : nfsServers) {
                if (nfsServer.getNasServer() != null) {
                    if (nfsServer.getNasServer().getId().equals(nasServer.getId())) {
                        protocols.add(StorageProtocol.File.NFS.name());
                        isNFSSupported = true;
                        break;
                    }
                }
            }
        }
        if (protocols.size() == 2) {
            // this nasServer support both
            isBothSupported = true;
        }
        // If the nasServer was not previously discovered
        if (haDomain == null) {
            haDomain = new StorageHADomain();
            haDomain.setId(URIUtil.createId(StorageHADomain.class));
            haDomain.setNativeGuid(adapterNativeGuid);
            haDomain.setStorageDeviceURI(system.getId());
            haDomain.setAdapterName(nasServer.getName());
            haDomain.setName(nasServer.getName());
            haDomain.setSerialNumber(nasServer.getId());
            newNasServers.add(haDomain);
        } else {
            existingNasServers.add(haDomain);
        }
        haDomain.setFileSharingProtocols(protocols);
        haDomain.setVirtual(true);
        nasServerIdMap.put(nasServer.getId(), haDomain.getId());
        CifsServerMap cifsServersMap = new CifsServerMap();
        for (VNXeCifsServer cifsServer : cifsServers) {
            if (cifsServer.getNasServer().getId().equals(nasServer.getId())) {
                _logger.info("Cifs Server {} for {} ", cifsServer.getName(), nasServer.getName());
                if (!cifsServer.getFileInterfaces().isEmpty()) {
                    _logger.info("{} has CIFS Enabled since interfaces are found ", nasServer.getName(), cifsServer.getName() + ":" + cifsServer.getFileInterfaces());
                    protocols.add(StorageProtocol.File.CIFS.name());
                    NasCifsServer nasCifsServer = new NasCifsServer();
                    nasCifsServer.setId(cifsServer.getId());
                    nasCifsServer.setMoverIdIsVdm(true);
                    nasCifsServer.setName(cifsServer.getName());
                    nasCifsServer.setDomain(cifsServer.getDomain());
                    cifsServersMap.put(cifsServer.getName(), nasCifsServer);
                }
            }
        }
        VirtualNAS vNas = findvNasByNativeId(system, nasServer.getId());
        // If the nasServer was not previously discovered
        if (vNas == null) {
            vNas = new VirtualNAS();
            vNas.setId(URIUtil.createId(VirtualNAS.class));
            String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nasServer.getId(), NativeGUIDGenerator.VIRTUAL_NAS);
            vNas.setNativeGuid(nasNativeGuid);
            vNas.setStorageDeviceURI(system.getId());
            vNas.setNasName(nasServer.getName());
            vNas.setNativeId(nasServer.getId());
            newVirtualNas.add(vNas);
        } else {
            existingVirtualNas.add(vNas);
        }
        vNas.setProtocols(protocols);
        vNas.setNasState(VirtualNasState.LOADED.name());
        vNas.setCifsServersMap(cifsServersMap);
    }
    // Persist the NAS servers!!!
    if (existingVirtualNas != null && !existingVirtualNas.isEmpty()) {
        _logger.info("discoverNasServers - modified VirtualNAS servers size {}", existingVirtualNas.size());
        _dbClient.updateObject(existingVirtualNas);
    }
    if (newVirtualNas != null && !newVirtualNas.isEmpty()) {
        _logger.info("discoverNasServers - new VirtualNAS servers size {}", newVirtualNas.size());
        _dbClient.createObject(newVirtualNas);
    }
    if (isBothSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.NFS.name());
        arraySupportedProtocols.add(StorageProtocol.File.CIFS.name());
    } else if (isNFSSupported && isCIFSSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.NFS_OR_CIFS.name());
    } else if (isNFSSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.NFS.name());
    } else if (isCIFSSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.CIFS.name());
    }
    _logger.info("NasServer discovery for storage system {} complete.", system.getId());
    for (StorageHADomain newDomain : newNasServers) {
        _logger.info("New NasServer : {} : {}", newDomain.getNativeGuid(), newDomain.getId());
    }
    for (StorageHADomain domain : existingNasServers) {
        _logger.info("Existing NasServer : {} : {}", domain.getNativeGuid(), domain.getId());
    }
    allNasServers.put(NEW, newNasServers);
    allNasServers.put(EXISTING, existingNasServers);
    return allNasServers;
}
Also used : HashMap(java.util.HashMap) VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) VNXeCifsServer(com.emc.storageos.vnxe.models.VNXeCifsServer) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) VNXeNfsServer(com.emc.storageos.vnxe.models.VNXeNfsServer) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 5 with CifsServerMap

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

the class IsilonCommunicationInterface method setCifsServerMapForNASServer.

/**
 * Set the cifs servers for accesszone
 *
 * @param isiAccessZone
 *            the Isilon access zone object
 * @param nasServer
 *            the NAS server in which CIF server map will be set
 */
private void setCifsServerMapForNASServer(final IsilonAccessZone isiAccessZone, NASServer nasServer) {
    if (nasServer == null) {
        return;
    }
    _log.info("Set the authentication providers for NAS: {}", nasServer.getNasName());
    String providerName = null;
    String domain = null;
    ArrayList<String> authArrayList = isiAccessZone.getAuth_providers();
    CifsServerMap cifsServersMap = nasServer.getCifsServersMap();
    if (cifsServersMap != null) {
        cifsServersMap.clear();
    } else {
        cifsServersMap = new CifsServerMap();
    }
    if (authArrayList != null && !authArrayList.isEmpty()) {
        for (String authProvider : authArrayList) {
            String[] providerArray = authProvider.split(":");
            providerName = providerArray[0];
            domain = providerArray[1];
            NasCifsServer nasCifsServer = new NasCifsServer();
            nasCifsServer.setName(providerName);
            nasCifsServer.setDomain(domain);
            cifsServersMap.put(providerName, nasCifsServer);
            _log.info("Setting provider: {} and domain: {}", providerName, domain);
        }
    }
    if (isiAccessZone.isAll_auth_providers() == true) {
        String[] providerArray = isiAccessZone.getSystem_provider().split(":");
        providerName = providerArray[0];
        domain = providerArray[1];
        NasCifsServer nasCifsServer = new NasCifsServer();
        nasCifsServer.setName(providerName);
        nasCifsServer.setDomain(domain);
        cifsServersMap.put(providerName, nasCifsServer);
        _log.info("Setting provider: {} and domain: {}", providerName, domain);
    }
    nasServer.setCifsServersMap(cifsServersMap);
}
Also used : CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer)

Aggregations

CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)5 NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)4 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 URI (java.net.URI)3 HashMap (java.util.HashMap)3 List (java.util.List)3 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)2 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)2 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)2 VNXCifsServer (com.emc.storageos.vnx.xmlapi.VNXCifsServer)2 LinkedList (java.util.LinkedList)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)1 IsilonGroup (com.emc.storageos.isilon.restapi.IsilonGroup)1 IsilonIdentity (com.emc.storageos.isilon.restapi.IsilonIdentity)1 IsilonUser (com.emc.storageos.isilon.restapi.IsilonUser)1 VNXDataMover (com.emc.storageos.vnx.xmlapi.VNXDataMover)1