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