Search in sources :

Example 1 with SegmentRoutingService

use of org.onosproject.segmentrouting.SegmentRoutingService 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)

Example 2 with SegmentRoutingService

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

the class NextMacVlanCommand method doExecute.

@Override
protected void doExecute() {
    SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
    print(srService.getMacVlanNextObjStore());
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService)

Example 3 with SegmentRoutingService

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

the class NextVlanCommand method doExecute.

@Override
protected void doExecute() {
    SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
    print(srService.getVlanNextObjStore());
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService)

Example 4 with SegmentRoutingService

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

the class PseudowireAddCommand method doExecute.

@Override
protected void doExecute() {
    SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
    L2Tunnel tun;
    L2TunnelPolicy policy;
    try {
        tun = new DefaultL2Tunnel(parseMode(mode), parseVlan(sDTag), parsePwId(pwId), parsePWLabel(pwLabel));
    } catch (IllegalArgumentException e) {
        log.error("Exception while parsing L2Tunnel : \n\t %s", e.getMessage());
        print("Exception while parsing L2Tunnel : \n\t %s", e.getMessage());
        return;
    }
    try {
        policy = new DefaultL2TunnelPolicy(parsePwId(pwId), ConnectPoint.deviceConnectPoint(cP1), parseVlan(cP1InnerVlan), parseVlan(cP1OuterVlan), ConnectPoint.deviceConnectPoint(cP2), parseVlan(cP2InnerVlan), parseVlan(cP2OuterVlan));
    } catch (IllegalArgumentException e) {
        log.error("Exception while parsing L2TunnelPolicy : \n\t %s", e.getMessage());
        print("Exception while parsing L2TunnelPolicy : \n\t %s", e.getMessage());
        return;
    }
    L2TunnelDescription pw = new DefaultL2TunnelDescription(tun, policy);
    L2TunnelHandler.Result res = srService.addPseudowire(pw);
    log.info("Deploying pseudowire {} via the command line.", pw);
    switch(res) {
        case WRONG_PARAMETERS:
            print("Pseudowire could not be added , error in the parameters : \n\t%s", res.getSpecificError());
            break;
        case CONFIGURATION_ERROR:
            print("Pseudowire could not be added, configuration error : \n\t%s", res.getSpecificError());
            break;
        case PATH_NOT_FOUND:
            print("Pseudowire path not found : \n\t%s", res.getSpecificError());
            break;
        case INTERNAL_ERROR:
            print("Pseudowire could not be added, internal error : \n\t%s", res.getSpecificError());
            break;
        case SUCCESS:
            break;
        default:
            break;
    }
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) L2TunnelHandler(org.onosproject.segmentrouting.pwaas.L2TunnelHandler) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription)

Example 5 with SegmentRoutingService

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

the class PseudowireListCommand method doExecute.

@Override
protected void doExecute() {
    SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
    srService.getL2TunnelDescriptions(false).forEach(pw -> printPseudowire(pw, false));
    srService.getL2TunnelDescriptions(true).forEach(pw -> printPseudowire(pw, true));
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService)

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