Search in sources :

Example 1 with FpmPeer

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

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

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

the class FpmAcceptRoutesCodec method decode.

@Override
public FpmPeerAcceptRoutes decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    IpAddress address = IpAddress.valueOf(json.path(PEER_ADDRESS).asText());
    int port = Integer.parseInt(json.path(PEER_PORT).asText());
    boolean isAcceptRoutes = Boolean.valueOf(json.path(ACCEPT_ROUTES).asText());
    FpmPeer peer = new FpmPeer(address, port);
    FpmPeerAcceptRoutes updatedPeer = new FpmPeerAcceptRoutes(peer, isAcceptRoutes);
    return updatedPeer;
}
Also used : FpmPeerAcceptRoutes(org.onosproject.routing.fpm.FpmPeerAcceptRoutes) IpAddress(org.onlab.packet.IpAddress) FpmPeer(org.onosproject.routing.fpm.FpmPeer)

Example 4 with FpmPeer

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

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

the class FpmSetAcceptRoutesCommand method doExecute.

@Override
protected void doExecute() {
    FpmInfoService service = AbstractShellCommand.get(FpmInfoService.class);
    IpAddress peerAddress = IpAddress.valueOf(peerAddressString);
    boolean isAcceptRoutes = Boolean.parseBoolean(acceptRoutesString);
    int port = Integer.parseInt(peerPort);
    FpmPeer peer = new FpmPeer(peerAddress, port);
    service.updateAcceptRouteFlag(Collections.singleton(new FpmPeerAcceptRoutes(peer, isAcceptRoutes)));
}
Also used : FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) FpmPeerAcceptRoutes(org.onosproject.routing.fpm.FpmPeerAcceptRoutes) IpAddress(org.onlab.packet.IpAddress) FpmPeer(org.onosproject.routing.fpm.FpmPeer)

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