Search in sources :

Example 1 with VNXeNasServer

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

the class VNXUnityCommunicationInterface method computeStaticLoadMetrics.

/**
 * Compute static load metrics.
 *
 * @param accessProfile
 * @return
 */
private void computeStaticLoadMetrics(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = accessProfile.getSystemId();
    StorageSystem storageSystem = null;
    try {
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        _logger.info("started computeStaticLoadMetrics for storagesystem: {}", storageSystem.getLabel());
        VNXeApiClient client = getVnxUnityClient(accessProfile);
        List<VNXeNasServer> nasServers = client.getNasServers();
        for (VNXeNasServer nasServer : nasServers) {
            if ((nasServer.getMode() == VNXeNasServer.NasServerModeEnum.DESTINATION) || nasServer.getIsReplicationDestination()) {
                _logger.debug("Found a replication destination NasServer");
                continue;
            }
            if (nasServer.getIsSystem()) {
                // skip system nasServer
                continue;
            }
            VirtualNAS virtualNAS = findvNasByNativeId(storageSystem, nasServer.getId());
            if (virtualNAS != null) {
                _logger.info("Process db metrics for nas server : {}", nasServer.getName());
                StringMap dbMetrics = virtualNAS.getMetrics();
                if (dbMetrics == null) {
                    dbMetrics = new StringMap();
                }
                // process db metrics
                StringMap tmpDbMetrics = populateDbMetrics(nasServer, client);
                dbMetrics.putAll(tmpDbMetrics);
                // set dbMetrics in db
                virtualNAS.setMetrics(dbMetrics);
                _dbClient.updateObject(virtualNAS);
            }
        }
    } catch (Exception e) {
        _logger.error("CollectStatisticsInformation failed. Storage system: {}", storageSystemId, e);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) URI(java.net.URI) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem)

Example 2 with VNXeNasServer

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

the class VNXUnityFileStorageDeviceTest method getStorageHADomain.

public List<StorageHADomain> getStorageHADomain() {
    VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
    List<VNXeNasServer> nasServers = apiclient.getNasServers();
    List<StorageHADomain> haDomains = new ArrayList<StorageHADomain>();
    List<String> proto = new ArrayList<String>();
    proto.add("CIFS");
    StringSet protocols = new StringSet(proto);
    for (VNXeNasServer nasServer : nasServers) {
        StorageHADomain haDomain = new StorageHADomain();
        haDomain.setId(URIUtil.createId(StorageHADomain.class));
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(_device, nasServer.getName(), NativeGUIDGenerator.ADAPTER);
        haDomain.setNativeGuid(adapterNativeGuid);
        haDomain.setStorageDeviceURI(_device.getId());
        haDomain.setAdapterName(nasServer.getName());
        haDomain.setName(nasServer.getName());
        haDomain.setSerialNumber(nasServer.getId());
        haDomain.setFileSharingProtocols(protocols);
        haDomain.setVirtual(true);
        haDomains.add(haDomain);
    }
    return haDomains;
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 3 with VNXeNasServer

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

the class NasServerRequestTest method getTest.

@Test
public void getTest() {
    NasServerRequest req = new NasServerRequest(_client, "system_nas_0");
    VNXeNasServer nasServer = req.get();
    String name = nasServer.getName();
    System.out.println(name);
    String spId = nasServer.getCurrentSP().getId();
    System.out.println(spId);
    System.out.println(nasServer.getMode());
}
Also used : VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) Test(org.junit.Test)

Example 4 with VNXeNasServer

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

use of com.emc.storageos.vnxe.models.VNXeNasServer 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)

Aggregations

VNXeNasServer (com.emc.storageos.vnxe.models.VNXeNasServer)5 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 ArrayList (java.util.ArrayList)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)2 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)2 VNXeCifsServer (com.emc.storageos.vnxe.models.VNXeCifsServer)2 VNXeNfsServer (com.emc.storageos.vnxe.models.VNXeNfsServer)2 URI (java.net.URI)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 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 VNXeException (com.emc.storageos.vnxe.VNXeException)1 VNXeStorageSystem (com.emc.storageos.vnxe.models.VNXeStorageSystem)1