Search in sources :

Example 1 with NasCifsServer

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

the class IsilonFileStorageDevice method getAuthProviderListFromCifsServerMap.

/**
 * Get the details for all provider form cifsServersMap
 *
 * @param cifsServersMap
 * @return
 */
private List<String> getAuthProviderListFromCifsServerMap(CifsServerMap cifsServersMap) {
    /*
         * ads Manage Active Directory Service providers.
         * ldap Manage LDAP authentication providers.
         * nis Manage NIS authentication providers.
         * example for a auth prover is lsa-activedirectory-provider:PROVISIONING.BOURNE.LOCAL
         */
    List<String> authProvider = new ArrayList<>();
    NasCifsServer adProvider = cifsServersMap.get(LSA_AD_PROVIDER);
    if (adProvider != null) {
        String adProvderString = adProvider.getName() + COLON + adProvider.getDomain();
        authProvider.add(adProvderString);
    }
    NasCifsServer ldapProvider = cifsServersMap.get(LSA_LDAP_PROVIDER);
    if (ldapProvider != null) {
        String ldapProvderString = ldapProvider.getName() + COLON + ldapProvider.getDomain();
        authProvider.add(ldapProvderString);
    }
    NasCifsServer nisProvider = cifsServersMap.get(LSA_NIS_PROVIDER);
    if (nisProvider != null) {
        String nisProvderString = nisProvider.getName() + COLON + nisProvider.getDomain();
        authProvider.add(nisProvderString);
    }
    NasCifsServer localProvider = cifsServersMap.get(LSA_LOCAL_PROVIDER);
    if (localProvider != null) {
        String localProviderString = localProvider.getName() + COLON + localProvider.getDomain();
        authProvider.add(localProviderString);
    }
    NasCifsServer fileProvider = cifsServersMap.get(LSA_FILE_PROVIDER);
    if (fileProvider != null) {
        String fileProviderString = fileProvider.getName() + COLON + fileProvider.getDomain();
        authProvider.add(fileProviderString);
    }
    return authProvider;
}
Also used : ArrayList(java.util.ArrayList) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer)

Example 2 with NasCifsServer

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

the class SystemsMapper method map.

public static VirtualNASRestRep map(VirtualNAS from, DbClient dbClient) {
    if (from == null) {
        return null;
    }
    VirtualNASRestRep to = new VirtualNASRestRep();
    mapDiscoveredDataObjectFields(from, to);
    to.setAssignedVirtualArrays(from.getAssignedVirtualArrays());
    to.setBaseDirPath(from.getBaseDirPath());
    to.setCompatibilityStatus(from.getCompatibilityStatus());
    to.setConnectedVirtualArrays(from.getConnectedVirtualArrays());
    to.setDiscoveryStatus(from.getDiscoveryStatus());
    to.setNasName(from.getNasName());
    to.setName(from.getNasName());
    to.setNasState(from.getNasState());
    to.setNasTag(from.getNAStag());
    if (from.getParentNasUri() != null) {
        PhysicalNAS pNAS = dbClient.queryObject(PhysicalNAS.class, from.getParentNasUri());
        // Self link will be empty as there is no Resource Type available
        // for PhysicalNAS
        to.setParentNASURI(toNamedRelatedResource(pNAS, pNAS.getNasName()));
    }
    to.setAssociatedProjects(from.getAssociatedProjects());
    to.setProtocols(from.getProtocols());
    to.setRegistrationStatus(from.getRegistrationStatus());
    Set<String> cifsServers = new HashSet<String>();
    Set<String> cifsDomains = new HashSet<String>();
    if (from.getCifsServersMap() != null && !from.getCifsServersMap().isEmpty()) {
        Set<Entry<String, NasCifsServer>> nasCifsServers = from.getCifsServersMap().entrySet();
        for (Entry<String, NasCifsServer> nasCifsServer : nasCifsServers) {
            String serverDomain = nasCifsServer.getKey();
            NasCifsServer cifsServer = nasCifsServer.getValue();
            if (cifsServer.getDomain() != null) {
                serverDomain = serverDomain + " = " + cifsServer.getDomain();
                cifsDomains.add(cifsServer.getDomain());
            }
            cifsServers.add(serverDomain);
        }
        if (cifsServers != null && !cifsServers.isEmpty()) {
            to.setCifsServers(cifsServers);
            to.setStorageDomain(cifsDomains);
        }
    }
    for (String port : from.getStoragePorts()) {
        to.getStoragePorts().add(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, URI.create(port)));
    }
    to.setTaggedVirtualArrays(from.getTaggedVirtualArrays());
    to.setStorageDeviceURI(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageDeviceURI()));
    DecimalFormat df = new DecimalFormat("0.00");
    // Set the metrics!!!
    Double maxStorageCapacity = MetricsKeys.getDouble(MetricsKeys.maxStorageCapacity, from.getMetrics()) / GBsINKB;
    to.setMaxStorageCapacity(df.format(maxStorageCapacity));
    to.setMaxStorageObjects(MetricsKeys.getLong(MetricsKeys.maxStorageObjects, from.getMetrics()).toString());
    to.setStorageObjects(MetricsKeys.getLong(MetricsKeys.storageObjects, from.getMetrics()).toString());
    Double usedStorageCapacity = MetricsKeys.getDouble(MetricsKeys.usedStorageCapacity, from.getMetrics()) / GBsINKB;
    to.setUsedStorageCapacity(df.format(usedStorageCapacity));
    Double percentLoad = MetricsKeys.getDoubleOrNull(MetricsKeys.percentLoad, from.getMetrics());
    if (percentLoad != null) {
        to.setPercentLoad(df.format(percentLoad));
    }
    to.setIsOverloaded(MetricsKeys.getBoolean(MetricsKeys.overLoaded, from.getMetrics()));
    Double percentBusy = MetricsKeys.getDoubleOrNull(MetricsKeys.emaPercentBusy, from.getMetrics());
    if (percentBusy != null) {
        to.setAvgEmaPercentagebusy(df.format(percentBusy));
    }
    percentBusy = MetricsKeys.getDoubleOrNull(MetricsKeys.avgPortPercentBusy, from.getMetrics());
    if (percentBusy != null) {
        to.setAvgPercentagebusy(df.format(percentBusy));
    }
    return to;
}
Also used : Entry(java.util.Map.Entry) DecimalFormat(java.text.DecimalFormat) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) VirtualNASRestRep(com.emc.storageos.model.vnas.VirtualNASRestRep) HashSet(java.util.HashSet)

Example 3 with NasCifsServer

use of com.emc.storageos.db.client.model.NasCifsServer 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 4 with NasCifsServer

use of com.emc.storageos.db.client.model.NasCifsServer 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 5 with NasCifsServer

use of com.emc.storageos.db.client.model.NasCifsServer 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)

Aggregations

NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)6 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)4 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)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 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 VirtualNASRestRep (com.emc.storageos.model.vnas.VirtualNASRestRep)1 VNXDataMover (com.emc.storageos.vnx.xmlapi.VNXDataMover)1 VNXFileSshApi (com.emc.storageos.vnx.xmlapi.VNXFileSshApi)1 VNXVdm (com.emc.storageos.vnx.xmlapi.VNXVdm)1 VNXeCifsServer (com.emc.storageos.vnxe.models.VNXeCifsServer)1