Search in sources :

Example 26 with SegmentRoutingService

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

the class BlackHoleCommand method doExecute.

@Override
protected void doExecute() {
    SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
    NetworkConfigService netcfgService = AbstractShellCommand.get(NetworkConfigService.class);
    SegmentRoutingAppConfig appConfig = netcfgService.getConfig(srService.appId(), SegmentRoutingAppConfig.class);
    if (appConfig == null) {
        JsonNode jsonNode = new ObjectMapper().createObjectNode();
        netcfgService.applyConfig(srService.appId(), SegmentRoutingAppConfig.class, jsonNode);
        appConfig = netcfgService.getConfig(srService.appId(), SegmentRoutingAppConfig.class);
    }
    Set<IpPrefix> blackHoleIps;
    switch(op) {
        case "list":
            appConfig.blackholeIPs().forEach(prefix -> print(prefix.toString()));
            break;
        case "add":
            blackHoleIps = Sets.newConcurrentHashSet(appConfig.blackholeIPs());
            blackHoleIps.add(IpPrefix.valueOf(prefix));
            appConfig.setBalckholeIps(blackHoleIps);
            appConfig.apply();
            break;
        case "remove":
            blackHoleIps = Sets.newConcurrentHashSet(appConfig.blackholeIPs());
            blackHoleIps.remove(IpPrefix.valueOf(prefix));
            appConfig.setBalckholeIps(blackHoleIps);
            appConfig.apply();
            break;
        default:
            throw new UnsupportedOperationException("Unknown operation " + op);
    }
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) IpPrefix(org.onlab.packet.IpPrefix) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 27 with SegmentRoutingService

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

the class DeviceSubnetListCommand method doExecute.

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

Example 28 with SegmentRoutingService

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

the class InvalidateNextCommand method doExecute.

@Override
protected void doExecute() {
    if (please == null || !please.equals(CONFIRM_PHRASE)) {
        print("WARNING: System may enter an unpredictable state if the next ID is force invalidated." + "Enter confirmation phrase to continue.");
        return;
    }
    try {
        SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
        srService.invalidateNextObj(Integer.parseInt(nextId));
    } catch (ServiceNotFoundException e) {
        print("SegmentRoutingService unavailable");
    }
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException)

Example 29 with SegmentRoutingService

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

the class LinkStateCommand method doExecute.

@Override
protected void doExecute() {
    SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
    printLinkState(srService.getSeenLinks(), srService.getDownedPortState());
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService)

Example 30 with SegmentRoutingService

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

the class McastLeaderListCommand 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<IpAddress, NodeId> keyToRole = srService.getMcastLeaders(mcastGroup);
    // And print local cache
    keyToRole.forEach(this::printMcastLeder);
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) NodeId(org.onosproject.cluster.NodeId) IpAddress(org.onlab.packet.IpAddress)

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