use of org.openkilda.integration.model.PortDetail in project open-kilda by telstra.
the class PortConverter method toPortsInfo.
/**
* To ports info.
*
* @param jsonObject the json object
* @param switchId the switch id
* @return the list
* @throws JsonParseException the json parse exception
* @throws JsonMappingException the json mapping exception
* @throws IOException Signals that an I/O exception has occurred.
*/
public static List<PortInfo> toPortsInfo(final JSONObject jsonObject, final String switchId) throws JsonParseException, JsonMappingException, IOException {
List<PortInfo> ports = new ArrayList<PortInfo>();
if (jsonObject != null) {
Object object = jsonObject.get(switchId);
if (object != null) {
String val = JSONValue.toJSONString(object);
PortsDetail portsDetail = JsonUtil.toObject(val, PortsDetail.class);
List<PortDetail> portDetailList = portsDetail.getPortDetail();
if (portDetailList != null && !portDetailList.isEmpty()) {
ports = getPortsInfo(portDetailList, switchId, ports);
}
}
}
return ports;
}
use of org.openkilda.integration.model.PortDetail in project open-kilda by telstra.
the class PortConverter method getPortsInfo.
/**
* Gets the ports info.
*
* @param portsDetail the ports detail
* @param key the key
* @param switchPortsInfoList the switch ports info list
* @return the ports info
*/
private static List<PortInfo> getPortsInfo(final List<PortDetail> portsDetail, final String key, final List<PortInfo> switchPortsInfoList) {
for (PortDetail portDetail : portsDetail) {
if (!portDetail.getPortNumber().equalsIgnoreCase("local")) {
PortInfo info = setPortInfo(key, portDetail);
switchPortsInfoList.add(info);
}
}
Collections.sort(switchPortsInfoList);
return switchPortsInfoList;
}
Aggregations