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