Search in sources :

Example 1 with XconnectPortEndpoint

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();
}
Also used : XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) PortNumber(org.onosproject.net.PortNumber)

Example 2 with XconnectPortEndpoint

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;
}
Also used : XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) PortNumber(org.onosproject.net.PortNumber) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) IdNextTreatment(org.onosproject.net.flowobjective.IdNextTreatment)

Example 3 with XconnectPortEndpoint

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);
}
Also used : SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) XconnectEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint) PortNumber(org.onosproject.net.PortNumber) XconnectKey(org.onosproject.segmentrouting.xconnect.api.XconnectKey)

Aggregations

PortNumber (org.onosproject.net.PortNumber)3 XconnectPortEndpoint (org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint)3 PortLoadBalancerId (org.onosproject.portloadbalancer.api.PortLoadBalancerId)2 DefaultNextTreatment (org.onosproject.net.flowobjective.DefaultNextTreatment)1 IdNextTreatment (org.onosproject.net.flowobjective.IdNextTreatment)1 NextTreatment (org.onosproject.net.flowobjective.NextTreatment)1 SegmentRoutingDeviceConfig (org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig)1 XconnectEndpoint (org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint)1 XconnectKey (org.onosproject.segmentrouting.xconnect.api.XconnectKey)1