Search in sources :

Example 1 with BgpSession

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);
}
Also used : BgpInfoService(org.onosproject.routing.bgp.BgpInfoService) BgpSession(org.onosproject.routing.bgp.BgpSession)

Example 2 with BgpSession

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;
}
Also used : ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BgpSession(org.onosproject.routing.bgp.BgpSession)

Example 3 with BgpSession

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());
    }
}
Also used : BgpInfoService(org.onosproject.routing.bgp.BgpInfoService) BgpSession(org.onosproject.routing.bgp.BgpSession)

Aggregations

BgpSession (org.onosproject.routing.bgp.BgpSession)3 BgpInfoService (org.onosproject.routing.bgp.BgpInfoService)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1