Search in sources :

Example 1 with FpmPeerAcceptRoutes

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

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

Example 3 with FpmPeerAcceptRoutes

use of org.onosproject.routing.fpm.FpmPeerAcceptRoutes 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();
}
Also used : FpmInfoService(org.onosproject.routing.fpm.FpmInfoService) FpmPeerAcceptRoutes(org.onosproject.routing.fpm.FpmPeerAcceptRoutes) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) IOException(java.io.IOException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

FpmPeerAcceptRoutes (org.onosproject.routing.fpm.FpmPeerAcceptRoutes)3 IpAddress (org.onlab.packet.IpAddress)2 FpmInfoService (org.onosproject.routing.fpm.FpmInfoService)2 FpmPeer (org.onosproject.routing.fpm.FpmPeer)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1