use of org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig in project trellis-control by opennetworkinglab.
the class PolicyManager method getEdgeDeviceIds.
private List<DeviceId> getEdgeDeviceIds() {
List<DeviceId> edges = new ArrayList<>();
deviceService.getDevices().forEach((device) -> {
DeviceId deviceId = device.id();
SegmentRoutingDeviceConfig srDevCfg = cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
if (srDevCfg != null && srDevCfg.isEdgeRouter()) {
edges.add(deviceId);
}
});
return edges;
}
use of org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig 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.config.SegmentRoutingDeviceConfig in project trellis-control by opennetworkinglab.
the class RouteHandlerTest method setUp.
@Before
public void setUp() {
ObjectMapper mapper = new ObjectMapper();
ConfigApplyDelegate delegate = config -> {
};
SegmentRoutingDeviceConfig dev1Config = new SegmentRoutingDeviceConfig();
JsonNode dev1Tree = mapper.createObjectNode();
dev1Config.init(CP1.deviceId(), "host-handler-test", dev1Tree, mapper, delegate);
dev1Config.setPairDeviceId(CP2.deviceId()).setPairLocalPort(P9);
SegmentRoutingDeviceConfig dev2Config = new SegmentRoutingDeviceConfig();
JsonNode dev2Tree = mapper.createObjectNode();
dev2Config.init(CP2.deviceId(), "host-handler-test", dev2Tree, mapper, delegate);
dev2Config.setPairDeviceId(CP1.deviceId()).setPairLocalPort(P9);
MockNetworkConfigRegistry mockNetworkConfigRegistry = new MockNetworkConfigRegistry();
mockNetworkConfigRegistry.applyConfig(dev1Config);
mockNetworkConfigRegistry.applyConfig(dev2Config);
// Initialize Segment Routing Manager
srManager = new MockSegmentRoutingManager(NEXT_TABLE, ROUTER_MACS);
srManager.storageService = createMock(StorageService.class);
expect(srManager.storageService.consistentMapBuilder()).andReturn(new TestConsistentMap.Builder<>()).anyTimes();
expect(srManager.storageService.consistentMultimapBuilder()).andReturn(new TestConsistentMultimap.Builder<>()).anyTimes();
replay(srManager.storageService);
srManager.cfgService = new NetworkConfigRegistryAdapter();
srManager.deviceConfiguration = createMock(DeviceConfiguration.class);
srManager.flowObjectiveService = new MockFlowObjectiveService(BRIDGING_TABLE, NEXT_TABLE);
srManager.routingRulePopulator = new MockRoutingRulePopulator(srManager, ROUTING_TABLE);
srManager.defaultRoutingHandler = new MockDefaultRoutingHandler(srManager, SUBNET_TABLE, ROUTING_TABLE, LED_DEVICES);
srManager.interfaceService = new MockInterfaceService(INTERFACES);
hostService = new MockHostService(HOSTS);
srManager.hostService = hostService;
srManager.cfgService = mockNetworkConfigRegistry;
srManager.routeService = new MockRouteService(ROUTE_STORE);
srManager.phasedRecoveryService = createMock(PhasedRecoveryService.class);
expect(srManager.phasedRecoveryService.isEnabled()).andReturn(true).anyTimes();
replay(srManager.phasedRecoveryService);
routeHandler = new RouteHandler(srManager);
ROUTING_TABLE.clear();
BRIDGING_TABLE.clear();
SUBNET_TABLE.clear();
}
use of org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig in project fabric-tna by stratum.
the class FabricIntProgrammable method getSidForCollector.
/**
* Gets the SID of the device which collector attached to.
* TODO: remove this method once we get SR API done.
*
* @param collectorIp the IP address of the INT collector
* @return the SID of the device, Optional.empty() if we cannot find the SID of
* the device
*/
private Optional<Integer> getSidForCollector(IpAddress collectorIp) {
Set<Host> collectorHosts = hostService.getHostsByIp(collectorIp);
if (collectorHosts.isEmpty()) {
log.warn("Unable to find collector with IP {}, skip for now.", collectorIp);
return Optional.empty();
}
Host collector = collectorHosts.iterator().next();
if (collectorHosts.size() > 1) {
log.warn("Find more than one host with IP {}, will use {} as collector.", collectorIp, collector.id());
}
Set<HostLocation> locations = collector.locations();
if (locations.isEmpty()) {
log.warn("Unable to find the location of collector {}, skip for now.", collector.id());
return Optional.empty();
}
HostLocation location = locations.iterator().next();
if (locations.size() > 1) {
// TODO: revisit this when we want to support dual-homed INT collector.
log.warn("Find more than one location for host {}, will use {}", collector.id(), location);
}
DeviceId deviceWithCollector = location.deviceId();
SegmentRoutingDeviceConfig cfg = cfgService.getConfig(deviceWithCollector, SegmentRoutingDeviceConfig.class);
if (cfg == null) {
log.error("Missing SegmentRoutingDeviceConfig config for {}, " + "cannot derive SID for collector", deviceWithCollector);
return Optional.empty();
}
if (cfg.nodeSidIPv4() == -1) {
log.error("Missing ipv4NodeSid in segment routing config for device {}", deviceWithCollector);
return Optional.empty();
}
return Optional.of(cfg.nodeSidIPv4());
}
Aggregations