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