@Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet(); } }
@Override public Set<String> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().keySet().stream() .filter(n -> _namePattern.matcher(n).matches()) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<IpAccessList> resolve(String node, SpecifierContext ctxt) { checkArgument( ctxt.getConfigs().containsKey(node), "SpecifierContext does not have configs for node: " + node); Configuration config = ctxt.getConfigs().get(node); return config.getIpAccessLists().values().stream() .filter(filter -> _shorthandSpecifier.matches(filter, config)) .collect(Collectors.toSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().entrySet().stream() .filter(entry -> _pattern.matcher(entry.getKey()).matches()) .map(Entry::getValue) .flatMap(this::getNodeLocations) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Interface> resolve(Set<String> nodes, SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> nodes.contains(c.getHostname())) .map(c -> c.getAllInterfaces().values()) .flatMap(Collection::stream) .filter(_shorthandSpecifier::matches) .collect(Collectors.toSet()); } }
@Override public Set<Interface> resolve(Set<String> nodes, SpecifierContext ctxt) { return nodes.stream() .map(n -> ctxt.getConfigs().get(n).getVrfs().values()) .flatMap(Collection::stream) // we have a stream of VRFs now .filter(v -> _pattern.matcher(v.getName()).matches()) .map(v -> v.getInterfaces().values()) .flatMap(Collection::stream) .collect(Collectors.toSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getVrfs().values().stream()) .filter(vrf -> _pattern.matcher(vrf.getName()).matches()) .flatMap(this::getVrfLocations) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Interface> resolve(Set<String> nodes, SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .filter(c -> nodes.contains(c.getHostname())) .flatMap(c -> c.getAllInterfaces().values().stream().filter(Interface::getActive)) .filter(i -> i.getAllAddresses().stream().anyMatch(this::interfaceAddressMatchesIpSpace)) .collect(Collectors.toSet()); }
@Override public Set<Interface> resolve(Set<String> nodes, SpecifierContext ctxt) { Map<String, Configuration> configs = ctxt.getConfigs(); return nodes.stream() .map(configs::get) .flatMap(config -> config.getAllInterfaces().values().stream()) .filter(iface -> _interfaceTypes.contains(iface.getInterfaceType())) .collect(ImmutableSet.toImmutableSet()); }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(config -> config.getAllInterfaces().values().stream()) .filter(iface -> _pattern.matcher(iface.getDescription()).matches()) .map(this::getLocation) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getAllInterfaces().values().stream()) .filter(iface -> _pattern.matcher(iface.getName()).matches()) .map(this::getLocation) .collect(ImmutableSet.toImmutableSet()); } }
private Set<Interface> resolve(String node, SpecifierContext ctxt) { Configuration config = ctxt.getConfigs().get(node); Set<String> interfaceNamesInMatchingZones = config.getZones().values().stream() .filter(z -> _pattern.matcher(z.getName()).matches()) .map(z -> z.getInterfaces()) .flatMap(Collection::stream) .collect(Collectors.toSet()); return config.getAllInterfaces().values().stream() .filter(i -> interfaceNamesInMatchingZones.contains(i.getName())) .collect(Collectors.toSet()); } }
private Set<InterfaceAddress> interfaceAddresses(String node, String iface) { return _specifierContext .getConfigs() .get(node) .getAllInterfaces() .get(iface) .getAllAddresses(); }
private String interfaceVrf(String node, String iface) { return _specifierContext .getConfigs() .get(node) .getAllInterfaces() .get(iface) .getVrf() .getName(); } }
@Override public Set<String> resolve(SpecifierContext ctxt) { Optional<NodeRoleDimension> dimension = ctxt.getNodeRoleDimension(_roleDimension); Set<NodeRole> roles = dimension.isPresent() ? dimension.get().getRoles().stream() .filter(role -> _rolePattern.matcher(role.getName()).matches()) .collect(ImmutableSet.toImmutableSet()) : ImmutableSet.of(); return ctxt.getConfigs().keySet().stream() .filter(node -> roles.stream().anyMatch(role -> role.matches(node))) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return _nodeSpecifier.resolve(ctxt).stream() .map(n -> ctxt.getConfigs().get(n).getAllInterfaces().values()) .flatMap(Collection::stream) .map(iface -> new InterfaceLocation(iface.getOwner().getHostname(), iface.getName())) .collect(Collectors.toSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getAllInterfaces().values().stream()) .map(iface -> new InterfaceLinkLocation(iface.getOwner().getHostname(), iface.getName())) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return _interfaceSpecifier.resolve(ctxt.getConfigs().keySet(), ctxt).stream() .map(iface -> new InterfaceLocation(iface.getOwner().getHostname(), iface.getName())) .collect(Collectors.toSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { return ctxt.getConfigs().values().stream() .flatMap(node -> node.getAllInterfaces().values().stream()) .map(iface -> new InterfaceLocation(iface.getOwner().getHostname(), iface.getName())) .collect(ImmutableSet.toImmutableSet()); } }
@Override public Set<Location> resolve(SpecifierContext ctxt) { Optional<NodeRoleDimension> dimension = ctxt.getNodeRoleDimension(_roleDimension); Set<NodeRole> matchingRoles = dimension.isPresent() ? dimension.get().getRoles().stream() .filter(role -> _rolePattern.matcher(role.getName()).matches()) .collect(ImmutableSet.toImmutableSet()) : ImmutableSet.of(); return ctxt.getConfigs().values().stream() .filter(node -> matchingRoles.stream().anyMatch(role -> role.matches(node.getHostname()))) .flatMap(this::getNodeLocations) .collect(ImmutableSet.toImmutableSet()); } }