Search in sources :

Example 1 with FpmPeerInfo

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

the class FpmAcceptRoutesInfoCommand method doExecute.

@Override
protected void doExecute() {
    FpmInfoService fpmInfo = get(FpmInfoService.class);
    if (peerAddress != null) {
        IpAddress address = IpAddress.valueOf(peerAddress);
        fpmInfo.peers().entrySet().stream().filter(peer -> peer.getKey().address().equals(address)).map(Map.Entry::getValue).forEach(this::print);
    } else {
        fpmInfo.peers().entrySet().stream().sorted(Comparator.<Map.Entry<FpmPeer, FpmPeerInfo>, IpAddress>comparing(e -> e.getKey().address()).thenComparing(e -> e.getKey().port())).map(Map.Entry::getValue).forEach(this::print);
    }
}
Also used : FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) FpmPeer(org.onosproject.routing.fpm.FpmPeer) FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) FpmPeerInfo(org.onosproject.routing.fpm.FpmPeerInfo) Map(java.util.Map) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Argument(org.apache.karaf.shell.api.action.Argument) Comparator(java.util.Comparator) Command(org.apache.karaf.shell.api.action.Command) IpAddress(org.onlab.packet.IpAddress) IpAddress(org.onlab.packet.IpAddress) Map(java.util.Map)

Example 2 with FpmPeerInfo

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

the class FpmConnectionsList method doExecute.

@Override
protected void doExecute() {
    FpmInfoService fpmInfo = get(FpmInfoService.class);
    print(String.format("PD Pushing is %s.", fpmInfo.isPdPushEnabled() ? "enabled" : "disabled"));
    if (peerAddress != null) {
        IpAddress address = IpAddress.valueOf(peerAddress);
        fpmInfo.peers().entrySet().stream().filter(peer -> peer.getKey().address().equals(address)).map(Map.Entry::getValue).forEach(this::print);
    } else {
        fpmInfo.peers().entrySet().stream().sorted(Comparator.<Map.Entry<FpmPeer, FpmPeerInfo>, IpAddress>comparing(e -> e.getKey().address()).thenComparing(e -> e.getKey().port())).map(Map.Entry::getValue).forEach(this::print);
    }
}
Also used : FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) FpmPeer(org.onosproject.routing.fpm.FpmPeer) FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) Tools(org.onlab.util.Tools) FpmPeerInfo(org.onosproject.routing.fpm.FpmPeerInfo) Map(java.util.Map) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Argument(org.apache.karaf.shell.api.action.Argument) ClusterService(org.onosproject.cluster.ClusterService) Comparator(java.util.Comparator) Command(org.apache.karaf.shell.api.action.Command) IpAddress(org.onlab.packet.IpAddress) IpAddress(org.onlab.packet.IpAddress) Map(java.util.Map)

Example 3 with FpmPeerInfo

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

the class FpmWebResource method getFpmConnectionsJsonOutput.

private ObjectNode getFpmConnectionsJsonOutput() {
    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 -> connectionArray.add((new FpmCodec()).encode(fpmPeerInfo, this)));
    node.put("fpm-connections", 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 4 with FpmPeerInfo

use of org.onosproject.routing.fpm.FpmPeerInfo 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 5 with FpmPeerInfo

use of org.onosproject.routing.fpm.FpmPeerInfo 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

Map (java.util.Map)5 IpAddress (org.onlab.packet.IpAddress)5 FpmInfoService (org.onosproject.routing.fpm.FpmInfoService)5 FpmPeer (org.onosproject.routing.fpm.FpmPeer)5 FpmPeerInfo (org.onosproject.routing.fpm.FpmPeerInfo)5 Comparator (java.util.Comparator)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 Argument (org.apache.karaf.shell.api.action.Argument)2