Search in sources :

Example 1 with TrafficMatchData

use of org.onosproject.segmentrouting.policy.api.TrafficMatchData in project trellis-control by opennetworkinglab.

the class PolicyManager method trafficMatches.

@Override
public Set<TrafficMatchData> trafficMatches() {
    Set<TrafficMatchData> trafficMatchData = Sets.newHashSet();
    List<DeviceId> edgeDeviceIds = getEdgeDeviceIds();
    Set<TrafficMatchRequest> trafficMatchRequests = ImmutableSet.copyOf(trafficMatchesMap.values());
    TrafficMatchKey trafficMatchKey;
    List<String> ops;
    for (TrafficMatchRequest trafficMatchRequest : trafficMatchRequests) {
        ops = Lists.newArrayList();
        for (DeviceId deviceId : edgeDeviceIds) {
            trafficMatchKey = new TrafficMatchKey(deviceId, trafficMatchRequest.trafficMatch().trafficMatchId());
            Operation operation = Versioned.valueOrNull(operations.get(trafficMatchKey.toString()));
            if (operation != null) {
                ops.add(deviceId + " -> " + operation.toStringMinimal());
            }
        }
        trafficMatchData.add(new TrafficMatchData(trafficMatchRequest.trafficMatchState(), trafficMatchRequest.trafficMatch(), ops));
    }
    return trafficMatchData;
}
Also used : TrafficMatchData(org.onosproject.segmentrouting.policy.api.TrafficMatchData) DeviceId(org.onosproject.net.DeviceId)

Example 2 with TrafficMatchData

use of org.onosproject.segmentrouting.policy.api.TrafficMatchData in project trellis-control by opennetworkinglab.

the class PolicyWebResource method getTrafficMatches.

/**
 * Get all Traffic Matches.
 *
 * @return 200 OK will a collection of Traffic Matches
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("trafficmatch")
public Response getTrafficMatches() {
    PolicyService policyService = get(PolicyService.class);
    ObjectNode root = mapper().createObjectNode();
    ArrayNode trafficMatchArr = root.putArray(TRAFFIC_MATCH);
    for (TrafficMatchData trafficMatchData : policyService.trafficMatches()) {
        TrafficMatch trafficMatch = trafficMatchData.trafficMatch();
        trafficMatchArr.add(codec(TrafficMatch.class).encode(trafficMatch, this));
    }
    return Response.ok(root).build();
}
Also used : TrafficMatchData(org.onosproject.segmentrouting.policy.api.TrafficMatchData) TrafficMatch(org.onosproject.segmentrouting.policy.api.TrafficMatch) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

TrafficMatchData (org.onosproject.segmentrouting.policy.api.TrafficMatchData)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 DeviceId (org.onosproject.net.DeviceId)1 PolicyService (org.onosproject.segmentrouting.policy.api.PolicyService)1 TrafficMatch (org.onosproject.segmentrouting.policy.api.TrafficMatch)1