@Test public void testSanityCheckDistributeListFilterType() { CiscoConfiguration oldConfig = new CiscoConfiguration(); oldConfig.setHostname("cisco_conf"); oldConfig.setWarnings(new Warnings(false, true, false)); DistributeList distributeList = new DistributeList("filter", DistributeListFilterType.ACCESS_LIST); assertFalse( sanityCheckDistributeList( distributeList, new Configuration("conf", ConfigurationFormat.CISCO_IOS), oldConfig, "vrf", "p1")); assertThat( oldConfig.getWarnings().getRedFlagWarnings().iterator().next().getText(), equalTo( "OSPF process vrf:p1 in cisco_conf uses distribute-list of type ACCESS_LIST, only prefix-lists are supported in dist-lists by Batfish")); }
@VisibleForTesting static boolean sanityCheckDistributeList( @Nonnull DistributeList distributeList, @Nonnull Configuration c, @Nonnull CiscoConfiguration oldConfig, String vrfName, String ospfProcessId) { if (distributeList.getFilterType() != DistributeListFilterType.PREFIX_LIST) { oldConfig .getWarnings() .redFlag( String.format( "OSPF process %s:%s in %s uses distribute-list of type %s, only prefix-lists are supported in dist-lists by Batfish", vrfName, ospfProcessId, oldConfig.getHostname(), distributeList.getFilterType())); return false; } else if (!c.getRouteFilterLists().containsKey(distributeList.getFilterName())) { oldConfig .getWarnings() .redFlag( String.format( "dist-list in OSPF process %s:%s uses a prefix-list which is not defined, this dist-list will allow everything", vrfName, ospfProcessId)); return false; } return true; }
CiscoConversions { @VisibleForTesting static boolean sanityCheckDistributeList( @Nonnull DistributeList distributeList, @Nonnull Configuration c, @Nonnull CiscoConfiguration oldConfig, String vrfName, String ospfProcessId) { if (distributeList.getFilterType() != DistributeListFilterType.PREFIX_LIST) { oldConfig .getWarnings() .redFlag( String.format( "OSPF process %s:%s in %s uses distribute-list of type %s, only prefix-lists are supported in dist-lists by Batfish", vrfName, ospfProcessId, oldConfig.getHostname(), distributeList.getFilterType())); return false; } else if (!c.getRouteFilterLists().containsKey(distributeList.getFilterName())) { oldConfig .getWarnings() .redFlag( String.format( "dist-list in OSPF process %s:%s uses a prefix-list which is not defined, this dist-list will allow everything", vrfName, ospfProcessId)); return false; } return true; } }
CiscoConversions { @VisibleForTesting static boolean sanityCheckDistributeList( @Nonnull DistributeList distributeList, @Nonnull Configuration c, @Nonnull CiscoConfiguration oldConfig, String vrfName, String ospfProcessId) { if (distributeList.getFilterType() != DistributeListFilterType.PREFIX_LIST) { oldConfig .getWarnings() .redFlag( String.format( "OSPF process %s:%s in %s uses distribute-list of type %s, only prefix-lists are supported in dist-lists by Batfish", vrfName, ospfProcessId, oldConfig.getHostname(), distributeList.getFilterType())); return false; } else if (!c.getRouteFilterLists().containsKey(distributeList.getFilterName())) { oldConfig .getWarnings() .redFlag( String.format( "dist-list in OSPF process %s:%s uses a prefix-list which is not defined, this dist-list will allow everything", vrfName, ospfProcessId)); return false; } return true; } private  CiscoConversions(); }
CiscoConversions { @VisibleForTesting static boolean sanityCheckDistributeList( @Nonnull DistributeList distributeList, @Nonnull Configuration c, @Nonnull CiscoConfiguration oldConfig, String vrfName, String ospfProcessId) { if (distributeList.getFilterType() != DistributeListFilterType.PREFIX_LIST) { oldConfig .getWarnings() .redFlag( String.format( "OSPF process %s:%s in %s uses distribute-list of type %s, only prefix-lists are supported in dist-lists by Batfish", vrfName, ospfProcessId, oldConfig.getHostname(), distributeList.getFilterType())); return false; } else if (!c.getRouteFilterLists().containsKey(distributeList.getFilterName())) { oldConfig .getWarnings() .redFlag( String.format( "dist-list in OSPF process %s:%s uses a prefix-list which is not defined, this dist-list will allow everything", vrfName, ospfProcessId)); return false; } return true; } private  CiscoConversions(); static CommunityList toCommunityList(StandardCommunityList scList); }
CiscoConversions { @VisibleForTesting static boolean sanityCheckDistributeList( @Nonnull DistributeList distributeList, @Nonnull Configuration c, @Nonnull CiscoConfiguration oldConfig, String vrfName, String ospfProcessId) { if (distributeList.getFilterType() != DistributeListFilterType.PREFIX_LIST) { oldConfig .getWarnings() .redFlag( String.format( "OSPF process %s:%s in %s uses distribute-list of type %s, only prefix-lists are supported in dist-lists by Batfish", vrfName, ospfProcessId, oldConfig.getHostname(), distributeList.getFilterType())); return false; } else if (!c.getRouteFilterLists().containsKey(distributeList.getFilterName())) { oldConfig .getWarnings() .redFlag( String.format( "dist-list in OSPF process %s:%s uses a prefix-list which is not defined, this dist-list will allow everything", vrfName, ospfProcessId)); return false; } return true; } private  CiscoConversions(); static CommunityList toCommunityList(StandardCommunityList scList);  }