Search in sources :

Example 1 with FixedIps

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

the class VpnManagerImpl method removeArpResponderFlowsToExternalNetworkIps.

@Override
public void removeArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId) {
    if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
        LOG.warn("Failed to remove arp responder flows for router {}. DPN id is missing.", id);
        return;
    }
    String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
    if (extInterfaceName == null) {
        LOG.warn("Failed to remove responder flows for {}. No external interface found for DPN id {}", id, dpnId);
        return;
    }
    Interface extInterfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, extInterfaceName);
    if (extInterfaceState == null) {
        LOG.debug("No interface state found for interface {}. Delaying responder flows for {}", extInterfaceName, id);
        return;
    }
    Integer lportTag = extInterfaceState.getIfIndex();
    if (lportTag == null) {
        LOG.debug("No Lport tag found for interface {}. Delaying flows for router-id {}", extInterfaceName, id);
        return;
    }
    if (macAddress == null) {
        LOG.debug("Failed to remove arp responder flows for router-gateway-ip {} for router {}." + "External Gw MacAddress is missing.", fixedIps, id);
        return;
    }
    removeArpResponderFlowsToExternalNetworkIps(id, fixedIps, dpnId, extInterfaceName, lportTag);
}
Also used : BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 2 with FixedIps

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

the class NatUtil method getNeutronPortForIp.

public static Port getNeutronPortForIp(DataBroker broker, IpAddress targetIP, String deviceType) {
    List<Port> ports = getNeutronPorts(broker);
    for (Port port : ports) {
        if (deviceType.equals(port.getDeviceOwner()) && port.getFixedIps() != null) {
            for (FixedIps ip : port.getFixedIps()) {
                if (Objects.equals(ip.getIpAddress(), targetIP)) {
                    return port;
                }
            }
        }
    }
    LOG.error("getNeutronPortForIp : Neutron Port missing for IP:{} DeviceType:{}", targetIP, deviceType);
    return null;
}
Also used : VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.IpPort) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Example 3 with FixedIps

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

the class InterfaceStateEventListener method removeSnatEntriesForPort.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeSnatEntriesForPort(String interfaceName, String routerName) {
    Long routerId = NatUtil.getVpnId(dataBroker, routerName);
    if (routerId == NatConstants.INVALID_ID) {
        LOG.error("removeSnatEntriesForPort : routerId not found for routername {}", routerName);
        return;
    }
    BigInteger naptSwitch = getNaptSwitchforRouter(dataBroker, routerName);
    if (naptSwitch == null || naptSwitch.equals(BigInteger.ZERO)) {
        LOG.error("removeSnatEntriesForPort : NaptSwitch is not elected for router {} with Id {}", routerName, routerId);
        return;
    }
    // getInternalIp for port
    List<String> fixedIps = getFixedIpsForPort(interfaceName);
    if (fixedIps == null) {
        LOG.warn("removeSnatEntriesForPort : Internal Ips not found for InterfaceName {} in router {} with id {}", interfaceName, routerName, routerId);
        return;
    }
    for (String internalIp : fixedIps) {
        LOG.debug("removeSnatEntriesForPort : Internal Ip retrieved for interface {} is {} in router with Id {}", interfaceName, internalIp, routerId);
        IpPort ipPort = NatUtil.getInternalIpPortInfo(dataBroker, routerId, internalIp);
        if (ipPort == null) {
            LOG.debug("removeSnatEntriesForPort : no snatint-ip-port-map found for ip:{}", internalIp);
            continue;
        }
        for (IntIpProtoType protoType : ipPort.getIntIpProtoType()) {
            ProtocolTypes protocol = protoType.getProtocol();
            for (Integer portnum : protoType.getPorts()) {
                // build and remove the flow in outbound table
                try {
                    removeNatFlow(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, routerId, internalIp, portnum);
                } catch (Exception ex) {
                    LOG.error("removeSnatEntriesForPort : Failed to remove snat flow for internalIP {} with " + "Port {} protocol {} for routerId {} in OUTBOUNDTABLE of NaptSwitch {}", internalIp, portnum, protocol, routerId, naptSwitch, ex);
                }
                // Get the external IP address and the port from the model
                NAPTEntryEvent.Protocol proto = protocol.toString().equals(ProtocolTypes.TCP.toString()) ? NAPTEntryEvent.Protocol.TCP : NAPTEntryEvent.Protocol.UDP;
                IpPortExternal ipPortExternal = NatUtil.getExternalIpPortMap(dataBroker, routerId, internalIp, String.valueOf(portnum), proto);
                if (ipPortExternal == null) {
                    LOG.error("removeSnatEntriesForPort : Mapping for internalIp {} with port {} is not found in " + "router with Id {}", internalIp, portnum, routerId);
                    return;
                }
                String externalIpAddress = ipPortExternal.getIpAddress();
                Integer portNumber = ipPortExternal.getPortNum();
                // build and remove the flow in inboundtable
                try {
                    removeNatFlow(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, routerId, externalIpAddress, portNumber);
                } catch (Exception ex) {
                    LOG.error("removeSnatEntriesForPort : Failed to remove snat flow internalIP {} with " + "Port {} protocol {} for routerId {} in INBOUNDTABLE of naptSwitch {}", externalIpAddress, portNumber, protocol, routerId, naptSwitch, ex);
                }
                String internalIpPort = internalIp + ":" + portnum;
                // delete the entry from IntExtIpPortMap DS
                try {
                    naptManager.removeFromIpPortMapDS(routerId, internalIpPort, proto);
                    naptManager.removePortFromPool(internalIpPort, externalIpAddress);
                } catch (Exception ex) {
                    LOG.error("removeSnatEntriesForPort : releaseIpExtPortMapping failed, Removal of " + "ipportmap {} for router {} failed", internalIpPort, routerId, ex);
                }
            }
        }
        // delete the entry from SnatIntIpPortMap DS
        LOG.debug("removeSnatEntriesForPort : Removing InternalIp:{} on router {}", internalIp, routerId);
        naptManager.removeFromSnatIpPortDS(routerId, internalIp);
    }
}
Also used : BigInteger(java.math.BigInteger) ProtocolTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProtocolTypes) BigInteger(java.math.BigInteger) IntIpProtoType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.ip.port.IntIpProtoType) IpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.snatint.ip.port.map.intip.port.map.IpPort) IpPortExternal(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.ip.port.map.IpPortExternal) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with FixedIps

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

the class InterfaceStateEventListener method getFixedIpsForPort.

private List<String> getFixedIpsForPort(String interfname) {
    LOG.debug("getFixedIpsForPort : getFixedIpsForPort method is called for interface {}", interfname);
    try {
        Future<RpcResult<GetFixedIPsForNeutronPortOutput>> result = neutronVpnService.getFixedIPsForNeutronPort(new GetFixedIPsForNeutronPortInputBuilder().setPortId(new Uuid(interfname)).build());
        RpcResult<GetFixedIPsForNeutronPortOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.error("getFixedIpsForPort : RPC Call to GetFixedIPsForNeutronPortOutput returned with Errors {}", rpcResult.getErrors());
        } else {
            return rpcResult.getResult().getFixedIPs();
        }
    } catch (InterruptedException | ExecutionException | NullPointerException ex) {
        LOG.error("getFixedIpsForPort : Exception while receiving fixedIps for port {}", interfname, ex);
    }
    return null;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetFixedIPsForNeutronPortOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput) ExecutionException(java.util.concurrent.ExecutionException) GetFixedIPsForNeutronPortInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortInputBuilder)

Example 5 with FixedIps

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

the class NeutronPortChangeListener method add.

@Override
protected void add(InstanceIdentifier<Port> identifier, Port port) {
    if (port.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_GATEWAY)) {
        // Todo: revisit when IPv6 north-south support is implemented.
        LOG.info("IPv6Service (TODO): Skipping router_gateway port {} for add event", port);
        return;
    }
    LOG.debug("Add port notification handler is invoked for port {} ", port);
    List<FixedIps> ipList = port.getFixedIps();
    for (FixedIps fixedip : ipList) {
        if (fixedip.getIpAddress().getIpv4Address() != null) {
            continue;
        }
        addInterfaceInfo(port, fixedip);
    }
}
Also used : FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Aggregations

FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)27 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)20 ArrayList (java.util.ArrayList)17 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)11 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)6 HashSet (java.util.HashSet)5 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)5 BigInteger (java.math.BigInteger)4 Test (org.junit.Test)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)4 ExecutionException (java.util.concurrent.ExecutionException)3 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)3 PortBindingExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Collections (java.util.Collections)2 List (java.util.List)2