Search in sources :

Example 51 with MultiPointToSinglePointIntent

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

the class ConnectivityManager method setUpL2.

@Override
public void setUpL2(Peer peer) {
    if (!castorStore.getLayer2Intents().isEmpty()) {
        updateExistingL2Intents(peer);
    }
    Set<FilteredConnectPoint> ingressPorts = new HashSet<>();
    ConnectPoint egressPort = ConnectPoint.deviceConnectPoint(peer.getPort());
    for (Peer inPeer : castorStore.getAllPeers()) {
        if (!inPeer.getName().equals(peer.getName())) {
            ingressPorts.add(new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(inPeer.getPort())));
        }
    }
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    MacAddress macAddress = castorStore.getAddressMap().get(IpAddress.valueOf(peer.getIpAddress()));
    selector.matchEthDst(macAddress);
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    Key key = Key.of(peer.getIpAddress(), appId);
    MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector.build()).treatment(treatment).filteredIngressPoints(ingressPorts).filteredEgressPoint(new FilteredConnectPoint(egressPort)).priority(FLOW_PRIORITY).build();
    intentSynchronizer.submit(intent);
    castorStore.storeLayer2Intent(peer.getIpAddress(), intent);
    castorStore.removeCustomer(peer);
    peer.setL2(true);
    castorStore.storeCustomer(peer);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MacAddress(org.onlab.packet.MacAddress) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 52 with MultiPointToSinglePointIntent

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

the class ConnectivityManager method updateL2AfterDeletion.

/**
 * Updates all the layer 2 flows after successful deletion of a Peer.
 * The Peer being deleted is removed from the ingress points of all
 * other flows.
 *
 * @param peer The Peer being deleted.
 */
private void updateL2AfterDeletion(Peer peer) {
    Collection<MultiPointToSinglePointIntent> oldIntents = castorStore.getLayer2Intents().values();
    Map<String, MultiPointToSinglePointIntent> intents = new HashMap<>();
    for (MultiPointToSinglePointIntent oldIntent : oldIntents) {
        Set<FilteredConnectPoint> ingressPoints = oldIntent.filteredIngressPoints();
        FilteredConnectPoint egressPoint = oldIntent.filteredEgressPoint();
        if (ingressPoints.remove(new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(peer.getPort())))) {
            MultiPointToSinglePointIntent updatedMp2pIntent = MultiPointToSinglePointIntent.builder().appId(appId).key(oldIntent.key()).selector(oldIntent.selector()).treatment(oldIntent.treatment()).filteredIngressPoints(ingressPoints).filteredEgressPoint(egressPoint).priority(oldIntent.priority()).build();
            intents.put(peer.getIpAddress(), updatedMp2pIntent);
            intentSynchronizer.submit(updatedMp2pIntent);
        }
    }
    for (String key : intents.keySet()) {
        castorStore.storeLayer2Intent(key, intents.get(key));
    }
}
Also used : HashMap(java.util.HashMap) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) 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