use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class TunnelWebResource method createTunnel.
/**
* Create a new segment routing tunnel.
*
* @param input JSON stream for tunnel to create
* @return status of the request - OK if the tunnel is created,
* @throws IOException if the JSON is invalid
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createTunnel(InputStream input) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode tunnelJson = readTreeFromStream(mapper, input);
SegmentRoutingService srService = get(SegmentRoutingService.class);
Tunnel tunnelInfo = TUNNEL_CODEC.decode(tunnelJson, this);
srService.createTunnel(tunnelInfo);
return Response.ok().build();
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class McastTreeListCommand method doExecute.
@Override
protected void doExecute() {
// Get SR service and the handled mcast groups
SegmentRoutingService srService = get(SegmentRoutingService.class);
Set<IpAddress> mcastGroups = ImmutableSet.copyOf(srService.getMcastLeaders(null).keySet());
if (!isNullOrEmpty(gAddr)) {
mcastGroups = mcastGroups.stream().filter(mcastIp -> mcastIp.equals(IpAddress.valueOf(gAddr))).collect(Collectors.toSet());
}
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.createObjectNode();
// Print the trees for each group or build json objects
mcastGroups.forEach(group -> {
// We want to use source cp only for a specific group
ConnectPoint sourcecp = null;
if (!isNullOrEmpty(source) && !isNullOrEmpty(gAddr)) {
sourcecp = ConnectPoint.deviceConnectPoint(source);
}
Multimap<ConnectPoint, List<ConnectPoint>> mcastTree = srService.getMcastTrees(group, sourcecp);
if (!mcastTree.isEmpty()) {
// Build a json object for each group
if (outputJson()) {
root.putPOJO(group.toString(), json(mcastTree));
} else {
// Banner and then the trees
printMcastGroup(group);
mcastTree.forEach(this::printMcastSink);
}
}
});
// Print the json object at the end
if (outputJson()) {
print("%s", root);
}
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class NextDstCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
printDestinationSet(srService.getDstNextObjStore());
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class NextPortCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
print(srService.getPortNextObjStore());
}
use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.
the class PseudowireIdCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
List<L2Tunnel> tunnels = srService.getL2Tunnels();
// combine polices and tunnels to pseudowires
Iterator<String> pseudowires = tunnels.stream().map(l2Tunnel -> Long.toString(l2Tunnel.tunnelId())).collect(Collectors.toList()).iterator();
SortedSet<String> strings = delegate.getStrings();
while (pseudowires.hasNext()) {
strings.add(pseudowires.next());
}
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
Aggregations