Search in sources :

Example 6 with PortInfo

use of org.openkilda.model.PortInfo in project open-kilda by telstra.

the class PortConverter method setPortInfo.

/**
 * Sets the port info.
 *
 * @param key the key
 * @param portDetail the port detail
 * @return the port info
 */
private static PortInfo setPortInfo(final String key, final PortDetail portDetail) {
    PortInfo portInfo = new PortInfo();
    StringBuilder currentFeatures = new StringBuilder();
    if (portDetail.getCurrentFeatures() != null && portDetail.getCurrentFeatures().size() > 0) {
        for (int i = 0; i < portDetail.getCurrentFeatures().size(); i++) {
            if (currentFeatures.length() == 0) {
                currentFeatures = currentFeatures.append(portDetail.getCurrentFeatures().get(i));
            } else {
                currentFeatures = currentFeatures.append("," + portDetail.getCurrentFeatures().get(i));
            }
        }
        portInfo.setInterfacetype(currentFeatures.toString());
    }
    portInfo.setSwitchName(key);
    portInfo.setPortNumber(portDetail.getPortNumber());
    portInfo.setPortName(portDetail.getName());
    if (portDetail.getState() != null && !portDetail.getState().isEmpty()) {
        portInfo.setStatus(portDetail.getState().get(0));
    }
    return portInfo;
}
Also used : PortInfo(org.openkilda.model.PortInfo)

Example 7 with PortInfo

use of org.openkilda.model.PortInfo in project open-kilda by telstra.

the class StatsService method getIslPorts.

/**
 * Sets the isl ports.
 *
 * @param portInfos
 *            the port infos
 * @param switchid
 *            the switchid
 * @return the list
 */
private List<PortInfo> getIslPorts(final Map<String, Map<String, Double>> portStatsByPortNo, String switchid) {
    List<PortInfo> portInfos = getPortInfo(portStatsByPortNo);
    List<IslLink> islLinkPorts = switchIntegrationService.getIslLinkPortsInfo(null);
    String switchIdInfo = null;
    if (islLinkPorts != null) {
        for (IslLink islLink : islLinkPorts) {
            for (IslPath islPath : islLink.getPath()) {
                switchIdInfo = ("SW" + islPath.getSwitchId().replaceAll(":", "")).toUpperCase();
                if (switchIdInfo.equals(switchid)) {
                    for (int i = 0; i < portInfos.size(); i++) {
                        if (portInfos.get(i).getPortNumber().equals(islPath.getPortNo().toString())) {
                            portInfos.get(i).setAssignmenttype("ISL");
                        }
                    }
                }
            }
        }
    }
    return portInfos;
}
Also used : PortInfo(org.openkilda.model.PortInfo) IslLink(org.openkilda.integration.model.response.IslLink) IslPath(org.openkilda.integration.model.response.IslPath)

Aggregations

PortInfo (org.openkilda.model.PortInfo)7 ArrayList (java.util.ArrayList)4 PortDetail (org.openkilda.integration.model.PortDetail)2 Port (org.openkilda.integration.source.store.dto.Port)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JSONObject (org.json.simple.JSONObject)1 IntegrationException (org.openkilda.integration.exception.IntegrationException)1 PortsDetail (org.openkilda.integration.model.PortsDetail)1 IslLink (org.openkilda.integration.model.response.IslLink)1 IslPath (org.openkilda.integration.model.response.IslPath)1 PortDiscrepancy (org.openkilda.model.PortDiscrepancy)1 SwitchPortStats (org.openkilda.model.SwitchPortStats)1