use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.
the class XconnectManager method revokeFilter.
/**
* Revokes filtering objectives for given XConnect.
*
* @param key XConnect store key
* @param endpoints XConnect endpoints
*/
private void revokeFilter(XconnectKey key, Set<XconnectEndpoint> endpoints) {
// FIXME Improve the logic
// If port load balancer is not involved, use filtered port. Otherwise, use unfiltered port.
// The purpose is to make sure existing XConnect logic can still work on a configured port.
boolean filtered = endpoints.stream().map(ep -> getNextTreatment(key.deviceId(), ep, false)).allMatch(t -> t.type().equals(NextTreatment.Type.TREATMENT));
endpoints.stream().map(ep -> getPhysicalPorts(key.deviceId(), ep)).flatMap(Set::stream).forEach(port -> {
FilteringObjective.Builder filtObjBuilder = filterObjBuilder(key, port, filtered);
ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("XConnect FilterObj for {} on port {} revoked", key, port), (objective, error) -> log.warn("Failed to revoke XConnect FilterObj for {} on port {}: {}", key, port, error));
flowObjectiveService.filter(key.deviceId(), filtObjBuilder.remove(context));
});
}
use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.
the class XconnectManager method updateL2Flooding.
/**
* Updates L2 flooding groups; add pair link into L2 flooding group of given xconnect vlan.
*
* @param deviceId Device ID
* @param port Port details
* @param vlanId VLAN ID
* @param install Whether to add or revoke pair link addition to flooding group
*/
private void updateL2Flooding(DeviceId deviceId, PortNumber port, VlanId vlanId, boolean install) {
XconnectKey key = new XconnectKey(deviceId, vlanId);
// Ensure leadership on device
if (!srService.shouldProgram(deviceId)) {
log.debug("Abort updating L2Flood {}: {}", key, ERROR_NOT_LEADER);
return;
}
// Locate L2 flooding group details for given xconnect vlan
int nextId = Versioned.valueOrElse(xconnectNextObjStore.get(key), -1);
if (nextId == -1) {
log.debug("XConnect vlan {} broadcast group for device {} doesn't exists. " + "Aborting pair group linking.", vlanId, deviceId);
return;
}
// Add pairing-port group to flooding group
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
// treatment.popVlan();
treatment.setOutput(port);
ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("Pair port added/removed to vlan {} next objective {} on {}", vlanId, nextId, deviceId), (objective, error) -> log.warn("Failed adding/removing pair port to vlan {} next objective {} on {}." + "Error : {}", vlanId, nextId, deviceId, error));
NextObjective.Builder vlanNextObjectiveBuilder = DefaultNextObjective.builder().withId(nextId).withType(NextObjective.Type.BROADCAST).fromApp(srService.appId()).withMeta(DefaultTrafficSelector.builder().matchVlanId(vlanId).build()).addTreatment(treatment.build());
if (install) {
flowObjectiveService.next(deviceId, vlanNextObjectiveBuilder.addToExisting(context));
} else {
flowObjectiveService.next(deviceId, vlanNextObjectiveBuilder.removeFromExisting(context));
}
log.debug("Submitted next objective {} for vlan: {} in device {}", nextId, vlanId, deviceId);
}
use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.
the class XconnectManager method addOrUpdateXconnect.
@Override
public void addOrUpdateXconnect(DeviceId deviceId, VlanId vlanId, Set<XconnectEndpoint> endpoints) {
log.info("Adding or updating xconnect. deviceId={}, vlanId={}, endpoints={}", deviceId, vlanId, endpoints);
SegmentRoutingDeviceConfig config = cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
List<PortNumber> devicePorts = deviceService.getPorts(deviceId).stream().map(Port::number).collect(Collectors.toList());
if (!config.isEdgeRouter()) {
throw new IllegalArgumentException(ERROR_NOT_EDGE_ROUTER);
} else {
Iterator<XconnectEndpoint> itr = endpoints.iterator();
while (itr.hasNext()) {
XconnectEndpoint ep = itr.next();
// Note: we don't validate an endpoint with LOAD_BALANCER type
if (ep.type() != XconnectEndpoint.Type.PORT) {
continue;
}
if (!devicePorts.contains(((XconnectPortEndpoint) ep).port())) {
throw new IllegalArgumentException(ERROR_PORT_NOT_RANGE);
}
}
}
final XconnectKey key = new XconnectKey(deviceId, vlanId);
xconnectStore.put(key, endpoints);
}
use of org.onosproject.segmentrouting.xconnect.api.XconnectKey in project trellis-control by opennetworkinglab.
the class XconnectManager method dequeue.
// Invalidate the cache and re-start the xconnect installation
private void dequeue(PortLoadBalancerId portLoadBalancerId) {
XconnectKey xconnectKey = portLoadBalancerCache.getIfPresent(portLoadBalancerId);
if (xconnectKey == null) {
log.trace("{} not present in the cache", portLoadBalancerId);
return;
}
log.debug("Dequeue {}", portLoadBalancerId);
portLoadBalancerCache.invalidate(portLoadBalancerId);
Set<XconnectEndpoint> endpoints = Versioned.valueOrNull(xconnectStore.get(xconnectKey));
if (endpoints == null || endpoints.isEmpty()) {
log.warn("Endpoints not found for XConnect {}", xconnectKey);
return;
}
populateXConnect(xconnectKey, endpoints);
log.trace("PortLoadBalancer cache size {}", portLoadBalancerCache.size());
}
Aggregations