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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations