use of org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint in project trellis-control by opennetworkinglab.
the class XconnectManager method getPhysicalPorts.
private Set<PortNumber> getPhysicalPorts(DeviceId deviceId, XconnectEndpoint endpoint) {
if (endpoint.type() == XconnectEndpoint.Type.PORT) {
PortNumber port = ((XconnectPortEndpoint) endpoint).port();
return Sets.newHashSet(port);
}
if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, ((XconnectLoadBalancerEndpoint) endpoint).key());
Set<PortNumber> ports = portLoadBalancerService.getPortLoadBalancer(portLoadBalancerId).ports();
return Sets.newHashSet(ports);
}
return Sets.newHashSet();
}
use of org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint in project trellis-control by opennetworkinglab.
the class XconnectManager method getNextTreatment.
private NextTreatment getNextTreatment(DeviceId deviceId, XconnectEndpoint endpoint, boolean reserve) {
if (endpoint.type() == XconnectEndpoint.Type.PORT) {
PortNumber port = ((XconnectPortEndpoint) endpoint).port();
return DefaultNextTreatment.of(DefaultTrafficTreatment.builder().setOutput(port).build());
}
if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, ((XconnectLoadBalancerEndpoint) endpoint).key());
NextTreatment idNextTreatment = IdNextTreatment.of(portLoadBalancerService.getPortLoadBalancerNext(portLoadBalancerId));
// Reserve only one time during next objective creation
if (reserve) {
if (!portLoadBalancerService.reserve(portLoadBalancerId, appId)) {
log.warn("Reservation failed for {}", portLoadBalancerId);
idNextTreatment = null;
}
}
return idNextTreatment;
}
return null;
}
use of org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint 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);
}
Aggregations