Search in sources :

Example 1 with VNXeFileInterface

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

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

the class VNXeCommunicationInterface 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>();
    _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);
        if (results.iterator().hasNext()) {
            _logger.info("cross verifying for duplicate port");
            StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().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());
    }
    _logger.info("Storage port discovery for storage system {} complete", system.getId());
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 3 with VNXeFileInterface

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

the class VNXUnityFileStorageDeviceTest method testDiscoverUnityStoragePorts.

/**
 * Tests Unity storage port discovery
 *
 * @throws Exception
 */
@Test
public void testDiscoverUnityStoragePorts() {
    try {
        VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
        List<VNXeFileInterface> unityStoragePorts = apiclient.getFileInterfaces();
        Assert.assertTrue("Unity Storage Port discovery failed " + unityStoragePorts.size(), true);
    } catch (VNXeException uex) {
        System.out.println("Unity Storage port discovery failed: " + uex.getCause());
    }
}
Also used : VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) Test(org.junit.Test)

Example 4 with VNXeFileInterface

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

the class VNXeUnManagedObjectDiscoverer method getStoragePortPool.

private StoragePort getStoragePortPool(StorageSystem storageSystem, DbClient dbClient, VNXeApiClient apiClient, VNXeFileSystem fs) throws IOException {
    StoragePort storagePort = null;
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXeFileInterface> interfaces = apiClient.getFileInterfaces();
    VNXeBase fsNasserver = fs.getNasServer();
    if (interfaces == null || interfaces.isEmpty()) {
        log.info("No file interfaces found for the system: {} ", storageSystem.getId());
        return storagePort;
    }
    log.info("Number file interfaces found: {}", interfaces.size());
    // Create the list of storage ports.
    for (VNXeFileInterface intf : interfaces) {
        VNXeBase nasServer = intf.getNasServer();
        if (nasServer == null || (!fsNasserver.getId().equalsIgnoreCase(nasServer.getId()))) {
            continue;
        }
        // Check if storage port was already discovered
        URIQueryResultList results = new URIQueryResultList();
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
        Iterator<URI> storagePortIter = results.iterator();
        if (storagePortIter.hasNext()) {
            URI storagePortURI = storagePortIter.next();
            storagePort = dbClient.queryObject(StoragePort.class, storagePortURI);
            if (storagePort.getStorageDevice().equals(storageSystem.getId()) && storagePort.getPortGroup().equals(nasServer.getId())) {
                log.debug("found a port for storage system  {} {}", storageSystem.getSerialNumber(), storagePort);
                break;
            }
        }
    }
    return storagePort;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 5 with VNXeFileInterface

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

the class VNXUnityUnManagedObjectDiscoverer method getStoragePortPool.

private StoragePort getStoragePortPool(StorageSystem storageSystem, DbClient dbClient, VNXeApiClient apiClient, VNXeFileSystem fs) throws IOException {
    StoragePort storagePort = null;
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXeFileInterface> interfaces = apiClient.getFileInterfaces();
    VNXeBase fsNasserver = fs.getNasServer();
    if (interfaces == null || interfaces.isEmpty()) {
        log.info("No file interfaces found for the system: {} ", storageSystem.getId());
        return storagePort;
    }
    log.info("Number file interfaces found: {}", interfaces.size());
    // Create the list of storage ports.
    for (VNXeFileInterface intf : interfaces) {
        VNXeBase nasServer = intf.getNasServer();
        if (nasServer == null || (!fsNasserver.getId().equalsIgnoreCase(nasServer.getId()))) {
            continue;
        }
        // Check if storage port was already discovered
        URIQueryResultList results = new URIQueryResultList();
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
        Iterator<URI> storagePortIter = results.iterator();
        if (storagePortIter.hasNext()) {
            URI storagePortURI = storagePortIter.next();
            storagePort = dbClient.queryObject(StoragePort.class, storagePortURI);
            if (storagePort.getStorageDevice().equals(storageSystem.getId()) && storagePort.getPortGroup().equals(nasServer.getId())) {
                log.debug("found a port for storage system  {} {}", storageSystem.getSerialNumber(), storagePort);
                break;
            }
        }
    }
    return storagePort;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

VNXeFileInterface (com.emc.storageos.vnxe.models.VNXeFileInterface)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)4 URI (java.net.URI)4 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)1 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)1 VNXeException (com.emc.storageos.vnxe.VNXeException)1 Test (org.junit.Test)1