Search in sources :

Example 31 with SegmentRoutingService

use of org.onosproject.segmentrouting.SegmentRoutingService in project trellis-control by opennetworkinglab.

the class McastNextListCommand method doExecute.

@Override
protected void doExecute() {
    // Verify mcast group
    IpAddress mcastGroup = null;
    if (!isNullOrEmpty(gAddr)) {
        mcastGroup = IpAddress.valueOf(gAddr);
    }
    // Get SR service
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    // Get the mapping
    Map<McastStoreKey, Integer> keyToNextId = srService.getMcastNextIds(mcastGroup);
    // Reduce to the set of mcast groups
    Set<IpAddress> mcastGroups = keyToNextId.keySet().stream().map(McastStoreKey::mcastIp).collect(Collectors.toSet());
    // Print the nextids for each group
    mcastGroups.forEach(group -> {
        // Create a new map for the group
        Map<Pair<DeviceId, VlanId>, Integer> deviceIdNextMap = Maps.newHashMap();
        keyToNextId.entrySet().stream().filter(entry -> entry.getKey().mcastIp().equals(group)).forEach(entry -> deviceIdNextMap.put(Pair.of(entry.getKey().deviceId(), entry.getKey().vlanId()), entry.getValue()));
        // Print the map
        printMcastNext(group, deviceIdNextMap);
    });
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) McastGroupCompleter(org.onosproject.mcast.cli.McastGroupCompleter) McastStoreKey(org.onosproject.segmentrouting.mcast.McastStoreKey) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) Option(org.apache.karaf.shell.api.action.Option) DeviceId(org.onosproject.net.DeviceId) IpAddress(org.onlab.packet.IpAddress) IpAddress(org.onlab.packet.IpAddress) McastStoreKey(org.onosproject.segmentrouting.mcast.McastStoreKey) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

SegmentRoutingService (org.onosproject.segmentrouting.SegmentRoutingService)31 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 Consumes (javax.ws.rs.Consumes)7 L2TunnelHandler (org.onosproject.segmentrouting.pwaas.L2TunnelHandler)7 List (java.util.List)5 IpAddress (org.onlab.packet.IpAddress)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ArrayList (java.util.ArrayList)4 DELETE (javax.ws.rs.DELETE)4 POST (javax.ws.rs.POST)4 Pair (org.apache.commons.lang3.tuple.Pair)4 DeviceId (org.onosproject.net.DeviceId)4 DefaultL2TunnelDescription (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription)4 Collectors (java.util.stream.Collectors)3 Path (javax.ws.rs.Path)3 Tunnel (org.onosproject.segmentrouting.Tunnel)3 L2Tunnel (org.onosproject.segmentrouting.pwaas.L2Tunnel)3 L2TunnelDescription (org.onosproject.segmentrouting.pwaas.L2TunnelDescription)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2