Search in sources :

Example 21 with MultiPointToSinglePointIntent

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

the class SdnIpFibTest method testRemoveIngressInterface.

/**
 * Tests removing an existing interface.
 *
 * We first push an intent with destination sw3 and source sw1 and sw2. We
 * then remove the ingress interface on sw1.
 *
 * We verify that the synchronizer records the correct state and that the
 * correct intent is withdrawn from the IntentService.
 */
@Test
public void testRemoveIngressInterface() {
    // Add a route first
    testRouteAddToNoVlan();
    // Create the new expected intent
    MultiPointToSinglePointIntent remainingIntent = createIntentToThreeSrcTwo(PREFIX1);
    reset(intentSynchronizer);
    intentSynchronizer.submit(eqExceptId(remainingIntent));
    expectLastCall().once();
    replay(intentSynchronizer);
    // Define the existing ingress interface and remove it
    Interface intf = new Interface("sw1-eth1", SW1_ETH1, Collections.singletonList(IIP1), MAC1, VLAN10);
    InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
    interfaceListener.event(intfEvent);
    verify(intentSynchronizer);
}
Also used : InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 22 with MultiPointToSinglePointIntent

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

the class SdnIpFibTest method testRouteDelete.

/**
 * Tests deleting a route.
 *
 * We verify that the synchronizer records the correct state and that the
 * correct intent is withdrawn from the IntentService.
 */
@Test
public void testRouteDelete() {
    // Add a route first
    testRouteAddToNoVlan();
    // Construct the existing route entry
    ResolvedRoute route = createRoute(PREFIX1, IP3, MAC3);
    // Create existing intent
    MultiPointToSinglePointIntent removedIntent = createIntentToThreeSrcOneTwo(PREFIX1);
    // Set up expectation
    reset(intentSynchronizer);
    // Setup the expected intents
    intentSynchronizer.withdraw(eqExceptId(removedIntent));
    replay(intentSynchronizer);
    // Send in the removed event
    routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_REMOVED, route));
    verify(intentSynchronizer);
}
Also used : RouteEvent(org.onosproject.routeservice.RouteEvent) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 23 with MultiPointToSinglePointIntent

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

the class SdnIpFibTest method createIntentToThreeSrcOneTwoFour.

/*
     * Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
     * sw1, sw2, sw4.
     */
private MultiPointToSinglePointIntent createIntentToThreeSrcOneTwoFour(IpPrefix ipPrefix) {
    // Build the expected treatment
    TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    treatmentBuilder.setEthDst(MAC3);
    // Build the expected egress FilteredConnectPoint
    FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
    // Build the expected selectors
    Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
    // Build the expected ingress FilteredConnectPoint for sw1
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchVlanId(VLAN10);
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchIPDst(ipPrefix);
    FilteredConnectPoint ingressFilteredCP = new FilteredConnectPoint(SW1_ETH1, selector.build());
    ingressFilteredCPs.add(ingressFilteredCP);
    // Build the expected ingress FilteredConnectPoint for sw2
    selector = DefaultTrafficSelector.builder();
    selector.matchVlanId(VLAN20);
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchIPDst(ipPrefix);
    ingressFilteredCP = new FilteredConnectPoint(SW2_ETH1, selector.build());
    ingressFilteredCPs.add(ingressFilteredCP);
    // Build the expected ingress FilteredConnectPoint for sw4
    selector = DefaultTrafficSelector.builder();
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchIPDst(ipPrefix);
    ingressFilteredCP = new FilteredConnectPoint(SW4_ETH1, selector.build());
    ingressFilteredCPs.add(ingressFilteredCP);
    // Build the expected intent
    MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder().appId(APPID).key(Key.of(ipPrefix.toString(), APPID)).filteredIngressPoints(ingressFilteredCPs).filteredEgressPoint(egressFilteredCP).treatment(treatmentBuilder.build()).constraints(SdnIpFib.CONSTRAINTS).build();
    return intent;
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 24 with MultiPointToSinglePointIntent

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

the class SdnIpFibTest method createIntentToThreeSrcTwo.

/*
     * Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
     * sw2.
     */
private MultiPointToSinglePointIntent createIntentToThreeSrcTwo(IpPrefix ipPrefix) {
    // Build the expected treatment
    TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    treatmentBuilder.setEthDst(MAC3);
    // Build the expected egress FilteredConnectPoint
    FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
    // Build the expected ingress FilteredConnectPoint for sw2
    Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchVlanId(VLAN20);
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchIPDst(ipPrefix);
    FilteredConnectPoint ingressFilteredCP = new FilteredConnectPoint(SW2_ETH1, selector.build());
    ingressFilteredCPs.add(ingressFilteredCP);
    // Build the expected intent
    MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder().appId(APPID).key(Key.of(ipPrefix.toString(), APPID)).filteredIngressPoints(ingressFilteredCPs).filteredEgressPoint(egressFilteredCP).treatment(treatmentBuilder.build()).constraints(SdnIpFib.CONSTRAINTS).build();
    return intent;
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 25 with MultiPointToSinglePointIntent

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

the class ConnectivityManager method updateExistingL2Intents.

/**
 * Updates the existing layer 2 flows. Whenever a new Peer is added, it is also
 * added as the ingress point to the existing layer two flows.
 *
 * @param peer The Peer being added.
 */
private void updateExistingL2Intents(Peer peer) {
    Collection<MultiPointToSinglePointIntent> oldIntents = castorStore.getLayer2Intents().values();
    for (MultiPointToSinglePointIntent oldIntent : oldIntents) {
        Set<FilteredConnectPoint> ingressPoints = oldIntent.filteredIngressPoints();
        ConnectPoint egressPoint = oldIntent.egressPoint();
        if (ingressPoints.add(new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(peer.getPort())))) {
            MultiPointToSinglePointIntent updatedMp2pIntent = MultiPointToSinglePointIntent.builder().appId(appId).key(oldIntent.key()).selector(oldIntent.selector()).treatment(oldIntent.treatment()).filteredIngressPoints(ingressPoints).filteredEgressPoint(new FilteredConnectPoint(egressPoint)).priority(oldIntent.priority()).build();
            // layer2Intents.put(peer.getIpAddress(), updatedMp2pIntent);
            castorStore.storeLayer2Intent(peer.getIpAddress(), updatedMp2pIntent);
            intentSynchronizer.submit(updatedMp2pIntent);
        }
    }
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)52 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)31 ConnectPoint (org.onosproject.net.ConnectPoint)25 Test (org.junit.Test)21 TrafficSelector (org.onosproject.net.flow.TrafficSelector)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)20 Intent (org.onosproject.net.intent.Intent)16 Key (org.onosproject.net.intent.Key)14 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)11 HashSet (java.util.HashSet)10 Constraint (org.onosproject.net.intent.Constraint)9 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)9 Interface (org.onosproject.net.intf.Interface)9 Map (java.util.Map)8 IpPrefix (org.onlab.packet.IpPrefix)8 MacAddress (org.onlab.packet.MacAddress)8 ResolvedRoute (org.onosproject.routeservice.ResolvedRoute)6