Search in sources :

Example 1 with McastRole

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

the class McastRoleListCommand method doExecute.

@Override
protected void doExecute() {
    // Verify mcast group
    IpAddress mcastGroup = null;
    // We want to use source cp only for a specific group
    ConnectPoint sourcecp = null;
    if (!isNullOrEmpty(gAddr)) {
        mcastGroup = IpAddress.valueOf(gAddr);
        if (!isNullOrEmpty(source)) {
            sourcecp = ConnectPoint.deviceConnectPoint(source);
        }
    }
    // Get SR service, the roles and the groups
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    Map<McastRoleStoreKey, McastRole> keyToRole = srService.getMcastRoles(mcastGroup, sourcecp);
    Set<IpAddress> mcastGroups = keyToRole.keySet().stream().map(McastRoleStoreKey::mcastIp).collect(Collectors.toSet());
    // Print the trees for each group
    mcastGroups.forEach(group -> {
        // Create a new map for the group
        Map<ConnectPoint, Multimap<McastRole, DeviceId>> roleDeviceIdMap = Maps.newHashMap();
        keyToRole.entrySet().stream().filter(entry -> entry.getKey().mcastIp().equals(group)).forEach(entry -> roleDeviceIdMap.compute(entry.getKey().source(), (gsource, map) -> {
            map = map == null ? ArrayListMultimap.create() : map;
            map.put(entry.getValue(), entry.getKey().deviceId());
            return map;
        }));
        roleDeviceIdMap.forEach((gsource, map) -> {
            // Print the map
            printMcastRole(group, gsource, map.get(McastRole.INGRESS), map.get(McastRole.TRANSIT), map.get(McastRole.EGRESS));
        });
    });
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) McastRoleStoreKey(org.onosproject.segmentrouting.mcast.McastRoleStoreKey) McastGroupCompleter(org.onosproject.mcast.cli.McastGroupCompleter) Collection(java.util.Collection) Set(java.util.Set) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) Multimap(com.google.common.collect.Multimap) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) ConnectPoint(org.onosproject.net.ConnectPoint) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) ConnectPointCompleter(org.onosproject.cli.net.ConnectPointCompleter) 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) McastRole(org.onosproject.segmentrouting.mcast.McastRole) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) Multimap(com.google.common.collect.Multimap) McastRoleStoreKey(org.onosproject.segmentrouting.mcast.McastRoleStoreKey) IpAddress(org.onlab.packet.IpAddress) ConnectPoint(org.onosproject.net.ConnectPoint) McastRole(org.onosproject.segmentrouting.mcast.McastRole)

Aggregations

Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)1 Option (org.apache.karaf.shell.api.action.Option)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 IpAddress (org.onlab.packet.IpAddress)1 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 ConnectPointCompleter (org.onosproject.cli.net.ConnectPointCompleter)1 McastGroupCompleter (org.onosproject.mcast.cli.McastGroupCompleter)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 SegmentRoutingService (org.onosproject.segmentrouting.SegmentRoutingService)1 McastRole (org.onosproject.segmentrouting.mcast.McastRole)1