Search in sources :

Example 11 with PhysicalNAS

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

the class VNXFileCommunicationInterface method createVirtualNas.

/**
 * Create Virtual NAS for the specified VNX File storage array
 *
 * @param system storage system information including credentials.
 * @param discovered VDM of the specified VNX File storage array
 * @return Virtual NAS Server
 * @throws VNXFileCollectionException
 */
private VirtualNAS createVirtualNas(StorageSystem system, VNXVdm vdm) throws VNXFileCollectionException {
    VirtualNAS vNas = new VirtualNAS();
    vNas.setNasName(vdm.getVdmName());
    vNas.setStorageDeviceURI(system.getId());
    vNas.setNativeId(vdm.getVdmId());
    vNas.setNasState(vdm.getState());
    vNas.setId(URIUtil.createId(VirtualNAS.class));
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vdm.getVdmId(), NativeGUIDGenerator.VIRTUAL_NAS);
    vNas.setNativeGuid(nasNativeGuid);
    PhysicalNAS parentNas = findPhysicalNasByNativeId(system, vdm.getMoverId());
    if (parentNas != null) {
        vNas.setParentNasUri(parentNas.getId());
        StringMap dbMetrics = vNas.getMetrics();
        _logger.info("new Virtual NAS created with guid {} ", vNas.getNativeGuid());
        // Set the Limit Metric keys!!
        Long MaxObjects = 2048L;
        Long MaxCapacity = 200L * TBsINKB;
        String modelStr = system.getModel();
        if (modelStr.startsWith("VNX")) {
            if (Long.parseLong(modelStr.substring(3)) > 5300) {
                MaxCapacity = 256L * TBsINKB;
            }
        }
        dbMetrics.put(MetricsKeys.maxStorageCapacity.name(), String.valueOf(MaxCapacity));
        dbMetrics.put(MetricsKeys.maxStorageObjects.name(), String.valueOf(MaxObjects));
        vNas.setMetrics(dbMetrics);
    }
    return vNas;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 12 with PhysicalNAS

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

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

the class VNXFileCommunicationInterface method getNASUri.

/**
 * get the nas or vnas uri
 *
 * @param storageHADomain
 * @param storageSystem
 * @return
 */
private URI getNASUri(StorageHADomain storageHADomain, StorageSystem storageSystem) {
    URI moverURI = null;
    if (storageHADomain.getVirtual() == true) {
        VirtualNAS virtualNAS = findvNasByNativeId(storageSystem, storageHADomain.getName());
        moverURI = virtualNAS.getId();
    } else {
        PhysicalNAS physicalNAS = findPhysicalNasByNativeId(storageSystem, storageHADomain.getName());
        moverURI = physicalNAS.getId();
    }
    return moverURI;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) URI(java.net.URI) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 14 with PhysicalNAS

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

the class VNXFileCommunicationInterface method createPhysicalNas.

/**
 * Create Physical NAS for the specified VNX File storage array
 *
 * @param system storage system information including credentials.
 * @param discovered DM of the specified VNX File storage array
 * @return Physical NAS Server
 * @throws VNXFileCollectionException
 */
private PhysicalNAS createPhysicalNas(StorageSystem system, VNXDataMover dm) throws VNXFileCollectionException {
    PhysicalNAS phyNas = new PhysicalNAS();
    if (phyNas != null) {
        phyNas.setNasName(dm.getName());
        phyNas.setStorageDeviceURI(system.getId());
        phyNas.setNativeId(String.valueOf(dm.getId()));
        phyNas.setNasState(dm.getRole());
        phyNas.setId(URIUtil.createId(PhysicalNAS.class));
        // Set storage port details to vNas
        String physicalNasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, String.valueOf(dm.getId()), NativeGUIDGenerator.PHYSICAL_NAS);
        phyNas.setNativeGuid(physicalNasNativeGuid);
        _logger.info("Physical NAS created with guid {} ", phyNas.getNativeGuid());
        StringMap dbMetrics = phyNas.getMetrics();
        // Set the Limit Metric keys!!
        Long MaxObjects = 2048L;
        Long MaxCapacity = 200L * TBsINKB;
        String modelStr = system.getModel();
        if (modelStr.startsWith("VNX")) {
            if (Long.parseLong(modelStr.substring(3)) > 5300) {
                MaxCapacity = 256L * TBsINKB;
            }
        }
        dbMetrics.put(MetricsKeys.maxStorageCapacity.name(), String.valueOf(MaxCapacity));
        dbMetrics.put(MetricsKeys.maxStorageObjects.name(), String.valueOf(MaxObjects));
        phyNas.setMetrics(dbMetrics);
    }
    return phyNas;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 15 with PhysicalNAS

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

Aggregations

PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)24 URI (java.net.URI)14 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)9 ArrayList (java.util.ArrayList)6 NASServer (com.emc.storageos.db.client.model.NASServer)5 StringMap (com.emc.storageos.db.client.model.StringMap)5 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 List (java.util.List)4 NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)3 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)3 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)2 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)2 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)2