Search in sources :

Example 1 with ObjectiveContext

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

the class FibInstaller method sendFilteringObjective.

private void sendFilteringObjective(boolean install, FilteringObjective.Builder fob, Interface intf) {
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.info("Installed filter for interface {}", intf), (objective, error) -> log.error("Failed to install filter for interface {}: {}", intf, error));
    FilteringObjective filter = install ? fob.add(context) : fob.remove(context);
    flowObjectiveService.filter(deviceId, filter);
}
Also used : DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective)

Example 2 with ObjectiveContext

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

the class VirtualNetworkPacketManager method removeRule.

/**
 * Removes packet intercept flow rules from the device.
 *
 * @param device  the device to remove the rules deom
 * @param request the packet request
 */
private void removeRule(Device device, PacketRequest request) {
    if (!device.type().equals(Device.Type.VIRTUAL)) {
        return;
    }
    ForwardingObjective forwarding = createBuilder(request).remove(new ObjectiveContext() {

        @Override
        public void onError(Objective objective, ObjectiveError error) {
            log.warn("Failed to withdraw packet request {} from {}: {}", request, device.id(), error);
        }
    });
    objectiveService.forward(device.id(), forwarding);
}
Also used : ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError)

Example 3 with ObjectiveContext

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

the class VirtualNetworkFlowObjectiveManagerTest method filteringObjective.

/**
 * Tests adding a filtering objective.
 */
@Test
public void filteringObjective() {
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    FilteringObjective filter = DefaultFilteringObjective.builder().fromApp(NetTestTools.APP_ID).withMeta(treatment).makePermanent().deny().addCondition(Criteria.matchEthType(12)).add(new ObjectiveContext() {

        @Override
        public void onSuccess(Objective objective) {
            assertEquals("1 flowrule entry expected", 1, flowRuleStore.getFlowRuleCount(vnet1.id()));
            assertEquals("0 flowrule entry expected", 0, flowRuleStore.getFlowRuleCount(vnet2.id()));
        }
    });
    service1.filter(VDID1, filter);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Example 4 with ObjectiveContext

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

the class VirtualNetworkFlowObjectiveManagerTest method forwardingObjective.

/**
 * Tests adding a forwarding objective.
 */
@Test
public void forwardingObjective() {
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    ForwardingObjective forward = DefaultForwardingObjective.builder().fromApp(NetTestTools.APP_ID).withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(selector).withTreatment(treatment).makePermanent().add(new ObjectiveContext() {

        @Override
        public void onSuccess(Objective objective) {
            assertEquals("1 flowrule entry expected", 1, flowRuleStore.getFlowRuleCount(vnet1.id()));
            assertEquals("0 flowrule entry expected", 0, flowRuleStore.getFlowRuleCount(vnet2.id()));
        }
    });
    service1.forward(VDID1, forward);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Example 5 with ObjectiveContext

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

the class VirtualNetworkFlowObjectiveManagerTest method nextObjective.

/**
 * Tests adding a next objective.
 */
@Test
public void nextObjective() {
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    NextObjective nextObjective = DefaultNextObjective.builder().withId(service1.allocateNextId()).fromApp(NetTestTools.APP_ID).addTreatment(treatment).withType(NextObjective.Type.BROADCAST).makePermanent().add(new ObjectiveContext() {

        @Override
        public void onSuccess(Objective objective) {
            assertEquals("1 next map entry expected", 1, service1.getNextMappings().size());
            assertEquals("0 next map entry expected", 0, service2.getNextMappings().size());
        }
    });
    service1.next(VDID1, nextObjective);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Aggregations

ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)13 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)11 Objective (org.onosproject.net.flowobjective.Objective)11 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)10 ObjectiveError (org.onosproject.net.flowobjective.ObjectiveError)7 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)6 NextObjective (org.onosproject.net.flowobjective.NextObjective)6 DefaultFilteringObjective (org.onosproject.net.flowobjective.DefaultFilteringObjective)5 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)5 Test (org.junit.Test)4 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)4 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)3 ConnectPoint (org.onosproject.net.ConnectPoint)2 Device (org.onosproject.net.Device)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 ArrayDeque (java.util.ArrayDeque)1 Deque (java.util.Deque)1