Search in sources :

Example 1 with DefaultNextObjective

use of org.onosproject.net.flowobjective.DefaultNextObjective in project onos by opennetworkinglab.

the class IntentFilter method getFlowEntries.

/**
 * Finds all flow entries created by FlowObjectiveIntent.
 *
 * @param intent FlowObjectiveIntent Object
 * @return set of flow entries created by FlowObjectiveIntent
 */
private List<FlowEntry> getFlowEntries(FlowObjectiveIntent intent) {
    List<FlowEntry> flowEntries = new ArrayList<>();
    Iterator<Objective> objectives = intent.objectives().iterator();
    Iterator<DeviceId> devices = intent.devices().iterator();
    DefaultNextObjective nextObjective = null;
    DefaultForwardingObjective forwardObjective;
    Objective objective;
    DeviceId deviceId;
    FlowEntry flowEntry;
    while (objectives.hasNext()) {
        objective = objectives.next();
        deviceId = devices.next();
        if (objective instanceof NextObjective) {
            nextObjective = (DefaultNextObjective) objective;
        } else if (objective instanceof ForwardingObjective) {
            forwardObjective = (DefaultForwardingObjective) objective;
            FlowRule.Builder builder = DefaultFlowRule.builder().forDevice(deviceId).withSelector(forwardObjective.selector()).withPriority(intent.priority()).fromApp(intent.appId()).makePermanent();
            if (nextObjective != null) {
                builder.withTreatment(nextObjective.next().iterator().next());
            }
            FlowRule flowRule = builder.build();
            flowEntry = getFlowEntry(flowRule);
            if (flowEntry != null) {
                flowEntries.add(flowEntry);
            }
        }
    }
    return flowEntries;
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) Objective(org.onosproject.net.flowobjective.Objective) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective)

Aggregations

ArrayList (java.util.ArrayList)1 DeviceId (org.onosproject.net.DeviceId)1 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1 FlowRule (org.onosproject.net.flow.FlowRule)1 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)1 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)1 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)1 NextObjective (org.onosproject.net.flowobjective.NextObjective)1 Objective (org.onosproject.net.flowobjective.Objective)1