@Test public void testToOspfProcess_ConfigedRouterId() { OspfVrf ospfVrf = new OspfVrf(DEFAULT_VRF_NAME); ospfVrf.setRouterId(Ip.parse("1.2.3.4")); CumulusNcluConfiguration vsConfig = new CumulusNcluConfiguration(); OspfProcess vsOspf = new OspfProcess(); vsConfig.setOspfProcess(vsOspf); org.batfish.datamodel.ospf.OspfProcess ospfProcess = toOspfProcess( new Configuration("dummy", ConfigurationFormat.CUMULUS_NCLU), vsConfig, ospfVrf, ImmutableMap.of(), new Warnings()); assertThat(ospfProcess.getRouterId(), equalTo(Ip.parse("1.2.3.4"))); assertThat(ospfProcess.getProcessId(), equalTo("default")); assertThat( ospfProcess.getReferenceBandwidth(), equalTo(org.batfish.representation.cumulus.OspfProcess.DEFAULT_REFERENCE_BANDWIDTH)); }
@VisibleForTesting static org.batfish.datamodel.ospf.OspfProcess toOspfProcess( Configuration c, CumulusNodeConfiguration vsConfig, OspfVrf ospfVrf, Map<String, org.batfish.datamodel.Interface> vrfInterfaces, Warnings w) { Ip routerId = ospfVrf.getRouterId(); if (routerId == null) { routerId = inferRouterId(c); } org.batfish.datamodel.ospf.OspfProcess.Builder builder = org.batfish.datamodel.ospf.OspfProcess.builder(); org.batfish.datamodel.ospf.OspfProcess proc = builder .setRouterId(routerId) .setProcessId(DEFAULT_OSPF_PROCESS_NAME) .setReferenceBandwidth(OspfProcess.DEFAULT_REFERENCE_BANDWIDTH) .build(); addOspfInterfaces(vsConfig, vrfInterfaces, proc.getProcessId(), w); proc.setAreas(computeOspfAreas(vsConfig, vrfInterfaces.keySet())); String ospfExportPolicyName = computeOspfExportPolicyName(ospfVrf.getVrfName()); RoutingPolicy ospfExportPolicy = new RoutingPolicy(ospfExportPolicyName, c); c.getRoutingPolicies().put(ospfExportPolicyName, ospfExportPolicy); List<Statement> ospfExportStatements = ospfExportPolicy.getStatements(); proc.setExportPolicy(ospfExportPolicyName); ospfExportStatements.add(new SetOspfMetricType(DEFAULT_REDISTRIBUTE_METRIC_TYPE)); ospfExportStatements.add(new SetMetric(new LiteralLong(DEFAULT_REDISTRIBUTE_METRIC))); ospfExportStatements.addAll( vsConfig.getOspfProcess().getRedistributionPolicies().values().stream() .map(policy -> convertOspfRedistributionPolicy(policy, vsConfig.getRouteMaps())) .collect(Collectors.toList())); return proc; }
CumulusConversions { @VisibleForTesting static org.batfish.datamodel.ospf.OspfProcess toOspfProcess( Configuration c, CumulusNodeConfiguration vsConfig, OspfVrf ospfVrf, Map<String, org.batfish.datamodel.Interface> vrfInterfaces, Warnings w) { Ip routerId = ospfVrf.getRouterId(); if (routerId == null) { routerId = inferRouterId(c); } org.batfish.datamodel.ospf.OspfProcess.Builder builder = org.batfish.datamodel.ospf.OspfProcess.builder(); org.batfish.datamodel.ospf.OspfProcess proc = builder .setRouterId(routerId) .setProcessId(DEFAULT_OSPF_PROCESS_NAME) .setReferenceBandwidth(OspfProcess.DEFAULT_REFERENCE_BANDWIDTH) .build(); addOspfInterfaces(vsConfig, vrfInterfaces, proc.getProcessId(), w); proc.setAreas(computeOspfAreas(vsConfig, vrfInterfaces.keySet())); String ospfExportPolicyName = computeOspfExportPolicyName(ospfVrf.getVrfName()); RoutingPolicy ospfExportPolicy = new RoutingPolicy(ospfExportPolicyName, c); c.getRoutingPolicies().put(ospfExportPolicyName, ospfExportPolicy); List<Statement> ospfExportStatements = ospfExportPolicy.getStatements(); proc.setExportPolicy(ospfExportPolicyName); ospfExportStatements.add(new SetOspfMetricType(DEFAULT_REDISTRIBUTE_METRIC_TYPE)); ospfExportStatements.add(new SetMetric(new LiteralLong(DEFAULT_REDISTRIBUTE_METRIC))); ospfExportStatements.addAll( vsConfig.getOspfProcess().getRedistributionPolicies().values().stream() .map(policy -> convertOspfRedistributionPolicy(policy, vsConfig.getRouteMaps())) .collect(Collectors.toList())); return proc; } }
CumulusConversions { @VisibleForTesting static org.batfish.datamodel.ospf.OspfProcess toOspfProcess( Configuration c, CumulusNodeConfiguration vsConfig, OspfVrf ospfVrf, Map<String, org.batfish.datamodel.Interface> vrfInterfaces, Warnings w) { Ip routerId = ospfVrf.getRouterId(); if (routerId == null) { routerId = inferRouterId(c); } org.batfish.datamodel.ospf.OspfProcess.Builder builder = org.batfish.datamodel.ospf.OspfProcess.builder(); org.batfish.datamodel.ospf.OspfProcess proc = builder .setRouterId(routerId) .setProcessId(DEFAULT_OSPF_PROCESS_NAME) .setReferenceBandwidth(OspfProcess.DEFAULT_REFERENCE_BANDWIDTH) .build(); addOspfInterfaces(vsConfig, vrfInterfaces, proc.getProcessId(), w); proc.setAreas(computeOspfAreas(vsConfig, vrfInterfaces.keySet())); String ospfExportPolicyName = computeOspfExportPolicyName(ospfVrf.getVrfName()); RoutingPolicy ospfExportPolicy = new RoutingPolicy(ospfExportPolicyName, c); c.getRoutingPolicies().put(ospfExportPolicyName, ospfExportPolicy); List<Statement> ospfExportStatements = ospfExportPolicy.getStatements(); proc.setExportPolicy(ospfExportPolicyName); ospfExportStatements.add(new SetOspfMetricType(DEFAULT_REDISTRIBUTE_METRIC_TYPE)); ospfExportStatements.add(new SetMetric(new LiteralLong(DEFAULT_REDISTRIBUTE_METRIC))); ospfExportStatements.addAll( vsConfig.getOspfProcess().getRedistributionPolicies().values().stream() .map(policy -> convertOspfRedistributionPolicy(policy, vsConfig.getRouteMaps())) .collect(Collectors.toList())); return proc; }  }
CumulusConversions { @VisibleForTesting static org.batfish.datamodel.ospf.OspfProcess toOspfProcess( Configuration c, CumulusNodeConfiguration vsConfig, OspfVrf ospfVrf, Map<String, org.batfish.datamodel.Interface> vrfInterfaces, Warnings w) { Ip routerId = ospfVrf.getRouterId(); if (routerId == null) { routerId = inferRouterId(c); } org.batfish.datamodel.ospf.OspfProcess.Builder builder = org.batfish.datamodel.ospf.OspfProcess.builder(); org.batfish.datamodel.ospf.OspfProcess proc = builder .setRouterId(routerId) .setProcessId(DEFAULT_OSPF_PROCESS_NAME) .setReferenceBandwidth(OspfProcess.DEFAULT_REFERENCE_BANDWIDTH) .build(); addOspfInterfaces(vsConfig, vrfInterfaces, proc.getProcessId(), w); proc.setAreas(computeOspfAreas(vsConfig, vrfInterfaces.keySet())); String ospfExportPolicyName = computeOspfExportPolicyName(ospfVrf.getVrfName()); RoutingPolicy ospfExportPolicy = new RoutingPolicy(ospfExportPolicyName, c); c.getRoutingPolicies().put(ospfExportPolicyName, ospfExportPolicy); List<Statement> ospfExportStatements = ospfExportPolicy.getStatements(); proc.setExportPolicy(ospfExportPolicyName); ospfExportStatements.add(new SetOspfMetricType(DEFAULT_REDISTRIBUTE_METRIC_TYPE)); ospfExportStatements.add(new SetMetric(new LiteralLong(DEFAULT_REDISTRIBUTE_METRIC))); ospfExportStatements.addAll( vsConfig.getOspfProcess().getRedistributionPolicies().values().stream() .map(policy -> convertOspfRedistributionPolicy(policy, vsConfig.getRouteMaps())) .collect(Collectors.toList())); return proc; }  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 { @VisibleForTesting static org.batfish.datamodel.ospf.OspfProcess toOspfProcess( Configuration c, CumulusNodeConfiguration vsConfig, OspfVrf ospfVrf, Map<String, org.batfish.datamodel.Interface> vrfInterfaces, Warnings w) { Ip routerId = ospfVrf.getRouterId(); if (routerId == null) { routerId = inferRouterId(c); } org.batfish.datamodel.ospf.OspfProcess.Builder builder = org.batfish.datamodel.ospf.OspfProcess.builder(); org.batfish.datamodel.ospf.OspfProcess proc = builder .setRouterId(routerId) .setProcessId(DEFAULT_OSPF_PROCESS_NAME) .setReferenceBandwidth(OspfProcess.DEFAULT_REFERENCE_BANDWIDTH) .build(); addOspfInterfaces(vsConfig, vrfInterfaces, proc.getProcessId(), w); proc.setAreas(computeOspfAreas(vsConfig, vrfInterfaces.keySet())); String ospfExportPolicyName = computeOspfExportPolicyName(ospfVrf.getVrfName()); RoutingPolicy ospfExportPolicy = new RoutingPolicy(ospfExportPolicyName, c); c.getRoutingPolicies().put(ospfExportPolicyName, ospfExportPolicy); List<Statement> ospfExportStatements = ospfExportPolicy.getStatements(); proc.setExportPolicy(ospfExportPolicyName); ospfExportStatements.add(new SetOspfMetricType(DEFAULT_REDISTRIBUTE_METRIC_TYPE)); ospfExportStatements.add(new SetMetric(new LiteralLong(DEFAULT_REDISTRIBUTE_METRIC))); ospfExportStatements.addAll( vsConfig.getOspfProcess().getRedistributionPolicies().values().stream() .map(policy -> convertOspfRedistributionPolicy(policy, vsConfig.getRouteMaps())) .collect(Collectors.toList())); return proc; }  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; }