Search in sources :

Example 1 with VNXeNfsServer

use of com.emc.storageos.vnxe.models.VNXeNfsServer 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 2 with VNXeNfsServer

use of com.emc.storageos.vnxe.models.VNXeNfsServer in project coprhd-controller by CoprHD.

the class VNXeCommunicationInterface 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>();
    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) {
            _logger.debug("Found a replication destination NasServer");
            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);
        if (results.iterator().hasNext()) {
            StorageHADomain tmpDomain = _dbClient.queryObject(StorageHADomain.class, results.iterator().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().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());
            haDomain.setFileSharingProtocols(protocols);
            newNasServers.add(haDomain);
        } else {
            haDomain.setFileSharingProtocols(protocols);
            existingNasServers.add(haDomain);
        }
        nasServerIdMap.put(nasServer.getId(), haDomain.getId());
    }
    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());
    }
    // return portGroups;
    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) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeCifsServer(com.emc.storageos.vnxe.models.VNXeCifsServer) 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) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 3 with VNXeNfsServer

use of com.emc.storageos.vnxe.models.VNXeNfsServer in project coprhd-controller by CoprHD.

the class NasServerListRequestTest method getTest.

@Test
public void getTest() {
    NfsServerListRequest req = new NfsServerListRequest(_client);
    List<VNXeNfsServer> list = req.get();
    for (VNXeNfsServer nfsServer : list) {
        String id = nfsServer.getId();
        System.out.println(id);
        List<VNXeBase> fileInterfaces = nfsServer.getFileInterfaces();
        System.out.println(fileInterfaces.size());
        for (VNXeBase finterface : fileInterfaces) {
            System.out.println(finterface.getId());
        }
    }
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeNfsServer(com.emc.storageos.vnxe.models.VNXeNfsServer) Test(org.junit.Test)

Aggregations

VNXeNfsServer (com.emc.storageos.vnxe.models.VNXeNfsServer)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 VNXeCifsServer (com.emc.storageos.vnxe.models.VNXeCifsServer)2 VNXeNasServer (com.emc.storageos.vnxe.models.VNXeNasServer)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)1 NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)1 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)1 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)1 URI (java.net.URI)1 Test (org.junit.Test)1