Search in sources :

Example 16 with FlowObjectiveIntent

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

the class FlowObjectiveIntentInstallerTest method createAnotherFlowObjectiveIntents.

/**
 * Creates flow objective Intents with different selector.
 *
 * @return the flow objective Intents
 */
private List<Intent> createAnotherFlowObjectiveIntents() {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).matchInPort(CP1.port()).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(CP2.port()).build();
    FilteringObjective filt = DefaultFilteringObjective.builder().addCondition(selector.getCriterion(Criterion.Type.IN_PORT)).addCondition(selector.getCriterion(Criterion.Type.VLAN_VID)).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 17 with FlowObjectiveIntent

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

the class FlowObjectiveIntentInstallerTest method testUninstallIntent.

/**
 * Uninstalls flow objective Intents.
 */
@Test
public void testUninstallIntent() {
    List<Intent> intentsToUninstall = createFlowObjectiveIntents();
    List<Intent> intentsToInstall = Lists.newArrayList();
    IntentData toInstall = null;
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.WITHDRAWING, new WallClockTimestamp());
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    IntentOperationContext<FlowObjectiveIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    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) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Aggregations

FlowObjectiveIntent (org.onosproject.net.intent.FlowObjectiveIntent)17 Intent (org.onosproject.net.intent.Intent)14 Test (org.junit.Test)11 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)11 NextObjective (org.onosproject.net.flowobjective.NextObjective)11 Objective (org.onosproject.net.flowobjective.Objective)11 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)9 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)9 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)9 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)8 Link (org.onosproject.net.Link)7 DefaultLink (org.onosproject.net.DefaultLink)6 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)6 DeviceId (org.onosproject.net.DeviceId)5 IntentData (org.onosproject.net.intent.IntentData)5 IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)4 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)4