Search in sources :

Example 1 with ScConfiguration

use of com.emc.storageos.driver.dellsc.scapi.objects.ScConfiguration in project coprhd-controller by CoprHD.

the class DellSCDiscovery method getPortList.

/**
 * Gets the ScControllerPorts for a system.
 *
 * @param api The API connection.
 * @param ssn The system serial number.
 * @return The ports.
 */
private Map<String, List<ScControllerPort>> getPortList(StorageCenterAPI api, String ssn) {
    Map<String, List<ScControllerPort>> ports = new HashMap<>();
    try {
        ScConfiguration scConfig = api.getScConfig(ssn);
        ScFaultDomain[] faultDomains = api.getFaultDomains(ssn);
        for (ScFaultDomain fd : faultDomains) {
            // See what kind of fault domain this is
            boolean virtualMode;
            if (ScControllerPort.FC_TRANSPORT_TYPE.equals(fd.transportType)) {
                virtualMode = "VirtualPort".equals(scConfig.fibreChannelTransportMode);
            } else if (ScControllerPort.ISCSI_TRANSPORT_TYPE.equals(fd.transportType)) {
                virtualMode = "VirtualPort".equals(scConfig.iscsiTransportMode);
            } else {
                // Not a currently supported transport type
                continue;
            }
            // Now get the actual ports
            if (!ports.containsKey(fd.name)) {
                ports.put(fd.name, new ArrayList<>());
            }
            ScControllerPort[] fdPorts = api.getFaultDomainPorts(fd.instanceId, virtualMode);
            for (ScControllerPort fdPort : fdPorts) {
                // See if we need to inherit the IP settings from the fault domain
                if (EMPTY_IPADDR.equals(fdPort.iscsiSubnetMask)) {
                    fdPort.iscsiSubnetMask = fd.subnetMask;
                }
                if (EMPTY_IPADDR.equals(fdPort.iscsiIpAddress)) {
                    fdPort.iscsiIpAddress = fd.targetIpv4Address;
                }
                ports.get(fd.name).add(fdPort);
            }
        }
    } catch (Exception e) {
        LOG.error(String.format("Error getting system controller ports: %s", e));
    }
    return ports;
}
Also used : ScControllerPort(com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ScFaultDomain(com.emc.storageos.driver.dellsc.scapi.objects.ScFaultDomain) ScConfiguration(com.emc.storageos.driver.dellsc.scapi.objects.ScConfiguration) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Aggregations

DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)1 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)1 ScConfiguration (com.emc.storageos.driver.dellsc.scapi.objects.ScConfiguration)1 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)1 ScFaultDomain (com.emc.storageos.driver.dellsc.scapi.objects.ScFaultDomain)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1