use of org.onosproject.routing.bgp.BgpSession in project onos by opennetworkinglab.
the class BgpNeighborsListCommand method doExecute.
@Override
protected void doExecute() {
BgpInfoService service = AbstractShellCommand.get(BgpInfoService.class);
Collection<BgpSession> bgpSessions = service.getBgpSessions();
if (bgpNeighbor != null) {
// Print a single neighbor (if found)
BgpSession foundBgpSession = null;
for (BgpSession bgpSession : bgpSessions) {
if (bgpSession.remoteInfo().bgpId().toString().equals(bgpNeighbor)) {
foundBgpSession = bgpSession;
break;
}
}
if (foundBgpSession != null) {
printNeighbor(foundBgpSession);
} else {
print("BGP neighbor %s not found", bgpNeighbor);
}
return;
}
// Print all neighbors
printNeighbors(bgpSessions);
}
use of org.onosproject.routing.bgp.BgpSession in project onos by opennetworkinglab.
the class BgpNeighborsListCommand method json.
/**
* Produces a JSON array of BGP neighbors.
*
* @param bgpSessions the BGP sessions with the data
* @return JSON array with the neighbors
*/
private JsonNode json(Collection<BgpSession> bgpSessions) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode result = mapper.createArrayNode();
for (BgpSession bgpSession : bgpSessions) {
result.add(json(mapper, bgpSession));
}
return result;
}
use of org.onosproject.routing.bgp.BgpSession in project onos by opennetworkinglab.
the class BgpRoutesListCommand method doExecute.
@Override
protected void doExecute() {
BgpInfoService service = AbstractShellCommand.get(BgpInfoService.class);
// Print summary of the routes
if (routesSummary) {
printSummary(service.getBgpRoutes4(), service.getBgpRoutes6());
return;
}
BgpSession foundBgpSession = null;
if (bgpNeighbor != null) {
// Print the routes from a single neighbor (if found)
for (BgpSession bgpSession : service.getBgpSessions()) {
if (bgpSession.remoteInfo().bgpId().toString().equals(bgpNeighbor)) {
foundBgpSession = bgpSession;
break;
}
}
if (foundBgpSession == null) {
print("BGP neighbor %s not found", bgpNeighbor);
return;
}
}
// Print the routes
if (foundBgpSession != null) {
printRoutes(foundBgpSession.getBgpRibIn4(), foundBgpSession.getBgpRibIn6());
} else {
printRoutes(service.getBgpRoutes4(), service.getBgpRoutes6());
}
}
Aggregations