@Test public void testToConfigurationNode_defaultVrf() { Set<Prefix> prefixes = ImmutableSet.of(Prefix.parse("1.1.1.1/32"), Prefix.parse("2.2.2.2/32")); Vpc vpc = getTestVpc("vpc", prefixes); Configuration vpcCfg = vpc.toConfigurationNode(new ConvertedConfiguration(), new Region("r"), new Warnings()); assertThat( vpcCfg.getDefaultVrf().getStaticRoutes(), equalTo( prefixes.stream() .map(Vpc::staticRouteToVpcPrefix) .collect(ImmutableSortedSet.toImmutableSortedSet(Comparator.naturalOrder())))); }
Configuration toConfigurationNode( ConvertedConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(nodeName(_vpcId), "aws", _tags, DeviceModel.AWS_VPC); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); cfgNode.getVendorFamily().getAws().setVpcId(_vpcId); initializeVrf(DEFAULT_VRF_NAME, cfgNode); region.getInternetGateways().values().stream() .filter(igw -> igw.getAttachmentVpcIds().contains(_vpcId)) .forEach(igw -> initializeVrf(vrfNameForLink(igw.getId()), cfgNode)); region.getVpnGateways().values().stream() .filter(vgw -> vgw.getAttachmentVpcIds().contains(_vpcId)) .forEach(vgw -> initializeVrf(vrfNameForLink(vgw.getId()), cfgNode)); region.getVpcEndpoints().values().stream() .filter(vpce -> vpce instanceof VpcEndpointGateway && vpce.getVpcId().equals(_vpcId)) .forEach(vpce -> initializeVrf(vrfNameForLink(vpce.getId()), cfgNode)); region.getNatGateways().values().stream() .filter(ngw -> ngw.getVpcId().equals(_vpcId)) .forEach(ngw -> initializeVrf(vrfNameForLink(ngw.getId()), cfgNode)); region.getTransitGatewayVpcAttachments().values().stream() .filter(attachment -> attachment.getVpcId().equals(_vpcId)) .forEach(attachment -> initializeVrf(vrfNameForLink(attachment.getId()), cfgNode)); region.getVpcPeeringConnections().values().stream() .filter( connection -> connection.getAccepterVpcId().equals(_vpcId) || connection.getRequesterVpcId().equals(_vpcId)) .forEach(connection -> initializeVrf(vrfNameForLink(connection.getId()), cfgNode)); return cfgNode; }
Vpc implements AwsVpcEntity, Serializable { Configuration toConfigurationNode( ConvertedConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(nodeName(_vpcId), "aws", _tags, DeviceModel.AWS_VPC); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); cfgNode.getVendorFamily().getAws().setVpcId(_vpcId); initializeVrf(DEFAULT_VRF_NAME, cfgNode); region.getInternetGateways().values().stream() .filter(igw -> igw.getAttachmentVpcIds().contains(_vpcId)) .forEach(igw -> initializeVrf(vrfNameForLink(igw.getId()), cfgNode)); region.getVpnGateways().values().stream() .filter(vgw -> vgw.getAttachmentVpcIds().contains(_vpcId)) .forEach(vgw -> initializeVrf(vrfNameForLink(vgw.getId()), cfgNode)); region.getVpcEndpoints().values().stream() .filter(vpce -> vpce instanceof VpcEndpointGateway && vpce.getVpcId().equals(_vpcId)) .forEach(vpce -> initializeVrf(vrfNameForLink(vpce.getId()), cfgNode)); region.getNatGateways().values().stream() .filter(ngw -> ngw.getVpcId().equals(_vpcId)) .forEach(ngw -> initializeVrf(vrfNameForLink(ngw.getId()), cfgNode)); region.getTransitGatewayVpcAttachments().values().stream() .filter(attachment -> attachment.getVpcId().equals(_vpcId)) .forEach(attachment -> initializeVrf(vrfNameForLink(attachment.getId()), cfgNode)); region.getVpcPeeringConnections().values().stream() .filter( connection -> connection.getAccepterVpcId().equals(_vpcId) || connection.getRequesterVpcId().equals(_vpcId)) .forEach(connection -> initializeVrf(vrfNameForLink(connection.getId()), cfgNode)); return cfgNode; } }
Vpc implements AwsVpcEntity, Serializable { Configuration toConfigurationNode( ConvertedConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(nodeName(_vpcId), "aws", _tags, DeviceModel.AWS_VPC); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); cfgNode.getVendorFamily().getAws().setVpcId(_vpcId); initializeVrf(DEFAULT_VRF_NAME, cfgNode); region.getInternetGateways().values().stream() .filter(igw -> igw.getAttachmentVpcIds().contains(_vpcId)) .forEach(igw -> initializeVrf(vrfNameForLink(igw.getId()), cfgNode)); region.getVpnGateways().values().stream() .filter(vgw -> vgw.getAttachmentVpcIds().contains(_vpcId)) .forEach(vgw -> initializeVrf(vrfNameForLink(vgw.getId()), cfgNode)); region.getVpcEndpoints().values().stream() .filter(vpce -> vpce instanceof VpcEndpointGateway && vpce.getVpcId().equals(_vpcId)) .forEach(vpce -> initializeVrf(vrfNameForLink(vpce.getId()), cfgNode)); region.getNatGateways().values().stream() .filter(ngw -> ngw.getVpcId().equals(_vpcId)) .forEach(ngw -> initializeVrf(vrfNameForLink(ngw.getId()), cfgNode)); region.getTransitGatewayVpcAttachments().values().stream() .filter(attachment -> attachment.getVpcId().equals(_vpcId)) .forEach(attachment -> initializeVrf(vrfNameForLink(attachment.getId()), cfgNode)); region.getVpcPeeringConnections().values().stream() .filter( connection -> connection.getAccepterVpcId().equals(_vpcId) || connection.getRequesterVpcId().equals(_vpcId)) .forEach(connection -> initializeVrf(vrfNameForLink(connection.getId()), cfgNode)); return cfgNode; } Vpc(String ownerId, String vpcId, Set<Prefix> cidrBlockAssociations, Map<String, String> tags); }
Vpc implements AwsVpcEntity, Serializable { Configuration toConfigurationNode( ConvertedConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(nodeName(_vpcId), "aws", _tags, DeviceModel.AWS_VPC); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); cfgNode.getVendorFamily().getAws().setVpcId(_vpcId); initializeVrf(DEFAULT_VRF_NAME, cfgNode); region.getInternetGateways().values().stream() .filter(igw -> igw.getAttachmentVpcIds().contains(_vpcId)) .forEach(igw -> initializeVrf(vrfNameForLink(igw.getId()), cfgNode)); region.getVpnGateways().values().stream() .filter(vgw -> vgw.getAttachmentVpcIds().contains(_vpcId)) .forEach(vgw -> initializeVrf(vrfNameForLink(vgw.getId()), cfgNode)); region.getVpcEndpoints().values().stream() .filter(vpce -> vpce instanceof VpcEndpointGateway && vpce.getVpcId().equals(_vpcId)) .forEach(vpce -> initializeVrf(vrfNameForLink(vpce.getId()), cfgNode)); region.getNatGateways().values().stream() .filter(ngw -> ngw.getVpcId().equals(_vpcId)) .forEach(ngw -> initializeVrf(vrfNameForLink(ngw.getId()), cfgNode)); region.getTransitGatewayVpcAttachments().values().stream() .filter(attachment -> attachment.getVpcId().equals(_vpcId)) .forEach(attachment -> initializeVrf(vrfNameForLink(attachment.getId()), cfgNode)); region.getVpcPeeringConnections().values().stream() .filter( connection -> connection.getAccepterVpcId().equals(_vpcId) || connection.getRequesterVpcId().equals(_vpcId)) .forEach(connection -> initializeVrf(vrfNameForLink(connection.getId()), cfgNode)); return cfgNode; } Vpc(String ownerId, String vpcId, Set<Prefix> cidrBlockAssociations, Map<String, String> tags); @Nonnull String getOwnerId(); @Override String getId(); @Override boolean equals(Object o); @Override int hashCode(); }
Vpc implements AwsVpcEntity, Serializable { Configuration toConfigurationNode( ConvertedConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(nodeName(_vpcId), "aws", _tags, DeviceModel.AWS_VPC); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); cfgNode.getVendorFamily().getAws().setVpcId(_vpcId); initializeVrf(DEFAULT_VRF_NAME, cfgNode); region.getInternetGateways().values().stream() .filter(igw -> igw.getAttachmentVpcIds().contains(_vpcId)) .forEach(igw -> initializeVrf(vrfNameForLink(igw.getId()), cfgNode)); region.getVpnGateways().values().stream() .filter(vgw -> vgw.getAttachmentVpcIds().contains(_vpcId)) .forEach(vgw -> initializeVrf(vrfNameForLink(vgw.getId()), cfgNode)); region.getVpcEndpoints().values().stream() .filter(vpce -> vpce instanceof VpcEndpointGateway && vpce.getVpcId().equals(_vpcId)) .forEach(vpce -> initializeVrf(vrfNameForLink(vpce.getId()), cfgNode)); region.getNatGateways().values().stream() .filter(ngw -> ngw.getVpcId().equals(_vpcId)) .forEach(ngw -> initializeVrf(vrfNameForLink(ngw.getId()), cfgNode)); region.getTransitGatewayVpcAttachments().values().stream() .filter(attachment -> attachment.getVpcId().equals(_vpcId)) .forEach(attachment -> initializeVrf(vrfNameForLink(attachment.getId()), cfgNode)); region.getVpcPeeringConnections().values().stream() .filter( connection -> connection.getAccepterVpcId().equals(_vpcId) || connection.getRequesterVpcId().equals(_vpcId)) .forEach(connection -> initializeVrf(vrfNameForLink(connection.getId()), cfgNode)); return cfgNode; } Vpc(String ownerId, String vpcId, Set<Prefix> cidrBlockAssociations, Map<String, String> tags); @Nonnull String getOwnerId(); @Override String getId(); @Override boolean equals(Object o); @Override int hashCode();  }