@Test public void testFinalizeConfigurationVerifyCommunityStructures() { Configuration c = new Configuration("c", ConfigurationFormat.CISCO_IOS); c.setDefaultCrossZoneAction(LineAction.PERMIT); c.setDefaultInboundAction(LineAction.PERMIT); c.setCommunityMatchExprs( ImmutableMap.of("referenceToUndefined", new CommunityMatchExprReference("undefined"))); _thrown.expect(VendorConversionException.class); _thrown.expectMessage(containsString("Undefined reference")); finalizeConfiguration(c, new Warnings()); }
@VisibleForTesting static void finalizeConfiguration(Configuration c, Warnings w) { String hostname = c.getHostname(); if (c.getDefaultCrossZoneAction() == null) { throw new BatfishException( "Implementation error: missing default cross-zone action for host: '" + hostname + "'"); } if (c.getDefaultInboundAction() == null) { throw new BatfishException( "Implementation error: missing default inbound action for host: '" + hostname + "'"); } c.simplifyRoutingPolicies(); c.computeRoutingPolicySources(w); verifyInterfaces(c, w); c.setAsPathAccessLists( verifyAndToImmutableMap(c.getAsPathAccessLists(), AsPathAccessList::getName, w)); c.setAuthenticationKeyChains(toImmutableMap(c.getAuthenticationKeyChains())); c.setCommunityLists(verifyAndToImmutableMap(c.getCommunityLists(), CommunityList::getName, w)); c.setCommunityMatchExprs(toImmutableMap(c.getCommunityMatchExprs())); c.setCommunitySetExprs(toImmutableMap(c.getCommunitySetExprs())); c.setCommunitySetMatchExprs(toImmutableMap(c.getCommunitySetMatchExprs())); c.setCommunitySets(toImmutableMap(c.getCommunitySets())); c.setDnsServers(toImmutableSet(c.getDnsServers())); c.setGeneratedReferenceBooks(toImmutableMap(c.getGeneratedReferenceBooks())); c.setIkePhase1Keys(toImmutableMap(c.getIkePhase1Keys())); c.setIkePhase1Policies(toImmutableMap(c.getIkePhase1Policies())); c.setIkePhase1Proposals(toImmutableMap(c.getIkePhase1Proposals())); c.setInterfaces(verifyAndToImmutableMap(c.getAllInterfaces(), Interface::getName, w)); c.setIp6AccessLists(verifyAndToImmutableMap(c.getIp6AccessLists(), Ip6AccessList::getName, w)); c.setIpAccessLists(verifyAndToImmutableMap(c.getIpAccessLists(), IpAccessList::getName, w)); c.setIpsecPeerConfigs(toImmutableMap(c.getIpsecPeerConfigs())); c.setIpsecPhase2Policies(toImmutableMap(c.getIpsecPhase2Policies())); c.setIpsecPhase2Proposals(toImmutableMap(c.getIpsecPhase2Proposals())); c.setIpSpaceMetadata(toImmutableMap(c.getIpSpaceMetadata())); c.setIpSpaces(toImmutableMap(c.getIpSpaces())); c.setLoggingServers(toImmutableSet(c.getLoggingServers())); c.setMlags(verifyAndToImmutableMap(c.getMlags(), Mlag::getId, w)); c.setNtpServers(toImmutableSet(c.getNtpServers())); c.setPacketPolicies(verifyAndToImmutableMap(c.getPacketPolicies(), PacketPolicy::getName, w)); c.setRouteFilterLists( verifyAndToImmutableMap(c.getRouteFilterLists(), RouteFilterList::getName, w)); c.setRoute6FilterLists( verifyAndToImmutableMap(c.getRoute6FilterLists(), Route6FilterList::getName, w)); c.setRoutingPolicies( verifyAndToImmutableMap(c.getRoutingPolicies(), RoutingPolicy::getName, w)); c.setSnmpTrapServers(toImmutableSet(c.getSnmpTrapServers())); c.setTacacsServers(toImmutableSet(c.getTacacsServers())); c.setTrackingGroups(toImmutableMap(c.getTrackingGroups())); c.setVrfs(verifyAndToImmutableMap(c.getVrfs(), Vrf::getName, w)); c.setZones(toImmutableMap(c.getZones())); verifyCommunityStructures(c); removeInvalidAcls(c, w); }
ConvertConfigurationJob extends BatfishJob<ConvertConfigurationResult> { @VisibleForTesting static void finalizeConfiguration(Configuration c, Warnings w) { String hostname = c.getHostname(); if (c.getDefaultCrossZoneAction() == null) { throw new BatfishException( "Implementation error: missing default cross-zone action for host: '" + hostname + "'"); } if (c.getDefaultInboundAction() == null) { throw new BatfishException( "Implementation error: missing default inbound action for host: '" + hostname + "'"); } c.simplifyRoutingPolicies(); c.computeRoutingPolicySources(w); verifyInterfaces(c, w); c.setAsPathAccessLists( verifyAndToImmutableMap(c.getAsPathAccessLists(), AsPathAccessList::getName, w)); c.setAuthenticationKeyChains(toImmutableMap(c.getAuthenticationKeyChains())); c.setCommunityLists(verifyAndToImmutableMap(c.getCommunityLists(), CommunityList::getName, w)); c.setCommunityMatchExprs(toImmutableMap(c.getCommunityMatchExprs())); c.setCommunitySetExprs(toImmutableMap(c.getCommunitySetExprs())); c.setCommunitySetMatchExprs(toImmutableMap(c.getCommunitySetMatchExprs())); c.setCommunitySets(toImmutableMap(c.getCommunitySets())); c.setDnsServers(toImmutableSet(c.getDnsServers())); c.setGeneratedReferenceBooks(toImmutableMap(c.getGeneratedReferenceBooks())); c.setIkePhase1Keys(toImmutableMap(c.getIkePhase1Keys())); c.setIkePhase1Policies(toImmutableMap(c.getIkePhase1Policies())); c.setIkePhase1Proposals(toImmutableMap(c.getIkePhase1Proposals())); c.setInterfaces(verifyAndToImmutableMap(c.getAllInterfaces(), Interface::getName, w)); c.setIp6AccessLists(verifyAndToImmutableMap(c.getIp6AccessLists(), Ip6AccessList::getName, w)); c.setIpAccessLists(verifyAndToImmutableMap(c.getIpAccessLists(), IpAccessList::getName, w)); c.setIpsecPeerConfigs(toImmutableMap(c.getIpsecPeerConfigs())); c.setIpsecPhase2Policies(toImmutableMap(c.getIpsecPhase2Policies())); c.setIpsecPhase2Proposals(toImmutableMap(c.getIpsecPhase2Proposals())); c.setIpSpaceMetadata(toImmutableMap(c.getIpSpaceMetadata())); c.setIpSpaces(toImmutableMap(c.getIpSpaces())); c.setLoggingServers(toImmutableSet(c.getLoggingServers())); c.setMlags(verifyAndToImmutableMap(c.getMlags(), Mlag::getId, w)); c.setNtpServers(toImmutableSet(c.getNtpServers())); c.setPacketPolicies(verifyAndToImmutableMap(c.getPacketPolicies(), PacketPolicy::getName, w)); c.setRouteFilterLists( verifyAndToImmutableMap(c.getRouteFilterLists(), RouteFilterList::getName, w)); c.setRoute6FilterLists( verifyAndToImmutableMap(c.getRoute6FilterLists(), Route6FilterList::getName, w)); c.setRoutingPolicies( verifyAndToImmutableMap(c.getRoutingPolicies(), RoutingPolicy::getName, w)); c.setSnmpTrapServers(toImmutableSet(c.getSnmpTrapServers())); c.setTacacsServers(toImmutableSet(c.getTacacsServers())); c.setTrackingGroups(toImmutableMap(c.getTrackingGroups())); c.setVrfs(verifyAndToImmutableMap(c.getVrfs(), Vrf::getName, w)); c.setZones(toImmutableMap(c.getZones())); verifyCommunityStructures(c); removeInvalidAcls(c, w); } }
ConvertConfigurationJob extends BatfishJob<ConvertConfigurationResult> { @VisibleForTesting static void finalizeConfiguration(Configuration c, Warnings w) { String hostname = c.getHostname(); if (c.getDefaultCrossZoneAction() == null) { throw new BatfishException( "Implementation error: missing default cross-zone action for host: '" + hostname + "'"); } if (c.getDefaultInboundAction() == null) { throw new BatfishException( "Implementation error: missing default inbound action for host: '" + hostname + "'"); } c.simplifyRoutingPolicies(); c.computeRoutingPolicySources(w); verifyInterfaces(c, w); c.setAsPathAccessLists( verifyAndToImmutableMap(c.getAsPathAccessLists(), AsPathAccessList::getName, w)); c.setAuthenticationKeyChains(toImmutableMap(c.getAuthenticationKeyChains())); c.setCommunityLists(verifyAndToImmutableMap(c.getCommunityLists(), CommunityList::getName, w)); c.setCommunityMatchExprs(toImmutableMap(c.getCommunityMatchExprs())); c.setCommunitySetExprs(toImmutableMap(c.getCommunitySetExprs())); c.setCommunitySetMatchExprs(toImmutableMap(c.getCommunitySetMatchExprs())); c.setCommunitySets(toImmutableMap(c.getCommunitySets())); c.setDnsServers(toImmutableSet(c.getDnsServers())); c.setGeneratedReferenceBooks(toImmutableMap(c.getGeneratedReferenceBooks())); c.setIkePhase1Keys(toImmutableMap(c.getIkePhase1Keys())); c.setIkePhase1Policies(toImmutableMap(c.getIkePhase1Policies())); c.setIkePhase1Proposals(toImmutableMap(c.getIkePhase1Proposals())); c.setInterfaces(verifyAndToImmutableMap(c.getAllInterfaces(), Interface::getName, w)); c.setIp6AccessLists(verifyAndToImmutableMap(c.getIp6AccessLists(), Ip6AccessList::getName, w)); c.setIpAccessLists(verifyAndToImmutableMap(c.getIpAccessLists(), IpAccessList::getName, w)); c.setIpsecPeerConfigs(toImmutableMap(c.getIpsecPeerConfigs())); c.setIpsecPhase2Policies(toImmutableMap(c.getIpsecPhase2Policies())); c.setIpsecPhase2Proposals(toImmutableMap(c.getIpsecPhase2Proposals())); c.setIpSpaceMetadata(toImmutableMap(c.getIpSpaceMetadata())); c.setIpSpaces(toImmutableMap(c.getIpSpaces())); c.setLoggingServers(toImmutableSet(c.getLoggingServers())); c.setMlags(verifyAndToImmutableMap(c.getMlags(), Mlag::getId, w)); c.setNtpServers(toImmutableSet(c.getNtpServers())); c.setPacketPolicies(verifyAndToImmutableMap(c.getPacketPolicies(), PacketPolicy::getName, w)); c.setRouteFilterLists( verifyAndToImmutableMap(c.getRouteFilterLists(), RouteFilterList::getName, w)); c.setRoute6FilterLists( verifyAndToImmutableMap(c.getRoute6FilterLists(), Route6FilterList::getName, w)); c.setRoutingPolicies( verifyAndToImmutableMap(c.getRoutingPolicies(), RoutingPolicy::getName, w)); c.setSnmpTrapServers(toImmutableSet(c.getSnmpTrapServers())); c.setTacacsServers(toImmutableSet(c.getTacacsServers())); c.setTrackingGroups(toImmutableMap(c.getTrackingGroups())); c.setVrfs(verifyAndToImmutableMap(c.getVrfs(), Vrf::getName, w)); c.setZones(toImmutableMap(c.getZones())); verifyCommunityStructures(c); removeInvalidAcls(c, w); } ConvertConfigurationJob(
      Settings settings,
      @Nullable SnapshotRuntimeData runtimeData,
      Object configObject,
      String name); }
ConvertConfigurationJob extends BatfishJob<ConvertConfigurationResult> { @VisibleForTesting static void finalizeConfiguration(Configuration c, Warnings w) { String hostname = c.getHostname(); if (c.getDefaultCrossZoneAction() == null) { throw new BatfishException( "Implementation error: missing default cross-zone action for host: '" + hostname + "'"); } if (c.getDefaultInboundAction() == null) { throw new BatfishException( "Implementation error: missing default inbound action for host: '" + hostname + "'"); } c.simplifyRoutingPolicies(); c.computeRoutingPolicySources(w); verifyInterfaces(c, w); c.setAsPathAccessLists( verifyAndToImmutableMap(c.getAsPathAccessLists(), AsPathAccessList::getName, w)); c.setAuthenticationKeyChains(toImmutableMap(c.getAuthenticationKeyChains())); c.setCommunityLists(verifyAndToImmutableMap(c.getCommunityLists(), CommunityList::getName, w)); c.setCommunityMatchExprs(toImmutableMap(c.getCommunityMatchExprs())); c.setCommunitySetExprs(toImmutableMap(c.getCommunitySetExprs())); c.setCommunitySetMatchExprs(toImmutableMap(c.getCommunitySetMatchExprs())); c.setCommunitySets(toImmutableMap(c.getCommunitySets())); c.setDnsServers(toImmutableSet(c.getDnsServers())); c.setGeneratedReferenceBooks(toImmutableMap(c.getGeneratedReferenceBooks())); c.setIkePhase1Keys(toImmutableMap(c.getIkePhase1Keys())); c.setIkePhase1Policies(toImmutableMap(c.getIkePhase1Policies())); c.setIkePhase1Proposals(toImmutableMap(c.getIkePhase1Proposals())); c.setInterfaces(verifyAndToImmutableMap(c.getAllInterfaces(), Interface::getName, w)); c.setIp6AccessLists(verifyAndToImmutableMap(c.getIp6AccessLists(), Ip6AccessList::getName, w)); c.setIpAccessLists(verifyAndToImmutableMap(c.getIpAccessLists(), IpAccessList::getName, w)); c.setIpsecPeerConfigs(toImmutableMap(c.getIpsecPeerConfigs())); c.setIpsecPhase2Policies(toImmutableMap(c.getIpsecPhase2Policies())); c.setIpsecPhase2Proposals(toImmutableMap(c.getIpsecPhase2Proposals())); c.setIpSpaceMetadata(toImmutableMap(c.getIpSpaceMetadata())); c.setIpSpaces(toImmutableMap(c.getIpSpaces())); c.setLoggingServers(toImmutableSet(c.getLoggingServers())); c.setMlags(verifyAndToImmutableMap(c.getMlags(), Mlag::getId, w)); c.setNtpServers(toImmutableSet(c.getNtpServers())); c.setPacketPolicies(verifyAndToImmutableMap(c.getPacketPolicies(), PacketPolicy::getName, w)); c.setRouteFilterLists( verifyAndToImmutableMap(c.getRouteFilterLists(), RouteFilterList::getName, w)); c.setRoute6FilterLists( verifyAndToImmutableMap(c.getRoute6FilterLists(), Route6FilterList::getName, w)); c.setRoutingPolicies( verifyAndToImmutableMap(c.getRoutingPolicies(), RoutingPolicy::getName, w)); c.setSnmpTrapServers(toImmutableSet(c.getSnmpTrapServers())); c.setTacacsServers(toImmutableSet(c.getTacacsServers())); c.setTrackingGroups(toImmutableMap(c.getTrackingGroups())); c.setVrfs(verifyAndToImmutableMap(c.getVrfs(), Vrf::getName, w)); c.setZones(toImmutableMap(c.getZones())); verifyCommunityStructures(c); removeInvalidAcls(c, w); } ConvertConfigurationJob(
      Settings settings,
      @Nullable SnapshotRuntimeData runtimeData,
      Object configObject,
      String name); @Override ConvertConfigurationResult call(); }
ConvertConfigurationJob extends BatfishJob<ConvertConfigurationResult> { @VisibleForTesting static void finalizeConfiguration(Configuration c, Warnings w) { String hostname = c.getHostname(); if (c.getDefaultCrossZoneAction() == null) { throw new BatfishException( "Implementation error: missing default cross-zone action for host: '" + hostname + "'"); } if (c.getDefaultInboundAction() == null) { throw new BatfishException( "Implementation error: missing default inbound action for host: '" + hostname + "'"); } c.simplifyRoutingPolicies(); c.computeRoutingPolicySources(w); verifyInterfaces(c, w); c.setAsPathAccessLists( verifyAndToImmutableMap(c.getAsPathAccessLists(), AsPathAccessList::getName, w)); c.setAuthenticationKeyChains(toImmutableMap(c.getAuthenticationKeyChains())); c.setCommunityLists(verifyAndToImmutableMap(c.getCommunityLists(), CommunityList::getName, w)); c.setCommunityMatchExprs(toImmutableMap(c.getCommunityMatchExprs())); c.setCommunitySetExprs(toImmutableMap(c.getCommunitySetExprs())); c.setCommunitySetMatchExprs(toImmutableMap(c.getCommunitySetMatchExprs())); c.setCommunitySets(toImmutableMap(c.getCommunitySets())); c.setDnsServers(toImmutableSet(c.getDnsServers())); c.setGeneratedReferenceBooks(toImmutableMap(c.getGeneratedReferenceBooks())); c.setIkePhase1Keys(toImmutableMap(c.getIkePhase1Keys())); c.setIkePhase1Policies(toImmutableMap(c.getIkePhase1Policies())); c.setIkePhase1Proposals(toImmutableMap(c.getIkePhase1Proposals())); c.setInterfaces(verifyAndToImmutableMap(c.getAllInterfaces(), Interface::getName, w)); c.setIp6AccessLists(verifyAndToImmutableMap(c.getIp6AccessLists(), Ip6AccessList::getName, w)); c.setIpAccessLists(verifyAndToImmutableMap(c.getIpAccessLists(), IpAccessList::getName, w)); c.setIpsecPeerConfigs(toImmutableMap(c.getIpsecPeerConfigs())); c.setIpsecPhase2Policies(toImmutableMap(c.getIpsecPhase2Policies())); c.setIpsecPhase2Proposals(toImmutableMap(c.getIpsecPhase2Proposals())); c.setIpSpaceMetadata(toImmutableMap(c.getIpSpaceMetadata())); c.setIpSpaces(toImmutableMap(c.getIpSpaces())); c.setLoggingServers(toImmutableSet(c.getLoggingServers())); c.setMlags(verifyAndToImmutableMap(c.getMlags(), Mlag::getId, w)); c.setNtpServers(toImmutableSet(c.getNtpServers())); c.setPacketPolicies(verifyAndToImmutableMap(c.getPacketPolicies(), PacketPolicy::getName, w)); c.setRouteFilterLists( verifyAndToImmutableMap(c.getRouteFilterLists(), RouteFilterList::getName, w)); c.setRoute6FilterLists( verifyAndToImmutableMap(c.getRoute6FilterLists(), Route6FilterList::getName, w)); c.setRoutingPolicies( verifyAndToImmutableMap(c.getRoutingPolicies(), RoutingPolicy::getName, w)); c.setSnmpTrapServers(toImmutableSet(c.getSnmpTrapServers())); c.setTacacsServers(toImmutableSet(c.getTacacsServers())); c.setTrackingGroups(toImmutableMap(c.getTrackingGroups())); c.setVrfs(verifyAndToImmutableMap(c.getVrfs(), Vrf::getName, w)); c.setZones(toImmutableMap(c.getZones())); verifyCommunityStructures(c); removeInvalidAcls(c, w); } ConvertConfigurationJob(
      Settings settings,
      @Nullable SnapshotRuntimeData runtimeData,
      Object configObject,
      String name); @Override ConvertConfigurationResult call();  }