use of org.onosproject.routing.fpm.FpmInfoService 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;
}
use of org.onosproject.routing.fpm.FpmInfoService 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;
}
use of org.onosproject.routing.fpm.FpmInfoService in project onos by opennetworkinglab.
the class FpmWebResource method updateAcceptRouteFlagForConnection.
/**
* Performs disabling of FPM Peer.
*
* @param stream array of peer address and accept route flag
* @return 200 OK disable peer.
* @onos.rsModel FpmPeerSetAcceptRouteFlag
*/
@POST
@Path("acceptRoutes")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateAcceptRouteFlagForConnection(InputStream stream) {
FpmInfoService fpmService = get(FpmInfoService.class);
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
ArrayNode peersArray = nullIsIllegal((ArrayNode) jsonTree.get(PEERS), PEERS_KEY_ERROR);
List<FpmPeerAcceptRoutes> fpmPeerRouteInfo = (new FpmAcceptRoutesCodec()).decode(peersArray, this);
fpmService.updateAcceptRouteFlag(fpmPeerRouteInfo);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.ok().build();
}
Aggregations