private AddressEndpointRegBuilder createBasicL3AddrEpInputBuilder(Port port, NetworkDomainId networkContainment, @Nullable List<EndpointGroupId> endpointGroupsToAdd, Neutron neutron) { Optional<FixedIps> firstFixedIps = PortUtils.resolveFirstFixedIps(port); if (!firstFixedIps.isPresent()) { throw new IllegalStateException("Failed to resolve FixedIps for port " + port.getKey() + ". Cannot register L3 Address endpoint."); } ContextId resolveL3ContextForPort = resolveL3ContextForPort(port, port.getFixedIps().get(0), neutron); AddressEndpointRegBuilder addrEpbuilder = new AddressEndpointRegBuilder().setAddressType(MacAddressType.class) .setAddress(MappingUtils.ipAddressToStringIpPrefix(firstFixedIps.get().getIpAddress())) .setAddressType(IpPrefixType.class) .setContextType(MappingUtils.L3_CONTEXT) .setContextId(resolveL3ContextForPort) .setTenant(new TenantId(port.getTenantId().getValue())) .setTimestamp(System.currentTimeMillis()); List<EndpointGroupId> epgs = concatEndpointGroups(port.getSecurityGroups(), endpointGroupsToAdd); addrEpbuilder.setEndpointGroup(epgs); if (networkContainment != null) { addrEpbuilder.setNetworkContainment(new NetworkContainmentBuilder().setContainment( new NetworkDomainContainmentBuilder().setNetworkDomainId(networkContainment) .setNetworkDomainType(MappingUtils.SUBNET) .build()).build()); } return addrEpbuilder; }
private boolean registerExternalGateway(TenantId tenantId, IpPrefix ipPrefix, ContextId routerl3ContextId, NetworkDomainId networkDomainId) { AddressEndpointRegBuilder addrEpBuilder = new AddressEndpointRegBuilder(); addrEpBuilder.setAddressType(IpPrefixType.class); addrEpBuilder.setAddress(MappingUtils.ipPrefixToStringIpAddress(ipPrefix)); addrEpBuilder.setContextId(routerl3ContextId); addrEpBuilder.setContextType(MappingUtils.L3_CONTEXT); addrEpBuilder.setTenant(tenantId); addrEpBuilder.setNetworkContainment(new NetworkContainmentBuilder().setContainment( new NetworkDomainContainmentBuilder().setNetworkDomainId(networkDomainId).build()).build()); addrEpBuilder.setEndpointGroup(ImmutableList.of(MappingUtils.EPG_EXTERNAL_ID)); addrEpBuilder.setTimestamp(System.currentTimeMillis()); return epRegistrator.registerEndpoint(addrEpBuilder.build()); }
private AddressEndpointRegBuilder createBasicMacAddrEpInputBuilder(Port port, NetworkDomainId networkContainment, @Nullable List<EndpointGroupId> endpointGroupsToAdd) { AddressEndpointRegBuilder addrEpbuilder = new AddressEndpointRegBuilder().setAddressType(MacAddressType.class) .setAddress(port.getMacAddress().getValue()) .setAddressType(MacAddressType.class) .setContextType(MappingUtils.L2_BRDIGE_DOMAIN) .setContextId(new ContextId(port.getNetworkId().getValue())) .setTenant(new TenantId(port.getTenantId().getValue())) .setTimestamp(System.currentTimeMillis()); List<EndpointGroupId> epgs = concatEndpointGroups(port.getSecurityGroups(), endpointGroupsToAdd); addrEpbuilder.setEndpointGroup(epgs); if (networkContainment != null) { addrEpbuilder.setNetworkContainment(new NetworkContainmentBuilder().setContainment( new NetworkDomainContainmentBuilder().setNetworkDomainId(networkContainment) .setNetworkDomainType(MappingUtils.SUBNET) .build()).build()); } return addrEpbuilder; }
@Override public ListenableFuture<RpcResult<Void>> processTemplatesAndSxpMasterDB( final EndpointPolicyTemplateBySgt epPolicyTemplate, final EndpointForwardingTemplateBySubnet epForwardingTemplate, final MasterDatabaseBinding masterDBBinding) { LOG.debug("processing ep-templates + sxpMasterDB entry: {} - {}", masterDBBinding.getSecurityGroupTag(), masterDBBinding.getIpPrefix()); // apply sxpMasterDB to policy template final Ipv4Prefix address = new Ipv4Prefix(epForwardingTemplate.getIpPrefix().getIpv4Prefix().getValue()); final NetworkContainment networkContainment = new NetworkContainmentBuilder() .setContainment(new NetworkDomainContainmentBuilder() .setNetworkDomainType(epForwardingTemplate.getNetworkContainment().getNetworkDomainType()) .setNetworkDomainId(epForwardingTemplate.getNetworkContainment().getNetworkDomainId()) .build()) .build(); final RegisterEndpointInput epInput = new RegisterEndpointInputBuilder().setAddressEndpointReg( Collections.singletonList(new AddressEndpointRegBuilder().setAddressType(IpPrefixType.class) .setAddress(address.getValue()) .setContextType(L3Context.class) .setContextId(epForwardingTemplate.getL3Context()) .setNetworkContainment(networkContainment) .setCondition(epPolicyTemplate.getConditions()) .setTenant(epPolicyTemplate.getTenant()) .setEndpointGroup(epPolicyTemplate.getEndpointGroups()) .build())) .build(); epForwardingTemplate.getL3Context(); return chainL3EPServiceIfEpAbsent(epInput); }