Search in sources :

Example 1 with PortStatMembers

use of com.emc.storageos.hp3par.command.PortStatMembers in project coprhd-controller by CoprHD.

the class HP3PARUtil method discoverStoragePortsById.

/**
 * Get storage port information
 * @throws Exception
 */
public void discoverStoragePortsById(String storageSystemId, List<StoragePort> storagePorts, Registry driverRegistery) throws Exception {
    // For this 3PAR system
    try {
        // get Api client
        HP3PARApi hp3parApi = getHP3PARDeviceFromNativeId(storageSystemId, driverRegistery);
        // get storage port details
        PortCommandResult portResult = hp3parApi.getPortDetails();
        PortStatisticsCommandResult portStatResult = hp3parApi.getPortStatisticsDetail();
        // for each ViPR Storage port = 3PAR host port
        for (PortMembers currMember : portResult.getMembers()) {
            StoragePort port = new StoragePort();
            // Consider online target ports
            if (currMember.getMode() != HP3PARConstants.MODE_TARGET || currMember.getLinkState() != HP3PARConstants.LINK_READY) {
                continue;
            }
            if (currMember.getLabel() == null) {
                String label = String.format("port:%s:%s:%s", currMember.getPortPos().getNode(), currMember.getPortPos().getSlot(), currMember.getPortPos().getCardPort());
                port.setPortName(label);
            } else {
                port.setPortName(currMember.getLabel());
            }
            port.setStorageSystemId(storageSystemId);
            switch(currMember.getProtocol()) {
                case 1:
                    port.setTransportType(TransportType.FC);
                    break;
                case 3:
                    port.setTransportType(TransportType.Ethernet);
                    break;
                case 2:
                    port.setTransportType(TransportType.IP);
                    break;
                default:
                    _log.warn("3PARDriver: discoverStoragePorts Invalid port {}", port.getPortName());
                    break;
            }
            for (PortStatMembers currStat : portStatResult.getMembers()) {
                if (currMember.getPortPos().getNode() == currStat.getNode() && currMember.getPortPos().getSlot() == currStat.getSlot() && currMember.getPortPos().getCardPort() == currStat.getCardPort()) {
                    port.setPortSpeed(currStat.getSpeed() * HP3PARConstants.MEGA_BYTE);
                }
            }
            // grouping with cluster node and slot
            port.setPortGroup(currMember.getPortPos().getNode().toString());
            port.setPortSubGroup(currMember.getPortPos().getSlot().toString());
            // set specific properties based on protocol
            if (port.getTransportType().equals(TransportType.FC.toString())) {
                port.setPortNetworkId(SanUtils.formatWWN(currMember.getPortWWN()));
                // rest of the values
                port.setEndPointID(port.getPortNetworkId());
                port.setTcpPortNumber((long) 0);
            } else if (port.getTransportType().equals(TransportType.IP.toString())) {
                port.setIpAddress(currMember.getIPAddr());
                port.setPortNetworkId(currMember.getiSCSINmae());
                port.setTcpPortNumber(currMember.getiSCSIPortInfo().getiSNSPort());
                // rest of the values
                port.setEndPointID(port.getPortNetworkId());
            }
            port.setAvgBandwidth(port.getPortSpeed());
            port.setPortHAZone(String.format("Group-%s", currMember.getPortPos().getNode()));
            String id = String.format("%s:%s:%s", currMember.getPortPos().getNode(), currMember.getPortPos().getSlot(), currMember.getPortPos().getCardPort());
            // Storage object properties
            port.setNativeId(id);
            port.setDeviceLabel(port.getPortName());
            port.setDisplayName(port.getPortName());
            port.setOperationalStatus(StoragePort.OperationalStatus.OK);
            _log.info("3PARDriver: added storage port {}, native id {}", port.getPortName(), port.getNativeId());
            storagePorts.add(port);
        }
    // for each storage pool
    } catch (Exception e) {
        throw e;
    }
}
Also used : PortMembers(com.emc.storageos.hp3par.command.PortMembers) PortCommandResult(com.emc.storageos.hp3par.command.PortCommandResult) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) PortStatMembers(com.emc.storageos.hp3par.command.PortStatMembers) HP3PARApi(com.emc.storageos.hp3par.impl.HP3PARApi) PortStatisticsCommandResult(com.emc.storageos.hp3par.command.PortStatisticsCommandResult) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException)

Aggregations

PortCommandResult (com.emc.storageos.hp3par.command.PortCommandResult)1 PortMembers (com.emc.storageos.hp3par.command.PortMembers)1 PortStatMembers (com.emc.storageos.hp3par.command.PortStatMembers)1 PortStatisticsCommandResult (com.emc.storageos.hp3par.command.PortStatisticsCommandResult)1 HP3PARApi (com.emc.storageos.hp3par.impl.HP3PARApi)1 HP3PARException (com.emc.storageos.hp3par.impl.HP3PARException)1 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)1