Search in sources :

Example 1 with VNXeFCPort

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

the class VNXeCommunicationInterface method discoverFcPorts.

/**
 * Discover fcPorts
 *
 * @param system
 * @param client
 * @param spIdMap
 *            storage processors VNXeId and ViPR URI map
 * @return
 * @throws VNXeException
 */
private HashMap<String, List<StoragePort>> discoverFcPorts(StorageSystem system, VNXeApiClient client, Map<String, URI> spIdMap) 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 FC storage port discovery for storage system {}", system.getId());
    // Retrieve the list of iscsi ports
    List<VNXeFCPort> ports = client.getAllFcPorts();
    if (ports == null || ports.isEmpty()) {
        _logger.info("No FC ports found for the system: {} ", system.getId());
        storagePorts.put(NEW, newStoragePorts);
        storagePorts.put(EXISTING, existingStoragePorts);
        return storagePorts;
    }
    // Create the list of storage ports.
    for (VNXeFCPort fcPort : ports) {
        StoragePort port = null;
        VNXeBase spId = fcPort.getStorageProcessorId();
        if (spId == null) {
            _logger.info("No storage processor info for the fcPort: {}", fcPort.getId());
            continue;
        }
        String spIdStr = spId.getId();
        URI haDomainUri = spIdMap.get(spIdStr);
        if (haDomainUri == null) {
            _logger.info("The sp {} has not been discovered.", spIdStr);
            continue;
        }
        // Check if storage port was already discovered
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, fcPort.getWwn(), NativeGUIDGenerator.PORT);
        URIQueryResultList results = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
        if (results.iterator().hasNext()) {
            _logger.debug("cross verifying for duplicate port");
            StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
            _logger.info(String.format("Actual StorageDevice %s : PortGroup found for port %s - Actual PortGroup %s", system.getId(), tmpPort.getPortNetworkId(), tmpPort.getPortGroup()));
            if (tmpPort.getStorageDevice().equals(system.getId()) && tmpPort.getPortGroup().equals(spIdStr)) {
                port = tmpPort;
                _logger.debug("found duplicate fc port {}", fcPort.getWwn());
            }
        }
        // port
        if (port == null) {
            port = new StoragePort();
            port.setId(URIUtil.createId(StoragePort.class));
            port.setLabel(portNativeGuid);
            port.setTransportType("FC");
            port.setNativeGuid(portNativeGuid);
            port.setStorageDevice(system.getId());
            port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
            port.setPortName(fcPort.getId());
            port.setPortNetworkId(fcPort.getPortWwn());
            port.setPortGroup(spIdStr);
            port.setStorageHADomain(haDomainUri);
            List<Integer> opstatus = fcPort.getOperationalStatus();
            Integer ok = 2;
            if (opstatus.contains(ok)) {
                port.setOperationalStatus(StoragePort.OperationalStatus.OK.name());
            } else {
                port.setOperationalStatus(StoragePort.OperationalStatus.NOT_OK.name());
            }
            _logger.info("Creating new storage port using NativeGuid : {}, WWN:", portNativeGuid, fcPort.getWwn());
            newStoragePorts.add(port);
        } else {
            existingStoragePorts.add(port);
        }
        port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
        port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
    }
    _logger.info("FC port discovery for storage system {} complete", system.getId());
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : 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) VNXeFCPort(com.emc.storageos.vnxe.models.VNXeFCPort) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with VNXeFCPort

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

the class VNXeApiClient method getAllFcPorts.

public List<VNXeFCPort> getAllFcPorts() {
    FcPortRequests req = new FcPortRequests(_khClient);
    List<VNXeFCPort> fcPorts = new ArrayList<VNXeFCPort>();
    try {
        fcPorts = req.get();
    } catch (VNXeException e) {
        _logger.info("Exception caught while getting all fcPorts", e);
    }
    return fcPorts;
}
Also used : ArrayList(java.util.ArrayList) FcPortRequests(com.emc.storageos.vnxe.requests.FcPortRequests) VNXeFCPort(com.emc.storageos.vnxe.models.VNXeFCPort)

Example 3 with VNXeFCPort

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

the class ApiClientTest method getFCPort.

// @Test
public void getFCPort() {
    List<VNXeFCPort> ports = apiClient.getAllFcPorts();
    System.out.println(ports.size());
    for (VNXeFCPort port : ports) {
        System.out.println(port.getName() + " " + port.getPortWwn());
        System.out.println(port.getPortWwn());
    }
}
Also used : VNXeFCPort(com.emc.storageos.vnxe.models.VNXeFCPort)

Example 4 with VNXeFCPort

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

the class VNXUnityCommunicationInterface method discoverFcPorts.

/**
 * Discover fcPorts
 *
 * @param system
 * @param client
 * @param spIdMap
 *            storage processors VNXeId and ViPR URI map
 * @return
 * @throws VNXeException
 */
private HashMap<String, List<StoragePort>> discoverFcPorts(StorageSystem system, VNXeApiClient client, Map<String, URI> spIdMap) 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 FC storage port discovery for storage system {}", system.getId());
    // Retrieve the list of iscsi ports
    List<VNXeFCPort> ports = client.getAllFcPorts();
    if (ports == null || ports.isEmpty()) {
        _logger.info("No FC ports found for the system: {} ", system.getId());
        storagePorts.put(NEW, newStoragePorts);
        storagePorts.put(EXISTING, existingStoragePorts);
        return storagePorts;
    }
    // Create the list of storage ports.
    for (VNXeFCPort fcPort : ports) {
        StoragePort port = null;
        VNXeBase spId = fcPort.getStorageProcessor();
        if (spId == null) {
            _logger.info("No storage processor info for the fcPort: {}", fcPort.getId());
            continue;
        }
        String spIdStr = spId.getId();
        URI haDomainUri = spIdMap.get(spIdStr);
        if (haDomainUri == null) {
            _logger.info("The sp {} has not been discovered.", spIdStr);
            continue;
        }
        // Check if storage port was already discovered
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, fcPort.getWwn(), NativeGUIDGenerator.PORT);
        URIQueryResultList results = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
        Iterator<URI> it = results.iterator();
        if (it.hasNext()) {
            _logger.debug("cross verifying for duplicate port");
            StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, it.next());
            _logger.info(String.format("Actual StorageDevice %s : PortGroup found for port %s - Actual PortGroup %s", system.getId(), tmpPort.getPortNetworkId(), tmpPort.getPortGroup()));
            if (tmpPort.getStorageDevice().equals(system.getId()) && tmpPort.getPortGroup().equals(spIdStr)) {
                port = tmpPort;
                _logger.debug("found duplicate fc port {}", fcPort.getWwn());
            }
        }
        // port
        if (port == null) {
            port = new StoragePort();
            port.setId(URIUtil.createId(StoragePort.class));
            port.setLabel(portNativeGuid);
            port.setTransportType("FC");
            port.setNativeGuid(portNativeGuid);
            port.setStorageDevice(system.getId());
            port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
            port.setPortName(fcPort.getId());
            port.setPortNetworkId(fcPort.getPortWwn());
            port.setPortGroup(spIdStr);
            port.setStorageHADomain(haDomainUri);
            _logger.info("Creating new storage port using NativeGuid : {}, WWN:", portNativeGuid, fcPort.getWwn());
            newStoragePorts.add(port);
        } else {
            existingStoragePorts.add(port);
        }
        Health portHealth = fcPort.getHealth();
        if (portHealth != null) {
            int healthValue = portHealth.getValue();
            if (healthValue == Health.HealthEnum.OK.getValue()) {
                port.setOperationalStatus(StoragePort.OperationalStatus.OK.name());
            } else {
                port.setOperationalStatus(StoragePort.OperationalStatus.NOT_OK.name());
            }
        }
        port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
        port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
    }
    _logger.info("FC port discovery for storage system {} complete", system.getId());
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : HashMap(java.util.HashMap) Health(com.emc.storageos.vnxe.models.Health) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) VNXeFCPort(com.emc.storageos.vnxe.models.VNXeFCPort) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

VNXeFCPort (com.emc.storageos.vnxe.models.VNXeFCPort)4 ArrayList (java.util.ArrayList)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 List (java.util.List)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 Health (com.emc.storageos.vnxe.models.Health)1 FcPortRequests (com.emc.storageos.vnxe.requests.FcPortRequests)1