Search in sources :

Example 51 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class AbstractIntentInstallerTest method createP2PIntent.

/**
 * Creates point to point Intent for test.
 *
 * @return the point to point Intent
 */
public PointToPointIntent createP2PIntent() {
    PointToPointIntent intent;
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
    FilteredConnectPoint egress = new FilteredConnectPoint(CP2);
    intent = PointToPointIntent.builder().selector(selector).treatment(treatment).filteredIngressPoint(ingress).filteredEgressPoint(egress).appId(APP_ID).build();
    return intent;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 52 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class AbstractIntentInstallerTest method createP2PIntentNonDisruptive.

/**
 * Creates point to point Intent for testing non-disruptive reallocation.
 *
 * @return the point to point Intent
 */
public PointToPointIntent createP2PIntentNonDisruptive() {
    PointToPointIntent intent;
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
    FilteredConnectPoint egress = new FilteredConnectPoint(CP4_1);
    List<Constraint> constraints = ImmutableList.of(nonDisruptive());
    intent = PointToPointIntent.builder().selector(selector).treatment(treatment).filteredIngressPoint(ingress).filteredEgressPoint(egress).constraints(constraints).appId(APP_ID).build();
    return intent;
}
Also used : Constraint(org.onosproject.net.intent.Constraint) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 53 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class FlowObjectiveIntentInstallerTest method createFlowObjectiveIntents.

/**
 * Creates flow objective Intents.
 *
 * @return the flow objective intents
 */
private List<Intent> createFlowObjectiveIntents() {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(CP1.port()).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(CP2.port()).build();
    FilteringObjective filt = DefaultFilteringObjective.builder().addCondition(selector.getCriterion(Criterion.Type.IN_PORT)).withPriority(DEFAULT_PRIORITY).fromApp(APP_ID).permit().add();
    NextObjective next = DefaultNextObjective.builder().withMeta(selector).addTreatment(treatment).makePermanent().withPriority(DEFAULT_PRIORITY).fromApp(APP_ID).withType(NextObjective.Type.SIMPLE).withId(NEXT_ID_1).add();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().withFlag(ForwardingObjective.Flag.SPECIFIC).nextStep(NEXT_ID_1).add();
    List<Objective> objectives = ImmutableList.of(filt, next, fwd);
    List<DeviceId> deviceIds = ImmutableList.of(CP1.deviceId(), CP1.deviceId(), CP1.deviceId());
    List<NetworkResource> resources = ImmutableList.of(CP1.deviceId());
    Intent intent = new FlowObjectiveIntent(APP_ID, KEY1, deviceIds, objectives, resources, RG1);
    return ImmutableList.of(intent);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DeviceId(org.onosproject.net.DeviceId) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) NetworkResource(org.onosproject.net.NetworkResource) 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) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective)

Example 54 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class FlowRuleIntentInstallerTest method testUninstallAndInstallNonDisruptive.

/**
 * Testing the non-disruptive reallocation.
 */
@Test
public void testUninstallAndInstallNonDisruptive() throws InterruptedException {
    installer.flowRuleService = flowRuleServiceNonDisruptive;
    List<Intent> intentsToInstall = createAnotherFlowRuleIntentsNonDisruptive();
    List<Intent> intentsToUninstall = createFlowRuleIntentsNonDisruptive();
    IntentData toInstall = new IntentData(createP2PIntentNonDisruptive(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentData toUninstall = new IntentData(createP2PIntentNonDisruptive(), IntentState.INSTALLED, new WallClockTimestamp());
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    IntentOperationContext<FlowRuleIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    // A single FlowRule is evaluated for every non-disruptive stage
    TrafficSelector selector = DefaultTrafficSelector.builder().matchInPhyPort(CP1.port()).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(CP3.port()).build();
    FlowRule firstStageInstalledRule = DefaultFlowRule.builder().forDevice(CP1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY - 1).makePermanent().build();
    // race conditions and failing builds
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(ADD, firstStageInstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesAdd.contains(firstStageInstalledRule));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(CP4_2.port()).build();
    treatment = DefaultTrafficTreatment.builder().setOutput(CP4_1.port()).build();
    FlowRule secondStageUninstalledRule = DefaultFlowRule.builder().forDevice(CP4_1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(REMOVE, secondStageUninstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesRemove.contains(secondStageUninstalledRule));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(CP4_3.port()).build();
    treatment = DefaultTrafficTreatment.builder().setOutput(CP4_1.port()).build();
    FlowRule thirdStageInstalledRule = DefaultFlowRule.builder().forDevice(CP4_1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(ADD, thirdStageInstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesAdd.contains(thirdStageInstalledRule));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(CP2_1.port()).build();
    treatment = DefaultTrafficTreatment.builder().setOutput(CP2_2.port()).build();
    FlowRule lastStageUninstalledRule = DefaultFlowRule.builder().forDevice(CP2_1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(REMOVE, lastStageUninstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesRemove.contains(lastStageUninstalledRule));
    IntentOperationContext successContext = intentInstallCoordinator.successContext;
    assertEquals(successContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 55 with TrafficTreatment

use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.

the class FlowRuleIntentInstallerTest method createFlowRuleIntentsNonDisruptive.

/**
 * Generates FlowRuleIntents for testing non-disruptive reallocation.
 *
 * @return the FlowRuleIntents for test
 */
public List<Intent> createFlowRuleIntentsNonDisruptive() {
    Map<ConnectPoint, ConnectPoint> portsAssociation = Maps.newHashMap();
    portsAssociation.put(CP1, CP2);
    portsAssociation.put(CP2_1, CP2_2);
    portsAssociation.put(CP4_2, CP4_1);
    List<FlowRule> flowRules = Lists.newArrayList();
    for (ConnectPoint srcPoint : portsAssociation.keySet()) {
        TrafficSelector selector = DefaultTrafficSelector.builder().matchInPhyPort(srcPoint.port()).build();
        TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(portsAssociation.get(srcPoint).port()).build();
        FlowRule flowRule = DefaultFlowRule.builder().forDevice(srcPoint.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
        flowRules.add(flowRule);
    }
    List<NetworkResource> resources = ImmutableList.of(S1_S2, S2_S4);
    FlowRuleIntent intent = new FlowRuleIntent(APP_ID, KEY1, flowRules, resources, PathIntent.ProtectionType.PRIMARY, RG1);
    List<Intent> flowRuleIntents = Lists.newArrayList();
    flowRuleIntents.add(intent);
    return flowRuleIntents;
}
Also used : NetworkResource(org.onosproject.net.NetworkResource) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent)

Aggregations

TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)395 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)369 TrafficSelector (org.onosproject.net.flow.TrafficSelector)257 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)236 FlowRule (org.onosproject.net.flow.FlowRule)93 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)86 PiAction (org.onosproject.net.pi.runtime.PiAction)79 Test (org.junit.Test)78 PortNumber (org.onosproject.net.PortNumber)70 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)56 Instruction (org.onosproject.net.flow.instructions.Instruction)52 DeviceId (org.onosproject.net.DeviceId)46 NextObjective (org.onosproject.net.flowobjective.NextObjective)45 ConnectPoint (org.onosproject.net.ConnectPoint)44 List (java.util.List)43 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)43 Ethernet (org.onlab.packet.Ethernet)40 Criterion (org.onosproject.net.flow.criteria.Criterion)39 GroupBucket (org.onosproject.net.group.GroupBucket)39 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)37