Search in sources :

Example 1 with FixedIpsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleRouterInterfaceRemoved.

private void handleRouterInterfaceRemoved(Port routerPort) {
    if (routerPort.getDeviceId() != null) {
        Uuid routerId = new Uuid(routerPort.getDeviceId());
        Uuid infNetworkId = routerPort.getNetworkId();
        elanService.removeKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
        Uuid vpnId = ObjectUtils.defaultIfNull(neutronvpnUtils.getVpnForRouter(routerId, true), routerId);
        Map<FixedIpsKey, FixedIps> keyFixedIpsMap = routerPort.nonnullFixedIps();
        boolean vpnInstanceInternetIpVersionRemoved = false;
        Uuid vpnInstanceInternetUuid = null;
        for (FixedIps portIP : keyFixedIpsMap.values()) {
            // Internet VPN : flush InternetVPN first
            Uuid subnetId = portIP.getSubnetId();
            Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
            if (sn != null && sn.getInternetVpnId() != null) {
                if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, sn.getInternetVpnId())) {
                    vpnInstanceInternetIpVersionRemoved = true;
                    vpnInstanceInternetUuid = sn.getInternetVpnId();
                }
                nvpnManager.updateVpnInternetForSubnet(sn, sn.getInternetVpnId(), false);
            }
        }
        /* Remove ping responder for router interfaces
             *  A router interface reference in a VPN will have to be removed before the host interface references
             * for that subnet in the VPN are removed. This is to ensure that the FIB Entry of the router interface
             *  is not the last entry to be removed for that subnet in the VPN.
             *  If router interface FIB entry is the last to be removed for a subnet in a VPN , then all the host
             *  interface references in the vpn will already have been cleared, which will cause failures in
             *  cleanup of router interface flows*/
        nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(), null, /* vpn-id */
        null);
        // update RouterInterfaces map
        LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
            IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
            for (FixedIps portIP : keyFixedIpsMap.values()) {
                Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
                if (null == sn) {
                    LOG.error("Subnetmap for subnet {} not found", portIP.getSubnetId().getValue());
                    continue;
                }
                // router Port have either IPv4 or IPv6, never both
                ipVersion = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
                String ipValue = portIP.getIpAddress().stringValue();
                neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, confTx);
                // NOTE:  Please donot change the order of calls to removeSubnetFromVpn and
                // and updateSubnetNodeWithFixedIP
                nvpnManager.removeSubnetFromVpn(vpnId, sn, sn.getInternetVpnId());
                nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
            }
            nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
            deleteElanInterface(routerPort.getUuid().getValue(), confTx);
            deleteOfPortInterface(routerPort, confTx);
            jobCoordinator.enqueueJob(routerId.toString(), () -> {
                nvpnNatManager.handleSubnetsForExternalRouter(routerId);
                return Collections.emptyList();
            });
            if (neutronvpnUtils.shouldVpnHandleIpVersionChoiceChange(ipVersion, routerId, false)) {
                LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {}", ipVersion, vpnId.getValue());
                neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
            }
        }), LOG, "Error handling interface removal");
        if (vpnInstanceInternetIpVersionRemoved) {
            neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(), IpVersionChoice.IPV6, false);
            neutronvpnUtils.updateVpnInstanceWithFallback(routerId, vpnInstanceInternetUuid, false);
        }
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) JsonObject(com.google.gson.JsonObject) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) LoggerFactory(org.slf4j.LoggerFactory) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RoutersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) NeutronvpnConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig) PreDestroy(javax.annotation.PreDestroy) NeutronConstants(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) Nullable(org.eclipse.jdt.annotation.Nullable) Gson(com.google.gson.Gson) Locale(java.util.Locale) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Hostconfig(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig) Duration(java.time.Duration) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) PortIdToSubport(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubport) NeutronUtils(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronUtils) Set(java.util.Set) Collectors(java.util.stream.Collectors) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Objects(java.util.Objects) JsonArray(com.google.gson.JsonArray) List(java.util.List) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) Optional(java.util.Optional) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) HashMap(java.util.HashMap) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ObjectUtils(org.apache.commons.lang3.ObjectUtils) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) Logger(org.slf4j.Logger) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) FloatingIpIdToPortMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.port.info.FloatingIpIdToPortMappingBuilder) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) ExecutionException(java.util.concurrent.ExecutionException) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ElanInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) FloatingIpIdToPortMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.port.info.FloatingIpIdToPortMappingKey) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 2 with FixedIpsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleNeutronPortCreated.

private void handleNeutronPortCreated(final Port port) {
    final String portName = port.getUuid().getValue();
    final Uuid portId = port.getUuid();
    final String networkId = port.getNetworkId().getValue();
    final Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
    if (NeutronConstants.IS_ODL_DHCP_PORT.test(port)) {
        return;
    }
    if (!NeutronUtils.isPortVnicTypeNormal(port) && (!isPortTypeSwitchdev(port) || !isSupportedVnicTypeByHost(port, NeutronConstants.VNIC_TYPE_DIRECT))) {
        for (FixedIps ip : keyFixedIpsMap.values()) {
            nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), null, portId);
        }
        LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "OF Port interfaces are not created", portName);
        return;
    }
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        // add direct port to subnetMaps config DS
        // TODO: for direct port as well, operations should be carried out per subnet based on port IP
        ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            LOG.info("Of-port-interface creation for port {}", portName);
            // Create of-port interface for this neutron port
            String portInterfaceName = createOfPortInterface(port, tx);
            LOG.debug("Creating ELAN Interface for port {}", portName);
            createElanInterface(port, portInterfaceName, tx);
            Set<Uuid> vpnIdList = new HashSet<>();
            Set<Uuid> routerIds = new HashSet<>();
            for (FixedIps ip : keyFixedIpsMap.values()) {
                Subnetmap subnetMap = nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), portId, null);
                if (subnetMap != null && subnetMap.getInternetVpnId() != null) {
                    if (!vpnIdList.contains(subnetMap.getInternetVpnId())) {
                        vpnIdList.add(subnetMap.getInternetVpnId());
                    }
                }
                if (subnetMap != null && subnetMap.getVpnId() != null) {
                    // can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
                    // obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
                    Uuid vpnId = subnetMap.getVpnId();
                    if (vpnId != null) {
                        vpnIdList.add(vpnId);
                    }
                }
                if (subnetMap != null && subnetMap.getRouterId() != null) {
                    routerIds.add(subnetMap.getRouterId());
                }
            }
            if (!vpnIdList.isEmpty()) {
                // create new vpn-interface for neutron port
                LOG.debug("handleNeutronPortCreated: Adding VPN Interface for port {} from network {}", portName, networkId);
                nvpnManager.createVpnInterface(vpnIdList, port, tx);
                for (Uuid routerId : routerIds) {
                    nvpnManager.addToNeutronRouterInterfacesMap(routerId, port.getUuid().getValue());
                }
            }
        });
        LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortCreated: Failed for port {} with networkId {}", portName, networkId);
        return Collections.singletonList(future);
    });
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) HashSet(java.util.HashSet)

Example 3 with FixedIpsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.

the class SubnetRouteInterfaceStateChangeListener method getSubnetId.

@NonNull
protected List<Uuid> getSubnetId(Interface intrf) {
    List<Uuid> listSubnetIds = new ArrayList<>();
    if (!NeutronUtils.isUuid(intrf.getName())) {
        LOG.debug("SubnetRouteInterfaceListener: Interface {} doesn't have valid uuid pattern", intrf.getName());
        return listSubnetIds;
    }
    PortOpDataEntry portOpEntry = subOpDpnManager.getPortOpDataEntry(intrf.getName());
    if (portOpEntry != null) {
        List<Uuid> subnet = portOpEntry.getSubnetIds();
        if (subnet != null) {
            return subnet;
        }
        return listSubnetIds;
    }
    LOG.trace("SubnetRouteInterfaceListener : Received Port {} event for {} that is not part of subnetRoute", intrf.getOperStatus(), intrf.getName());
    Port port = neutronVpnManager.getNeutronPort(intrf.getName());
    if (port == null) {
        return listSubnetIds;
    }
    Map<FixedIpsKey, FixedIps> portIpsMap = port.getFixedIps();
    if (portIpsMap != null) {
        for (FixedIps portIp : portIpsMap.values()) {
            listSubnetIds.add(portIp.getSubnetId());
        }
    }
    return listSubnetIds;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) PortOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 4 with FixedIpsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleNeutronPortDeleted.

private void handleNeutronPortDeleted(final Port port) {
    final String portName = port.getUuid().getValue();
    final Uuid portId = port.getUuid();
    final Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
    if (!NeutronUtils.isPortVnicTypeNormal(port) && !isPortTypeSwitchdev(port)) {
        for (FixedIps ip : keyFixedIpsMap.values()) {
            // remove direct port from subnetMaps config DS
            // TODO: for direct port as well, operations should be carried out per subnet based on port IP
            nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), null, portId);
        }
        LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "Skipping OF Port interfaces removal", portName);
        return;
    }
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
            Uuid vpnId = null;
            Set<Uuid> routerIds = new HashSet<>();
            Uuid internetVpnId = null;
            for (FixedIps ip : keyFixedIpsMap.values()) {
                Subnetmap subnetMap = nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), portId, null);
                if (subnetMap == null) {
                    continue;
                }
                if (subnetMap.getVpnId() != null) {
                    // can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
                    // obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
                    vpnId = subnetMap.getVpnId();
                }
                if (subnetMap.getRouterId() != null) {
                    routerIds.add(subnetMap.getRouterId());
                }
                internetVpnId = subnetMap.getInternetVpnId();
                if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(port.getDeviceOwner()) || NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(port.getDeviceOwner())) {
                    String ipAddress = ip.getIpAddress().stringValue();
                    if (vpnId != null) {
                        neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipAddress, confTx);
                    }
                    if (internetVpnId != null) {
                        neutronvpnUtils.removeVpnPortFixedIpToPort(internetVpnId.getValue(), ipAddress, confTx);
                    }
                }
            }
            if (vpnId != null || internetVpnId != null) {
                // remove vpn-interface for this neutron port
                LOG.debug("removing VPN Interface for port {}", portName);
                if (!routerIds.isEmpty()) {
                    for (Uuid routerId : routerIds) {
                        nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, portName);
                    }
                }
                nvpnManager.deleteVpnInterface(portName, null, /* vpn-id */
                confTx);
            }
            // Remove of-port interface for this neutron port
            // ELAN interface is also implicitly deleted as part of this operation
            LOG.debug("Of-port-interface removal for port {}", portName);
            deleteOfPortInterface(port, confTx);
            // dissociate fixedIP from floatingIP if associated
            nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
        });
        LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortDeleted: Failed to update interface {} with networkId", portName, port.getNetworkId().getValue());
        return Collections.singletonList(future);
    });
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) HashSet(java.util.HashSet)

Example 5 with FixedIpsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.

the class NeutronSubnetGwMacResolver method sendArpRequestsToExtGatewayTask.

private void sendArpRequestsToExtGatewayTask(Router router) {
    LOG.trace("Send ARP requests to external GW for router {}", router);
    Port extPort = getRouterExtGatewayPort(router);
    if (extPort == null) {
        LOG.trace("External GW port for router {} is missing", router.getUuid().getValue());
        return;
    }
    String extInterface = getExternalInterface(router);
    if (extInterface == null) {
        LOG.trace("No external interface defined for router {}", router.getUuid().getValue());
        return;
    }
    Map<FixedIpsKey, FixedIps> keyFixedIpsMap = extPort.getFixedIps();
    if (keyFixedIpsMap == null || keyFixedIpsMap.isEmpty()) {
        LOG.trace("External GW port {} for router {} has no fixed IPs", extPort.getUuid().getValue(), router.getUuid().getValue());
        return;
    }
    MacAddress macAddress = extPort.getMacAddress();
    if (macAddress == null) {
        LOG.trace("External GW port {} for router {} has no mac address", extPort.getUuid().getValue(), router.getUuid().getValue());
        return;
    }
    for (FixedIps fixIp : keyFixedIpsMap.values()) {
        Uuid subnetId = fixIp.getSubnetId();
        IpAddress srcIpAddress = fixIp.getIpAddress();
        IpAddress dstIpAddress = getExternalGwIpAddress(subnetId);
        String srcIpAddressString = srcIpAddress.stringValue();
        String dstIpAddressString = dstIpAddress.stringValue();
        if (NWUtil.isIpv4Address(srcIpAddressString)) {
            sendArpRequest(srcIpAddress, dstIpAddress, macAddress, extInterface);
        } else {
            sendNeighborSolication(new Ipv6Address(srcIpAddressString), macAddress, new Ipv6Address(dstIpAddressString), extInterface);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)

Aggregations

FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)9 FixedIpsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)7 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)4 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)3 Nullable (org.eclipse.jdt.annotation.Nullable)2 Strings (com.google.common.base.Strings)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Locale (java.util.Locale)1