use of org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig in project TFG by mattinelorza.
the class Srv6SidCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
NetworkConfigService netCfgService = AbstractShellCommand.get(NetworkConfigService.class);
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
SortedSet<String> strings = delegate.getStrings();
stream(deviceService.getDevices()).map(d -> netCfgService.getConfig(d.id(), FabricDeviceConfig.class)).filter(Objects::nonNull).map(FabricDeviceConfig::mySid).filter(Objects::nonNull).forEach(sid -> strings.add(sid.toString()));
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig in project TFG by mattinelorza.
the class NdpReplyComponent method setUpDevice.
/**
* Performs setup of the given device by creating a flow rule to generate
* NDP NA packets for IPv6 addresses associated to the device interfaces.
*
* @param deviceId device ID
*/
private void setUpDevice(DeviceId deviceId) {
// Get this device config from netcfg.json.
final FabricDeviceConfig config = configService.getConfig(deviceId, FabricDeviceConfig.class);
if (config == null) {
// Config not available yet
throw new ItemNotFoundException("Missing fabricDeviceConfig for " + deviceId);
}
// Get this device myStation mac.
final MacAddress deviceMac = config.myStationMac();
// Get all interfaces currently configured for the device
final Collection<Interface> interfaces = interfaceService.getInterfaces().stream().filter(iface -> iface.connectPoint().deviceId().equals(deviceId)).collect(Collectors.toSet());
if (interfaces.isEmpty()) {
log.info("{} does not have any IPv6 interface configured", deviceId);
return;
}
// Generate and install flow rules.
log.info("Adding rules to {} to generate NDP NA for {} IPv6 interfaces...", deviceId, interfaces.size());
final Collection<FlowRule> flowRules = interfaces.stream().map(this::getIp6Addresses).flatMap(Collection::stream).map(ipv6addr -> buildNdpReplyFlowRule(deviceId, ipv6addr, deviceMac)).collect(Collectors.toSet());
installRules(flowRules);
}
Aggregations