Search in sources :

Example 6 with WaypointConstraint

use of org.onosproject.net.intent.constraint.WaypointConstraint in project onos by opennetworkinglab.

the class IntentJsonMatcher method matchWaypointConstraint.

/**
 * Matches a waypoint constraint against a JSON representation of the
 * constraint.
 *
 * @param waypointConstraint constraint object to match
 * @param constraintJson JSON representation of the constraint
 * @return true if the constraint and JSON match, false otherwise.
 */
private boolean matchWaypointConstraint(WaypointConstraint waypointConstraint, JsonNode constraintJson) {
    final JsonNode waypointsJson = constraintJson.get("waypoints");
    if (waypointsJson.size() != waypointConstraint.waypoints().size()) {
        return false;
    }
    for (int waypointsIndex = 0; waypointsIndex < waypointsJson.size(); waypointsIndex++) {
        boolean waypointFound = false;
        final String waypointJson = waypointsJson.get(waypointsIndex).asText();
        for (DeviceId waypoint : waypointConstraint.waypoints()) {
            if (waypoint.toString().equals(waypointJson)) {
                waypointFound = true;
            }
        }
        if (!waypointFound) {
            return false;
        }
    }
    return true;
}
Also used : DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) ObstacleConstraint(org.onosproject.net.intent.constraint.ObstacleConstraint) Constraint(org.onosproject.net.intent.Constraint) ConnectPoint(org.onosproject.net.ConnectPoint) AnnotationConstraint(org.onosproject.net.intent.constraint.AnnotationConstraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) LinkTypeConstraint(org.onosproject.net.intent.constraint.LinkTypeConstraint)

Aggregations

WaypointConstraint (org.onosproject.net.intent.constraint.WaypointConstraint)6 DeviceId (org.onosproject.net.DeviceId)4 AnnotationConstraint (org.onosproject.net.intent.constraint.AnnotationConstraint)4 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)4 LatencyConstraint (org.onosproject.net.intent.constraint.LatencyConstraint)4 ObstacleConstraint (org.onosproject.net.intent.constraint.ObstacleConstraint)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Constraint (org.onosproject.net.intent.Constraint)3 LinkTypeConstraint (org.onosproject.net.intent.constraint.LinkTypeConstraint)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Test (org.junit.Test)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 AsymmetricPathConstraint (org.onosproject.net.intent.constraint.AsymmetricPathConstraint)2 MeteredConstraint (org.onosproject.net.intent.constraint.MeteredConstraint)2 TierConstraint (org.onosproject.net.intent.constraint.TierConstraint)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ArrayList (java.util.ArrayList)1 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)1 Lambda (org.onosproject.net.Lambda)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1