@Test public void testGetIps() { String nodeName = "nodeName"; String int1 = "int1"; String int2 = "int2"; String ip1 = "10.1.3.7"; String ip2 = "128.212.155.30"; String ip3 = "124.51.32.2"; String address1 = ip1 + "/30"; String address2 = ip2 + "/24"; String address3 = ip3 + "/20"; InterfaceAddress interfaceAddress1 = new InterfaceAddress(address1); InterfaceAddress interfaceAddress2 = new InterfaceAddress(address2); InterfaceAddress interfaceAddress3 = new InterfaceAddress(address3); Map<String, Configuration> configs = new HashMap<>(); Configuration config = createTestConfiguration(nodeName, ConfigurationFormat.HOST, int1, int2); config .getAllInterfaces() .get(int1) .setAllAddresses(ImmutableSet.of(interfaceAddress1, interfaceAddress2)); config .getAllInterfaces() .get(int2) .setAllAddresses(ImmutableSet.of(interfaceAddress2, interfaceAddress3)); configs.put(nodeName, config); assertThat(getIps(configs), equalTo(ImmutableSet.of(ip1, ip2, ip3))); }
@Test public void testGetPrefixes() { String nodeName = "nodeName"; String int1 = "int1"; String int2 = "int2"; String address1 = "10.1.3.7/30"; String address2 = "128.212.155.30/24"; String address3 = "124.51.32.2/20"; InterfaceAddress interfaceAddress1 = new InterfaceAddress(address1); InterfaceAddress interfaceAddress2 = new InterfaceAddress(address2); InterfaceAddress interfaceAddress3 = new InterfaceAddress(address3); Map<String, Configuration> configs = new HashMap<>(); Configuration config = createTestConfiguration(nodeName, ConfigurationFormat.HOST, int1, int2); config .getAllInterfaces() .get(int1) .setAllAddresses(ImmutableSet.of(interfaceAddress1, interfaceAddress2)); config .getAllInterfaces() .get(int2) .setAllAddresses(ImmutableSet.of(interfaceAddress2, interfaceAddress3)); configs.put(nodeName, config); assertThat( getPrefixes(configs), equalTo( ImmutableSet.of( interfaceAddress1.getPrefix().toString(), interfaceAddress2.getPrefix().toString(), interfaceAddress3.getPrefix().toString()))); }
iface.setAllAddresses(ifaceAddresses);
newIface.setAddress(iface.getPrimaryAddress()); newIface.setAllAddresses(iface.getAllAddresses()); newIface.setActive(iface.getActive()); if (iface.getSwitchportMode() == SwitchportMode.ACCESS && iface.getAccessVlan() != null) {
iface.setAllAddresses(allAddresses.addAll(_secondaryAddresses).build()); iface.setBandwidth(_bandwidth); iface.setBlacklisted(_blacklisted);
private static Configuration createConfigurationWithDynamicSession( Configuration.Builder cb, Ip localIp, Prefix remotePrefix, List<Long> remoteAsList) { Configuration node = cb.setHostname("node4").build(); Interface iface = new Interface("iface", node, InterfaceType.PHYSICAL); iface.setAllAddresses( ImmutableList.of(new InterfaceAddress(localIp, Ip.numSubnetBitsToSubnetMask(32)))); BgpPassivePeerConfig peerConfig = BgpPassivePeerConfig.builder() .setLocalAs(3L) .setRemoteAs(remoteAsList) .setLocalIp(localIp) .setPeerPrefix(remotePrefix) .build(); BgpProcess bgpProcess = new BgpProcess(); bgpProcess.setPassiveNeighbors(ImmutableSortedMap.of(remotePrefix, peerConfig)); Vrf vrf1 = new Vrf("vrf"); vrf1.setBgpProcess(bgpProcess); node.setVrfs(ImmutableMap.of("vrf", vrf1)); node.setInterfaces(ImmutableSortedMap.of("iface", iface)); return node; }
newIface.setAllAddresses(allPrefixes.build());
private static Configuration createConfiguration( Configuration.Builder cb, String nodeName, Ip localIp, Ip remoteIp, Long localAs, Long remoteAs) { Configuration node = cb.setHostname(nodeName).build(); Interface iface = new Interface("iface", node, InterfaceType.PHYSICAL); iface.setAllAddresses( ImmutableList.of(new InterfaceAddress(localIp, Ip.numSubnetBitsToSubnetMask(32)))); BgpActivePeerConfig peerConfig = BgpActivePeerConfig.builder() .setLocalAs(localAs) .setRemoteAs(remoteAs) .setLocalIp(localIp) .setPeerAddress(remoteIp) .build(); BgpProcess bgpProcess = new BgpProcess(); bgpProcess.setNeighbors(ImmutableSortedMap.of(Prefix.create(remoteIp, 32), peerConfig)); Vrf vrf1 = new Vrf("vrf"); vrf1.setBgpProcess(bgpProcess); node.setVrfs(ImmutableMap.of("vrf", vrf1)); node.setInterfaces(ImmutableSortedMap.of("iface", iface)); return node; }
newIface.setAllAddresses(iface.getAllAddresses()); newIface.setActive(iface.getActive()); newIface.setDescription(iface.getComment());