@Test public void testGenerateAwsServicesGateway() { Configuration cfg = generateAwsServicesGateway(); assertThat(cfg.getDeviceModel(), equalTo(DeviceModel.AWS_SERVICES_GATEWAY)); assertThat( cfg.getAllInterfaces().keySet(), containsInAnyOrder(BACKBONE_FACING_INTERFACE_NAME, AWS_SERVICES_FACING_INTERFACE_NAME)); assertThat( cfg.getAllInterfaces() .get(AWS_SERVICES_FACING_INTERFACE_NAME) .getFirewallSessionInterfaceInfo(), notNullValue()); assertThat( cfg.getAllInterfaces() .get(BACKBONE_FACING_INTERFACE_NAME) .getFirewallSessionInterfaceInfo(), notNullValue()); Set<Prefix> awsServicesPrefixes = AwsPrefixes.getAwsServicesPrefixes(); assertThat( cfg.getDefaultVrf().getStaticRoutes(), equalTo( awsServicesPrefixes.stream() .map(prefix -> toStaticRoute(prefix, AWS_SERVICES_FACING_INTERFACE_NAME)) .collect(Collectors.toSet()))); assertThat( cfg.getLocationInfo() .get( interfaceLinkLocation( cfg.getAllInterfaces().get(AWS_SERVICES_FACING_INTERFACE_NAME))), equalTo( new LocationInfo( true, IpWildcardSetIpSpace.builder() .including( awsServicesPrefixes.stream() .map(IpWildcard::create) .collect(Collectors.toList())) .build(), LINK_LOCAL_IP.toIpSpace()))); assertTrue(cfg.getRoutingPolicies().containsKey(AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME)); }
static Configuration generateAwsServicesGateway() { Configuration cfgNode = Configuration.builder() .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .setHostname(AWS_SERVICES_GATEWAY_NODE_NAME) .setHumanName(AWS_SERVICES_GATEWAY_HUMAN_NAME) .setDefaultInboundAction(LineAction.PERMIT) .setDefaultCrossZoneAction(LineAction.PERMIT) .setDeviceModel(DeviceModel.AWS_SERVICES_GATEWAY) .build(); Vrf.builder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(cfgNode).build(); Interface outInterface = Utils.newInterface( AWS_SERVICES_FACING_INTERFACE_NAME, cfgNode, LinkLocalAddress.of(LINK_LOCAL_IP), "To AWS services"); Set<Prefix> awsServicesPrefixes = AwsPrefixes.getAwsServicesPrefixes(); PrefixSpace servicesPrefixSpace = new PrefixSpace(); awsServicesPrefixes.forEach( prefix -> { servicesPrefixSpace.addPrefix(prefix); addStaticRoute(cfgNode, toStaticRoute(prefix, outInterface.getName())); }); installRoutingPolicyAdvertiseStatic( AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME, cfgNode, servicesPrefixSpace); Utils.createBackboneConnection( cfgNode, cfgNode.getDefaultVrf(), AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME); cfgNode .getAllInterfaces() .get(BACKBONE_FACING_INTERFACE_NAME) .setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(BACKBONE_FACING_INTERFACE_NAME), null, null)); outInterface.setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(outInterface.getName()), null, null)); IpSpace servicesIpSpace = IpWildcardSetIpSpace.builder() .including( awsServicesPrefixes.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); cfgNode.setLocationInfo( ImmutableMap.of( interfaceLinkLocation(outInterface), new LocationInfo( true, servicesIpSpace, LINK_LOCAL_IP.toIpSpace()))); return cfgNode; }
AwsConfiguration extends VendorConfiguration { static Configuration generateAwsServicesGateway() { Configuration cfgNode = Configuration.builder() .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .setHostname(AWS_SERVICES_GATEWAY_NODE_NAME) .setHumanName(AWS_SERVICES_GATEWAY_HUMAN_NAME) .setDefaultInboundAction(LineAction.PERMIT) .setDefaultCrossZoneAction(LineAction.PERMIT) .setDeviceModel(DeviceModel.AWS_SERVICES_GATEWAY) .build(); Vrf.builder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(cfgNode).build(); Interface outInterface = Utils.newInterface( AWS_SERVICES_FACING_INTERFACE_NAME, cfgNode, LinkLocalAddress.of(LINK_LOCAL_IP), "To AWS services"); Set<Prefix> awsServicesPrefixes = AwsPrefixes.getAwsServicesPrefixes(); PrefixSpace servicesPrefixSpace = new PrefixSpace(); awsServicesPrefixes.forEach( prefix -> { servicesPrefixSpace.addPrefix(prefix); addStaticRoute(cfgNode, toStaticRoute(prefix, outInterface.getName())); }); installRoutingPolicyAdvertiseStatic( AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME, cfgNode, servicesPrefixSpace); Utils.createBackboneConnection( cfgNode, cfgNode.getDefaultVrf(), AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME); cfgNode .getAllInterfaces() .get(BACKBONE_FACING_INTERFACE_NAME) .setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(BACKBONE_FACING_INTERFACE_NAME), null, null)); outInterface.setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(outInterface.getName()), null, null)); IpSpace servicesIpSpace = IpWildcardSetIpSpace.builder() .including( awsServicesPrefixes.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); cfgNode.setLocationInfo( ImmutableMap.of( interfaceLinkLocation(outInterface), new LocationInfo( true, servicesIpSpace, LINK_LOCAL_IP.toIpSpace()))); return cfgNode; } }
AwsConfiguration extends VendorConfiguration { static Configuration generateAwsServicesGateway() { Configuration cfgNode = Configuration.builder() .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .setHostname(AWS_SERVICES_GATEWAY_NODE_NAME) .setHumanName(AWS_SERVICES_GATEWAY_HUMAN_NAME) .setDefaultInboundAction(LineAction.PERMIT) .setDefaultCrossZoneAction(LineAction.PERMIT) .setDeviceModel(DeviceModel.AWS_SERVICES_GATEWAY) .build(); Vrf.builder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(cfgNode).build(); Interface outInterface = Utils.newInterface( AWS_SERVICES_FACING_INTERFACE_NAME, cfgNode, LinkLocalAddress.of(LINK_LOCAL_IP), "To AWS services"); Set<Prefix> awsServicesPrefixes = AwsPrefixes.getAwsServicesPrefixes(); PrefixSpace servicesPrefixSpace = new PrefixSpace(); awsServicesPrefixes.forEach( prefix -> { servicesPrefixSpace.addPrefix(prefix); addStaticRoute(cfgNode, toStaticRoute(prefix, outInterface.getName())); }); installRoutingPolicyAdvertiseStatic( AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME, cfgNode, servicesPrefixSpace); Utils.createBackboneConnection( cfgNode, cfgNode.getDefaultVrf(), AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME); cfgNode .getAllInterfaces() .get(BACKBONE_FACING_INTERFACE_NAME) .setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(BACKBONE_FACING_INTERFACE_NAME), null, null)); outInterface.setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(outInterface.getName()), null, null)); IpSpace servicesIpSpace = IpWildcardSetIpSpace.builder() .including( awsServicesPrefixes.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); cfgNode.setLocationInfo( ImmutableMap.of( interfaceLinkLocation(outInterface), new LocationInfo( true, servicesIpSpace, LINK_LOCAL_IP.toIpSpace()))); return cfgNode; } AwsConfiguration(); private  AwsConfiguration(Map<String, Account> accounts); }
AwsConfiguration extends VendorConfiguration { static Configuration generateAwsServicesGateway() { Configuration cfgNode = Configuration.builder() .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .setHostname(AWS_SERVICES_GATEWAY_NODE_NAME) .setHumanName(AWS_SERVICES_GATEWAY_HUMAN_NAME) .setDefaultInboundAction(LineAction.PERMIT) .setDefaultCrossZoneAction(LineAction.PERMIT) .setDeviceModel(DeviceModel.AWS_SERVICES_GATEWAY) .build(); Vrf.builder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(cfgNode).build(); Interface outInterface = Utils.newInterface( AWS_SERVICES_FACING_INTERFACE_NAME, cfgNode, LinkLocalAddress.of(LINK_LOCAL_IP), "To AWS services"); Set<Prefix> awsServicesPrefixes = AwsPrefixes.getAwsServicesPrefixes(); PrefixSpace servicesPrefixSpace = new PrefixSpace(); awsServicesPrefixes.forEach( prefix -> { servicesPrefixSpace.addPrefix(prefix); addStaticRoute(cfgNode, toStaticRoute(prefix, outInterface.getName())); }); installRoutingPolicyAdvertiseStatic( AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME, cfgNode, servicesPrefixSpace); Utils.createBackboneConnection( cfgNode, cfgNode.getDefaultVrf(), AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME); cfgNode .getAllInterfaces() .get(BACKBONE_FACING_INTERFACE_NAME) .setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(BACKBONE_FACING_INTERFACE_NAME), null, null)); outInterface.setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(outInterface.getName()), null, null)); IpSpace servicesIpSpace = IpWildcardSetIpSpace.builder() .including( awsServicesPrefixes.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); cfgNode.setLocationInfo( ImmutableMap.of( interfaceLinkLocation(outInterface), new LocationInfo( true, servicesIpSpace, LINK_LOCAL_IP.toIpSpace()))); return cfgNode; } AwsConfiguration(); private  AwsConfiguration(Map<String, Account> accounts); Collection<Account> getAccounts(); @Nonnull Stream<Vpc> getAllVpc(); @Nullable Vpc getVpc(String vpcId); @Nonnull Account addOrGetAccount(String accountId); void addConfigElement(
      String region,
      JsonNode json,
      String sourceFileName,
      ParseVendorConfigurationAnswerElement pvcae,
      String account); @Nonnull @Override List<Configuration> toVendorIndependentConfigurations(); @Override @Nonnull IspConfiguration getIspConfiguration(); @Override String getFilename(); @Override String getHostname(); @Override @Nonnull Set<Layer1Edge> getLayer1Edges(); @Override void setHostname(String hostname); @Override void setVendor(ConfigurationFormat format); static String vpnExternalInterfaceName(String tunnelId); static String vpnTunnelId(String vpnConnectionId, int idNum); static String vpnInterfaceName(String tunnelId); }
AwsConfiguration extends VendorConfiguration { static Configuration generateAwsServicesGateway() { Configuration cfgNode = Configuration.builder() .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .setHostname(AWS_SERVICES_GATEWAY_NODE_NAME) .setHumanName(AWS_SERVICES_GATEWAY_HUMAN_NAME) .setDefaultInboundAction(LineAction.PERMIT) .setDefaultCrossZoneAction(LineAction.PERMIT) .setDeviceModel(DeviceModel.AWS_SERVICES_GATEWAY) .build(); Vrf.builder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(cfgNode).build(); Interface outInterface = Utils.newInterface( AWS_SERVICES_FACING_INTERFACE_NAME, cfgNode, LinkLocalAddress.of(LINK_LOCAL_IP), "To AWS services"); Set<Prefix> awsServicesPrefixes = AwsPrefixes.getAwsServicesPrefixes(); PrefixSpace servicesPrefixSpace = new PrefixSpace(); awsServicesPrefixes.forEach( prefix -> { servicesPrefixSpace.addPrefix(prefix); addStaticRoute(cfgNode, toStaticRoute(prefix, outInterface.getName())); }); installRoutingPolicyAdvertiseStatic( AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME, cfgNode, servicesPrefixSpace); Utils.createBackboneConnection( cfgNode, cfgNode.getDefaultVrf(), AWS_SERVICES_GATEWAY_EXPORT_POLICY_NAME); cfgNode .getAllInterfaces() .get(BACKBONE_FACING_INTERFACE_NAME) .setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(BACKBONE_FACING_INTERFACE_NAME), null, null)); outInterface.setFirewallSessionInterfaceInfo( new FirewallSessionInterfaceInfo( false, ImmutableList.of(outInterface.getName()), null, null)); IpSpace servicesIpSpace = IpWildcardSetIpSpace.builder() .including( awsServicesPrefixes.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); cfgNode.setLocationInfo( ImmutableMap.of( interfaceLinkLocation(outInterface), new LocationInfo( true, servicesIpSpace, LINK_LOCAL_IP.toIpSpace()))); return cfgNode; } AwsConfiguration(); private  AwsConfiguration(Map<String, Account> accounts); Collection<Account> getAccounts(); @Nonnull Stream<Vpc> getAllVpc(); @Nullable Vpc getVpc(String vpcId); @Nonnull Account addOrGetAccount(String accountId); void addConfigElement(
      String region,
      JsonNode json,
      String sourceFileName,
      ParseVendorConfigurationAnswerElement pvcae,
      String account); @Nonnull @Override List<Configuration> toVendorIndependentConfigurations(); @Override @Nonnull IspConfiguration getIspConfiguration(); @Override String getFilename(); @Override String getHostname(); @Override @Nonnull Set<Layer1Edge> getLayer1Edges(); @Override void setHostname(String hostname); @Override void setVendor(ConfigurationFormat format); static String vpnExternalInterfaceName(String tunnelId); static String vpnTunnelId(String vpnConnectionId, int idNum); static String vpnInterfaceName(String tunnelId); static final String DEFAULT_REGION_NAME; static final String DEFAULT_ACCOUNT_NAME; static final String AWS_BACKBONE_HOSTNAME; }