private void unsetRoutes(OpenstackRouter osRouter, OpenstackSubnet osSubNet) { Set<OpenstackSubnet> routableSubNets = routableSubNets(osRouter.id()); Tools.stream(hostService.getHosts()) .filter(h -> Objects.equals(h.annotations().value(NETWORK_ID), osSubNet.id())) .forEach(h -> removeRoutingRules(h, routableSubNets)); routableSubNets.forEach( n -> { Tools.stream(hostService.getHosts()) .filter(h -> Objects.equals(h.annotations().value(SUBNET_ID), n.id())) .forEach(h -> removeRoutingRules(h, ImmutableSet.of(osSubNet))); log.debug("Removed between {} to {}", n.name(), osSubNet.name()); }); }
private void setRoutes(OpenstackRouter osRouter, Optional<Host> host) { Set<OpenstackSubnet> routableSubNets = routableSubNets(osRouter.id()); if (routableSubNets.size() < 2) { // no other subnet interface is connected to this router, do nothing return; } Set<String> routableSubNetIds = routableSubNets.stream().map(OpenstackSubnet::id).collect(Collectors.toSet()); Set<Host> hosts = host.isPresent() ? ImmutableSet.of(host.get()) : Tools.stream(hostService.getHosts()) .filter(h -> routableSubNetIds.contains(h.annotations().value(SUBNET_ID))) .collect(Collectors.toSet()); hosts.forEach(h -> populateRoutingRules(h, routableSubNets)); }