Search in sources :

Example 16 with VirtualNAS

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

the class VNXFileCommunicationInterface method findvNasByNativeId.

/**
 * Find the Virtual NAS by Native ID for the specified VNX File storage array
 *
 * @param system storage system information including credentials.
 * @param Native id of the specified Virtual NAS
 * @return Virtual NAS Server
 */
private VirtualNAS findvNasByNativeId(StorageSystem system, String nativeId) {
    URIQueryResultList results = new URIQueryResultList();
    VirtualNAS vNas = null;
    // Set storage port details to vNas
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nativeId, NativeGUIDGenerator.VIRTUAL_NAS);
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualNASByNativeGuidConstraint(nasNativeGuid), results);
    Iterator<URI> iter = results.iterator();
    while (iter.hasNext()) {
        VirtualNAS tmpVnas = _dbClient.queryObject(VirtualNAS.class, iter.next());
        if (tmpVnas != null && !tmpVnas.getInactive()) {
            vNas = tmpVnas;
            _logger.info("found virtual NAS {}", tmpVnas.getNativeGuid() + ":" + tmpVnas.getNasName());
            break;
        }
    }
    return vNas;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 17 with VirtualNAS

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

the class VNXFileCommunicationInterface method discoverVdmPorts.

/**
 * Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
 *
 * @param system storage system information including credentials.
 * @return Map of New and Existing Storage Ports
 * @throws VNXFileCollectionException
 * @throws IOException
 */
private HashMap<String, List<StoragePort>> discoverVdmPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
    HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    _logger.info("Start storage port discovery for storage system {}", system.getId());
    HashMap<String, VNXDataMoverIntf> vdmIntMap = new HashMap();
    List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
    // Retrieve VDMs
    List<VNXVdm> vdms = getVdmPortGroups(system);
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXDataMoverIntf> vdmIntfs = getVdmPorts(system, vdms);
    for (VNXDataMoverIntf intf : vdmIntfs) {
        _logger.info("getVdmPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
        vdmIntMap.put(intf.getName(), intf);
    }
    _logger.info("Number VDM mover interfaces found: {}", vdmIntfs.size());
    for (VNXVdm vdm : vdms) {
        List<String> vNasStoragePorts = new ArrayList<String>();
        // Create the list of storage ports.
        for (String vdmIF : vdm.getInterfaces()) {
            VNXDataMoverIntf intf = vdmIntMap.get(vdmIF);
            StoragePort port = null;
            StorageHADomain matchingHADomain = getMatchingMoverByName(movers, vdm.getVdmName());
            // Check for valid data mover
            if (null == matchingHADomain) {
                continue;
            }
            // Check if storage port was already discovered
            String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
            port = findExistingPort(portNativeGuid);
            // If VDM interface was not previously discovered, add new storage port
            if (port == null) {
                port = new StoragePort();
                port.setId(URIUtil.createId(StoragePort.class));
                port.setLabel(portNativeGuid);
                port.setTransportType("IP");
                port.setNativeGuid(portNativeGuid);
                port.setStorageDevice(system.getId());
                port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                port.setPortName(intf.getName());
                port.setPortNetworkId(intf.getIpAddress());
                port.setPortGroup(vdm.getVdmId());
                port.setStorageHADomain(matchingHADomain.getId());
                _logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress(), intf.getDataMoverId(), vdm.getVdmId(), port.getPortName(), port.getPortGroup() });
                newStoragePorts.add(port);
            } else {
                port.setStorageHADomain(matchingHADomain.getId());
                port.setPortGroup(vdm.getVdmId());
                existingStoragePorts.add(port);
            }
            port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
            vNasStoragePorts.add(port.getId().toString());
        }
        // Set storage port details to vNas
        VirtualNAS vNas = findvNasByNativeId(system, vdm.getVdmId());
        if (vNas != null) {
            vNas.getStoragePorts().clear();
            vNas.getStoragePorts().addAll(vNasStoragePorts);
            modifiedServers.add(vNas);
        }
    }
    // Persist the changed nas servers!!!
    if (modifiedServers != null && !modifiedServers.isEmpty()) {
        _logger.info("Modified VirtualNAS servers size {}", modifiedServers.size());
        _dbClient.persistObject(modifiedServers);
    }
    _logger.info("Storage port discovery for storage system {} complete", system.getId());
    for (StoragePort newPort : newStoragePorts) {
        _logger.debug("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
    }
    for (StoragePort port : existingStoragePorts) {
        _logger.debug("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
    }
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) VNXDataMoverIntf(com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) 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)

Example 18 with VirtualNAS

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

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

the class VNXUnityCommunicationInterface method discoverFileStoragePorts.

/**
 * Discover file interfaces for specified VNXe Storage Array
 *
 * @param system
 *            storage system.
 * @param client
 *            VNXe service client
 * @param nasServerIdSet
 *            all valid NAS Server ids
 * @return Map of New and Existing Storage Ports
 * @throws VNXeException
 */
private HashMap<String, List<StoragePort>> discoverFileStoragePorts(StorageSystem system, VNXeApiClient client, Map<String, URI> nasServerIdMap) throws VNXeException {
    HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
    _logger.info("Start storage port discovery for storage system {}", system.getId());
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXeFileInterface> interfaces = client.getFileInterfaces();
    if (interfaces == null || interfaces.isEmpty()) {
        _logger.info("No file interfaces found for the system: {} ", system.getId());
        return storagePorts;
    }
    _logger.info("Number file interfaces found: {}", interfaces.size());
    // Create the list of storage ports.
    for (VNXeFileInterface intf : interfaces) {
        StoragePort port = null;
        // Check for valid nasServer
        VNXeBase nasServer = intf.getNasServer();
        if (nasServer == null) {
            continue;
        }
        String nasServerId = nasServer.getId();
        URI haDomainUri = nasServerIdMap.get(nasServerId);
        if (haDomainUri == null) {
            continue;
        }
        // Check if storage port was already discovered
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
        URIQueryResultList results = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
        Iterator<URI> it = results.iterator();
        if (it.hasNext()) {
            _logger.info("cross verifying for duplicate port");
            StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, it.next());
            _logger.info(String.format("StorageDevice found for port %s - Actual StorageDevice %s : PortGroup found for port %s - Actual PortGroup %s", tmpPort.getStorageDevice(), system.getId(), tmpPort.getPortGroup(), nasServerId));
            if (tmpPort.getStorageDevice().equals(system.getId()) && tmpPort.getPortGroup().equals(nasServerId)) {
                port = tmpPort;
                _logger.info("found duplicate dm intf {}", intf.getName());
            }
        }
        // storage port
        if (port == null) {
            port = new StoragePort();
            port.setId(URIUtil.createId(StoragePort.class));
            port.setLabel(portNativeGuid);
            port.setTransportType("IP");
            port.setNativeGuid(portNativeGuid);
            port.setStorageDevice(system.getId());
            port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
            port.setPortName(intf.getName());
            port.setPortNetworkId(intf.getIpAddress());
            port.setPortGroup(nasServerId);
            port.setStorageHADomain(haDomainUri);
            _logger.info("Creating new storage port using NativeGuid : {}, IP : {}", portNativeGuid, intf.getIpAddress());
            newStoragePorts.add(port);
        } else {
            existingStoragePorts.add(port);
        }
        port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
        port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        // Associate Storage Port to Virtual NAS
        VirtualNAS vNas = findvNasByNativeId(system, nasServerId);
        if (vNas != null) {
            if (vNas.getStoragePorts() != null && !vNas.getStoragePorts().isEmpty()) {
                if (vNas.getStoragePorts().contains(port.getId())) {
                    vNas.getStoragePorts().remove(port.getId());
                }
            }
            vNas.getStoragePorts().add(port.getId().toString());
            modifiedServers.add(vNas);
            _logger.info("VirtualNAS : {} : port : {} got modified", vNas.getId(), port.getPortName());
        }
    }
    // Persist the modified virtual nas servers
    if (modifiedServers != null && !modifiedServers.isEmpty()) {
        _logger.info("Modified VirtualNAS servers size {}", modifiedServers.size());
        _dbClient.updateObject(modifiedServers);
    }
    _logger.info("Storage port discovery for storage system {} complete", system.getId());
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 20 with VirtualNAS

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

the class VNXUnityCommunicationInterface method findvNasByNativeId.

/**
 * Find the Virtual NAS by Native ID for the specified VNX unity storage
 * array
 *
 * @param system
 *            storage system information including credentials.
 * @param Native
 *            id of the specified Virtual NAS
 * @return Virtual NAS Server
 */
private VirtualNAS findvNasByNativeId(StorageSystem system, String nativeId) {
    URIQueryResultList results = new URIQueryResultList();
    VirtualNAS vNas = null;
    // Set storage port details to vNas
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nativeId, NativeGUIDGenerator.VIRTUAL_NAS);
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualNASByNativeGuidConstraint(nasNativeGuid), results);
    Iterator<URI> iter = results.iterator();
    while (iter.hasNext()) {
        VirtualNAS tmpVnas = _dbClient.queryObject(VirtualNAS.class, iter.next());
        if (tmpVnas != null && !tmpVnas.getInactive()) {
            vNas = tmpVnas;
            _logger.info("found virtual NAS {}", tmpVnas.getNativeGuid() + ":" + tmpVnas.getNasName());
            break;
        }
    }
    return vNas;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)54 URI (java.net.URI)26 ArrayList (java.util.ArrayList)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)16 StringSet (com.emc.storageos.db.client.model.StringSet)15 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 List (java.util.List)9 StoragePort (com.emc.storageos.db.client.model.StoragePort)8 URISyntaxException (java.net.URISyntaxException)8 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)7 Project (com.emc.storageos.db.client.model.Project)6 StringMap (com.emc.storageos.db.client.model.StringMap)6 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)6 ControllerException (com.emc.storageos.volumecontroller.ControllerException)6