Search in sources :

Example 46 with StorageHADomain

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

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

the class VNXFileCommunicationInterface method getAllDataMovers.

private Map<String, StorageHADomain> getAllDataMovers(StorageSystem storageSystem) throws IOException {
    Map<String, StorageHADomain> allDataMovers = new ConcurrentHashMap<>();
    List<URI> storageAdapterURIs = _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStorageHADomainConstraint(storageSystem.getId()));
    List<StorageHADomain> dataMovers = _dbClient.queryObject(StorageHADomain.class, storageAdapterURIs);
    for (StorageHADomain dm : dataMovers) {
        if (!dm.getInactive() && !dm.getVirtual()) {
            _logger.info("found a Physical StorageHADomain for storage system  {} {}", storageSystem.getSerialNumber(), dm.getAdapterName());
            allDataMovers.put(dm.getAdapterName(), dm);
        }
    }
    return allDataMovers;
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) URI(java.net.URI)

Example 48 with StorageHADomain

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

the class VNXFileCommunicationInterface method getAllStoragePort.

private HashMap<String, List<StoragePort>> getAllStoragePort(StorageSystem storageSystem) throws IOException {
    HashMap<String, List<StoragePort>> ports = new HashMap<>();
    ArrayList<StoragePort> allVirtualStoragePorts = new ArrayList<>();
    ArrayList<StoragePort> allPhysicalStoragePorts = new ArrayList<>();
    List<URI> storagePortURIs = _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(storageSystem.getId()));
    List<StoragePort> storagePorts = _dbClient.queryObject(StoragePort.class, storagePortURIs);
    for (StoragePort sp : storagePorts) {
        URI moverOrVdmURI = sp.getStorageHADomain();
        if (!sp.getInactive() && moverOrVdmURI != null) {
            StorageHADomain moverOrVdm = _dbClient.queryObject(StorageHADomain.class, moverOrVdmURI);
            if (moverOrVdm != null) {
                if (moverOrVdm.getVirtual()) {
                    allVirtualStoragePorts.add(sp);
                } else {
                    allPhysicalStoragePorts.add(sp);
                }
            }
        }
    }
    // return ports;
    ports.put(VIRTUAL, allVirtualStoragePorts);
    ports.put(PHYSICAL, allPhysicalStoragePorts);
    return ports;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) 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) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI)

Example 49 with StorageHADomain

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

the class VNXFileCommunicationInterface method discoverAll.

public void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = null;
    StorageSystem storageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :  IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
        storageSystemId = accessProfile.getSystemId();
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        // Retrieve control station information.
        discoverControlStation(storageSystem);
        // Model number
        VNXFileSshApi sshDmApi = new VNXFileSshApi();
        sshDmApi.setConnParams(storageSystem.getIpAddress(), storageSystem.getUsername(), storageSystem.getPassword());
        String model = sshDmApi.getModelInfo();
        storageSystem.setModel(model);
        boolean connectionStatus = getVnxFileSMISConnection(accessProfile, storageSystem);
        if (connectionStatus) {
            storageSystem.setSmisConnectionStatus(ConnectionStatus.CONNECTED.toString());
        } else {
            storageSystem.setSmisConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
        }
        _dbClient.persistObject(storageSystem);
        if (!storageSystem.getReachableStatus()) {
            throw new VNXFileCollectionException("Failed to connect to " + storageSystem.getIpAddress());
        }
        // Get All Existing DataMovers
        Map<String, StorageHADomain> allExistingDataMovers = getAllDataMovers(storageSystem);
        for (StorageHADomain activeDM : allExistingDataMovers.values()) {
            _logger.info("Existing DataMovers in database {}", activeDM.getName());
        }
        // Discover port groups (data movers)
        StringSet fileSharingProtocols = new StringSet();
        Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, fileSharingProtocols);
        _logger.info("No of newly discovered groups {}", groups.get(NEW).size());
        _logger.info("No of existing discovered groups {}", groups.get(EXISTING).size());
        if (!groups.get(NEW).isEmpty()) {
            _dbClient.createObject(groups.get(NEW));
            for (StorageHADomain newDm : groups.get(NEW)) {
                _logger.info("New DM {} ", newDm.getAdapterName());
            }
        }
        if (!groups.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(groups.get(EXISTING));
            for (StorageHADomain existingDm : groups.get(EXISTING)) {
                _logger.info("Existing DM {} ", existingDm.getAdapterName());
            }
        }
        // Discover storage pools.
        List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
        List<StoragePool> allPools = new ArrayList<StoragePool>();
        Map<String, List<StoragePool>> pools = discoverStoragePools(storageSystem, poolsToMatchWithVpool, fileSharingProtocols);
        _logger.info("No of newly discovered pools {}", pools.get(NEW).size());
        _logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
        if (!pools.get(NEW).isEmpty()) {
            allPools.addAll(pools.get(NEW));
            _dbClient.createObject(pools.get(NEW));
        }
        if (!pools.get(EXISTING).isEmpty()) {
            allPools.addAll(pools.get(EXISTING));
            _dbClient.persistObject(pools.get(EXISTING));
        }
        List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystemId);
        if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
            poolsToMatchWithVpool.addAll(notVisiblePools);
        }
        // Keep a set of active data movers. Data movers in 'standby' state are not added to the
        // database since they cannot be used in this state.
        Set<StorageHADomain> activeDataMovers = new HashSet<StorageHADomain>();
        activeDataMovers.addAll(groups.get(NEW));
        activeDataMovers.addAll(groups.get(EXISTING));
        int i = 0;
        for (StorageHADomain activeDM : activeDataMovers) {
            _logger.info("DataMover {} : {}", i++, activeDM.getName());
        }
        // Discover ports (data mover interfaces) with the data movers in the active set.
        Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, activeDataMovers);
        _logger.info("No of newly discovered port {}", ports.get(NEW).size());
        _logger.info("No of existing discovered port {}", ports.get(EXISTING).size());
        if (!ports.get(NEW).isEmpty()) {
            _dbClient.createObject(ports.get(NEW));
        }
        if (!ports.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(ports.get(EXISTING));
        }
        // Discover VDM and Ports
        Map<String, StorageHADomain> allVdmsInDb = this.getAllVDMs(storageSystem);
        for (StorageHADomain activeVDM : allVdmsInDb.values()) {
            _logger.info("Existing DataMovers in the Database {}", activeVDM.getName());
        }
        Map<String, List<StorageHADomain>> vdms = discoverVdmPortGroups(storageSystem, activeDataMovers);
        _logger.info("No of newly Vdm discovered groups {}", vdms.get(NEW).size());
        _logger.info("No of existing vdm discovered groups {}", vdms.get(EXISTING).size());
        if (!vdms.get(NEW).isEmpty()) {
            _dbClient.createObject(vdms.get(NEW));
        }
        if (!vdms.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(vdms.get(EXISTING));
            for (StorageHADomain existingVdm : vdms.get(EXISTING)) {
                _logger.info("Existing VDM {}", existingVdm.getAdapterName());
            }
        }
        // Keep a set of active data movers. Data movers in 'standby' state are not added to the
        // database since they cannot be used in this state.
        Set<StorageHADomain> activeVDMs = new HashSet<StorageHADomain>();
        List<StorageHADomain> newVdms = vdms.get(NEW);
        for (StorageHADomain vdm : newVdms) {
            _logger.debug("New VDM : {}", vdm.getName());
            activeVDMs.add(vdm);
        }
        List<StorageHADomain> existingVdms = vdms.get(EXISTING);
        for (StorageHADomain vdm : existingVdms) {
            _logger.debug("Existing VDM : {}", vdm.getName());
            activeVDMs.add(vdm);
        }
        // Discover VDM Interfaces
        // Discover ports (data mover interfaces) with the data movers in the active set.
        Map<String, List<StoragePort>> vdmPorts = discoverVdmPorts(storageSystem, activeVDMs);
        _logger.info("No of newly discovered port {}", vdmPorts.get(NEW).size());
        _logger.info("No of existing discovered port {}", vdmPorts.get(EXISTING).size());
        if (!vdmPorts.get(NEW).isEmpty()) {
            _dbClient.createObject(vdmPorts.get(NEW));
            for (StoragePort port : vdmPorts.get(NEW)) {
                _logger.debug("New VDM Port : {}", port.getPortName());
            }
        }
        if (!vdmPorts.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(vdmPorts.get(EXISTING));
            for (StoragePort port : vdmPorts.get(EXISTING)) {
                _logger.info("EXISTING VDM Port : {}", port.getPortName());
            }
        }
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
        allExistingPorts.addAll(vdmPorts.get(EXISTING));
        List<StoragePort> allNewPorts = new ArrayList<StoragePort>(ports.get(NEW));
        allNewPorts.addAll(vdmPorts.get(NEW));
        List<StoragePort> allPorts = new ArrayList<StoragePort>(allExistingPorts);
        allPorts.addAll(allNewPorts);
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
        allExistingPorts.addAll(notVisiblePorts);
        StoragePortAssociationHelper.updatePortAssociations(allNewPorts, _dbClient);
        StoragePortAssociationHelper.updatePortAssociations(allExistingPorts, _dbClient);
        StringBuffer errorMessage = new StringBuffer();
        ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVpool(poolsToMatchWithVpool, _dbClient, _coordinator, storageSystemId, errorMessage);
        // Update the virtual nas association with virtual arrays!!!
        // For existing virtual nas ports!!
        StoragePortAssociationHelper.runUpdateVirtualNasAssociationsProcess(allExistingPorts, null, _dbClient);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemId.toString());
    } catch (Exception e) {
        if (storageSystem != null) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw new VNXFileCollectionException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) 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) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) IOException(java.io.IOException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 50 with StorageHADomain

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

StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)80 URI (java.net.URI)41 StoragePort (com.emc.storageos.db.client.model.StoragePort)35 ArrayList (java.util.ArrayList)33 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 HashMap (java.util.HashMap)22 List (java.util.List)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)11 URISyntaxException (java.net.URISyntaxException)11 LinkedList (java.util.LinkedList)10 IOException (java.io.IOException)9 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)8 HashSet (java.util.HashSet)8 Map (java.util.Map)7