@Test public void testResolveLocalIpFromUpdateSource_Null() { Warnings warnings = new Warnings(false, true, false); NetworkFactory nf = new NetworkFactory(); Configuration c = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CUMULUS_NCLU).build(); assertNull(resolveLocalIpFromUpdateSource(null, c, warnings)); }
@Nullable @VisibleForTesting static Ip resolveLocalIpFromUpdateSource( @Nullable BgpNeighborSource source, Configuration c, Warnings warnings) { if (source == null) { return null; } BgpNeighborSourceVisitor<Ip> visitor = new BgpNeighborSourceVisitor<Ip>() { @Override public Ip visitBgpNeighborSourceAddress(BgpNeighborSourceAddress updateSourceAddress) { return updateSourceAddress.getAddress(); } @Nullable @Override public Ip visitBgpNeighborSourceInterface( BgpNeighborSourceInterface updateSourceInterface) { org.batfish.datamodel.Interface iface = c.getAllInterfaces().get(updateSourceInterface.getInterface()); if (iface == null) { warnings.redFlag( String.format( "cannot find interface named %s for update-source", updateSourceInterface.getInterface())); return null; } ConcreteInterfaceAddress concreteAddress = iface.getConcreteAddress(); if (concreteAddress == null) { warnings.redFlag( String.format( "cannot find an address for interface named %s for update-source", updateSourceInterface.getInterface())); return null; } return iface.getConcreteAddress().getIp(); } }; return source.accept(visitor); }
CumulusConversions { @Nullable @VisibleForTesting static Ip resolveLocalIpFromUpdateSource( @Nullable BgpNeighborSource source, Configuration c, Warnings warnings) { if (source == null) { return null; } BgpNeighborSourceVisitor<Ip> visitor = new BgpNeighborSourceVisitor<Ip>() { @Override public Ip visitBgpNeighborSourceAddress(BgpNeighborSourceAddress updateSourceAddress) { return updateSourceAddress.getAddress(); } @Nullable @Override public Ip visitBgpNeighborSourceInterface( BgpNeighborSourceInterface updateSourceInterface) { org.batfish.datamodel.Interface iface = c.getAllInterfaces().get(updateSourceInterface.getInterface()); if (iface == null) { warnings.redFlag( String.format( "cannot find interface named %s for update-source", updateSourceInterface.getInterface())); return null; } ConcreteInterfaceAddress concreteAddress = iface.getConcreteAddress(); if (concreteAddress == null) { warnings.redFlag( String.format( "cannot find an address for interface named %s for update-source", updateSourceInterface.getInterface())); return null; } return iface.getConcreteAddress().getIp(); } }; return source.accept(visitor); } }
CumulusConversions { @Nullable @VisibleForTesting static Ip resolveLocalIpFromUpdateSource( @Nullable BgpNeighborSource source, Configuration c, Warnings warnings) { if (source == null) { return null; } BgpNeighborSourceVisitor<Ip> visitor = new BgpNeighborSourceVisitor<Ip>() { @Override public Ip visitBgpNeighborSourceAddress(BgpNeighborSourceAddress updateSourceAddress) { return updateSourceAddress.getAddress(); } @Nullable @Override public Ip visitBgpNeighborSourceInterface( BgpNeighborSourceInterface updateSourceInterface) { org.batfish.datamodel.Interface iface = c.getAllInterfaces().get(updateSourceInterface.getInterface()); if (iface == null) { warnings.redFlag( String.format( "cannot find interface named %s for update-source", updateSourceInterface.getInterface())); return null; } ConcreteInterfaceAddress concreteAddress = iface.getConcreteAddress(); if (concreteAddress == null) { warnings.redFlag( String.format( "cannot find an address for interface named %s for update-source", updateSourceInterface.getInterface())); return null; } return iface.getConcreteAddress().getIp(); } }; return source.accept(visitor); }  }
CumulusConversions { @Nullable @VisibleForTesting static Ip resolveLocalIpFromUpdateSource( @Nullable BgpNeighborSource source, Configuration c, Warnings warnings) { if (source == null) { return null; } BgpNeighborSourceVisitor<Ip> visitor = new BgpNeighborSourceVisitor<Ip>() { @Override public Ip visitBgpNeighborSourceAddress(BgpNeighborSourceAddress updateSourceAddress) { return updateSourceAddress.getAddress(); } @Nullable @Override public Ip visitBgpNeighborSourceInterface( BgpNeighborSourceInterface updateSourceInterface) { org.batfish.datamodel.Interface iface = c.getAllInterfaces().get(updateSourceInterface.getInterface()); if (iface == null) { warnings.redFlag( String.format( "cannot find interface named %s for update-source", updateSourceInterface.getInterface())); return null; } ConcreteInterfaceAddress concreteAddress = iface.getConcreteAddress(); if (concreteAddress == null) { warnings.redFlag( String.format( "cannot find an address for interface named %s for update-source", updateSourceInterface.getInterface())); return null; } return iface.getConcreteAddress().getIp(); } }; return source.accept(visitor); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); }
CumulusConversions { @Nullable @VisibleForTesting static Ip resolveLocalIpFromUpdateSource( @Nullable BgpNeighborSource source, Configuration c, Warnings warnings) { if (source == null) { return null; } BgpNeighborSourceVisitor<Ip> visitor = new BgpNeighborSourceVisitor<Ip>() { @Override public Ip visitBgpNeighborSourceAddress(BgpNeighborSourceAddress updateSourceAddress) { return updateSourceAddress.getAddress(); } @Nullable @Override public Ip visitBgpNeighborSourceInterface( BgpNeighborSourceInterface updateSourceInterface) { org.batfish.datamodel.Interface iface = c.getAllInterfaces().get(updateSourceInterface.getInterface()); if (iface == null) { warnings.redFlag( String.format( "cannot find interface named %s for update-source", updateSourceInterface.getInterface())); return null; } ConcreteInterfaceAddress concreteAddress = iface.getConcreteAddress(); if (concreteAddress == null) { warnings.redFlag( String.format( "cannot find an address for interface named %s for update-source", updateSourceInterface.getInterface())); return null; } return iface.getConcreteAddress().getIp(); } }; return source.accept(visitor); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); static final int DEFAULT_STATIC_ROUTE_ADMINISTRATIVE_DISTANCE; static final int DEFAULT_STATIC_ROUTE_METRIC; static final Ip CLAG_LINK_LOCAL_IP; static final long DEFAULT_MAX_MED; static final double SPEED_CONVERSION_FACTOR; static final double DEFAULT_LOOPBACK_BANDWIDTH; static final double DEFAULT_PORT_BANDWIDTH; }