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;
}
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)));
}
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();
}
Aggregations