Search in sources :

Example 6 with FpmPeer

use of org.onosproject.routing.fpm.FpmPeer in project onos by opennetworkinglab.

the class FpmWebResource method getFpmPeerRouteInfoJsonOutput.

private ObjectNode getFpmPeerRouteInfoJsonOutput() {
    FpmInfoService fpmService = get(FpmInfoService.class);
    ObjectNode node = mapper().createObjectNode();
    ArrayNode connectionArray = mapper().createArrayNode();
    Map<FpmPeer, FpmPeerInfo> fpmPeers = fpmService.peers();
    fpmPeers.entrySet().stream().sorted(Comparator.<Map.Entry<FpmPeer, FpmPeerInfo>, IpAddress>comparing(e -> e.getKey().address()).thenComparing(e -> e.getKey().port())).map(Map.Entry::getValue).forEach(fpmPeerInfo -> {
        fpmPeerInfo.connections().forEach(connection -> {
            ObjectNode fpmNode = mapper().createObjectNode();
            fpmNode.put(PEER_ADDRESS, connection.peer().address().toString());
            fpmNode.put(PEER_PORT, connection.peer().port());
            fpmNode.put(ACCEPT_ROUTES, connection.isAcceptRoutes());
            connectionArray.add(fpmNode);
        });
    });
    node.put("fpm-peer-info", connectionArray);
    return node;
}
Also used : FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) FpmPeerInfo(org.onosproject.routing.fpm.FpmPeerInfo) PathParam(javax.ws.rs.PathParam) AbstractWebResource(org.onosproject.rest.AbstractWebResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) MediaType(javax.ws.rs.core.MediaType) Consumes(javax.ws.rs.Consumes) Map(java.util.Map) Tools.nullIsIllegal(org.onlab.util.Tools.nullIsIllegal) IpAddress(org.onlab.packet.IpAddress) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) IOException(java.io.IOException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) FpmPeer(org.onosproject.routing.fpm.FpmPeer) List(java.util.List) Response(javax.ws.rs.core.Response) FpmPeerInfo(org.onosproject.routing.fpm.FpmPeerInfo) FpmPeerAcceptRoutes(org.onosproject.routing.fpm.FpmPeerAcceptRoutes) Tools.readTreeFromStream(org.onlab.util.Tools.readTreeFromStream) Comparator(java.util.Comparator) InputStream(java.io.InputStream) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) IpAddress(org.onlab.packet.IpAddress) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) FpmPeer(org.onosproject.routing.fpm.FpmPeer) Map(java.util.Map)

Example 7 with FpmPeer

use of org.onosproject.routing.fpm.FpmPeer in project onos by opennetworkinglab.

the class FpmWebResource method getFpmPeerAcceptFlagInfoJsonOutput.

private ObjectNode getFpmPeerAcceptFlagInfoJsonOutput(String address) {
    FpmInfoService fpmService = get(FpmInfoService.class);
    ObjectNode fpmNode = mapper().createObjectNode();
    Map<FpmPeer, FpmPeerInfo> fpmPeers = fpmService.peers();
    IpAddress peerAddress = IpAddress.valueOf(address);
    fpmPeers.entrySet().stream().filter(peer -> peer.getKey().address().equals(peerAddress)).map(Map.Entry::getValue).forEach(fpmPeerInfo -> {
        fpmPeerInfo.connections().forEach(connection -> {
            fpmNode.put(ACCEPT_ROUTES, connection.isAcceptRoutes());
        });
    });
    return fpmNode;
}
Also used : FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) FpmPeerInfo(org.onosproject.routing.fpm.FpmPeerInfo) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) IpAddress(org.onlab.packet.IpAddress) FpmPeer(org.onosproject.routing.fpm.FpmPeer) Map(java.util.Map)

Aggregations

IpAddress (org.onlab.packet.IpAddress)7 FpmPeer (org.onosproject.routing.fpm.FpmPeer)7 FpmInfoService (org.onosproject.routing.fpm.FpmInfoService)6 Map (java.util.Map)5 FpmPeerInfo (org.onosproject.routing.fpm.FpmPeerInfo)5 Comparator (java.util.Comparator)4 FpmPeerAcceptRoutes (org.onosproject.routing.fpm.FpmPeerAcceptRoutes)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 List (java.util.List)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 PathParam (javax.ws.rs.PathParam)2 Produces (javax.ws.rs.Produces)2 MediaType (javax.ws.rs.core.MediaType)2 Response (javax.ws.rs.core.Response)2