/** * Populate interface acl builder. * * @param interfaceAclBuilder the interface acl builder * @param port the port */ protected static void populateInterfaceAclBuilder(InterfaceAclBuilder interfaceAclBuilder, Port port) { // Handle security group enabled List<Uuid> securityGroups = port.getSecurityGroups(); if (securityGroups != null) { interfaceAclBuilder.setSecurityGroups(securityGroups); } List<AllowedAddressPairs> aclAllowedAddressPairs = NeutronvpnUtils.getAllowedAddressPairsForAclService( port.getMacAddress(), port.getFixedIps()); // Update the allowed address pair with the IPv6 LLA that is auto configured on the port. aclAllowedAddressPairs.add(NeutronvpnUtils.updateIPv6LinkLocalAddressForAclService(port.getMacAddress())); List<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.AllowedAddressPairs> portAllowedAddressPairs = port.getAllowedAddressPairs(); if (portAllowedAddressPairs != null) { aclAllowedAddressPairs.addAll(NeutronvpnUtils.getAllowedAddressPairsForAclService(portAllowedAddressPairs)); } interfaceAclBuilder.setAllowedAddressPairs(aclAllowedAddressPairs); }
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; }
result.setName(port.getName()); result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue())); if (port.getSecurityGroups() != null) { Set<NeutronSecurityGroup> allGroups = new HashSet<>(); NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this); INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface(); for (Uuid sgUuid : port.getSecurityGroups()) { NeutronSecurityGroup secGroup = sgIf.getNeutronSecurityGroup(sgUuid.getValue()); if (secGroup != null) {
result.setName(port.getName()); result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue())); if (port.getSecurityGroups() != null) { Set<NeutronSecurityGroup> allGroups = new HashSet<>(); NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this); INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface(); for (Uuid sgUuid : port.getSecurityGroups()) { NeutronSecurityGroup secGroup = sgIf.getNeutronSecurityGroup(sgUuid.getValue()); if (secGroup != null) {
@Deprecated private void modifyL3ContextForEndpoints(Port port, FixedIps resolvedPortFixedIp, ContextId newContextId) { org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder epInBuilder = createBasicEndpointInputBuilder(port); epInBuilder.setNetworkContainment(new NetworkDomainId(resolvedPortFixedIp.getSubnetId().getValue())); L3Address l3Address = new L3AddressBuilder().setL3Context(new L3ContextId(newContextId)) .setIpAddress(resolvedPortFixedIp.getIpAddress()) .build(); epInBuilder.setL3Address(ImmutableList.of(l3Address)); List<EndpointGroupId> epgsFromSecGroups = resolveEpgIdsFromSecGroups(port.getSecurityGroups()); epgsFromSecGroups.add(NetworkClient.EPG_ID); epInBuilder.setEndpointGroups(epgsFromSecGroups); epRegistrator.registerEndpoint(epInBuilder.build()); // unregister L3EP L3ContextId oldL3Context = new L3ContextId(port.getNetworkId().getValue()); L3 l3 = new L3Builder().setL3Context(oldL3Context).setIpAddress(resolvedPortFixedIp.getIpAddress()).build(); org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput epUnreg = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder().setL3( ImmutableList.of(l3)) .build(); epRegistrator.unregisterEndpoint(epUnreg); }
result.setName(port.getName()); result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue())); if (port.getSecurityGroups() != null) { Set<NeutronSecurityGroup> allGroups = new HashSet<>(); NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this); INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface(); for (Uuid sgUuid : port.getSecurityGroups()) { NeutronSecurityGroup secGroup = sgIf.getNeutronSecurityGroup(sgUuid.getValue()); if (secGroup != null) {
result.setName(port.getName()); result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue())); if (port.getSecurityGroups() != null) { Set<NeutronSecurityGroup> allGroups = new HashSet<>(); NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this); INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface(); for (Uuid sgUuid : port.getSecurityGroups()) { NeutronSecurityGroup secGroup = sgIf.getNeutronSecurityGroup(sgUuid.getValue()); if (secGroup != null) {
result.setName(port.getName()); result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue())); if (port.getSecurityGroups() != null) { final Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>(); for (final Uuid sgUuid : port.getSecurityGroups()) { final NeutronSecurityGroup sg = new NeutronSecurityGroup(); sg.setID(sgUuid.getValue());
interfaceAclBuilder.setSecurityGroups( NeutronvpnUtils.getUpdatedSecurityGroups(interfaceAcl.getSecurityGroups(), portOriginal.getSecurityGroups(), portUpdated.getSecurityGroups())); List<AllowedAddressPairs> updatedAddressPairs = NeutronvpnUtils.getUpdatedAllowedAddressPairs( interfaceAcl.getAllowedAddressPairs(), portOriginal.getAllowedAddressPairs(),
List<EndpointGroupId> epgsFromSecGroups = resolveEpgIdsFromSecGroups(port.getSecurityGroups()); epgsFromSecGroups.add(NetworkService.EPG_ID); List<EndpointGroupId> epgsFromSecGroups = resolveEpgIdsFromSecGroups(port.getSecurityGroups()); epgsFromSecGroups.add(NetworkService.EPG_ID); AddressEndpointRegBuilder l3BaseEp = null; Optional<FixedIps> firstFixedIps = PortUtils.resolveFirstFixedIps(port); List<EndpointGroupId> epgsFromSecGroups = resolveEpgIdsFromSecGroups(port.getSecurityGroups()); epgsFromSecGroups.add(NetworkClient.EPG_ID); if (firstFixedIps.isPresent()) {
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; }