Search in sources :

Example 6 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface in project netvirt by opendaylight.

the class ElanInterfaceStateClusteredListener method handleExternalTunnelUpdate.

private void handleExternalTunnelUpdate(String interfaceName, Interface update) throws ElanException {
    ExternalTunnel externalTunnel = elanUtils.getExternalTunnel(interfaceName, LogicalDatastoreType.CONFIGURATION);
    if (externalTunnel != null) {
        LOG.debug("handling external tunnel update event for ext device dst {}  src {} ", externalTunnel.getDestinationDevice(), externalTunnel.getSourceDevice());
        elanInterfaceManager.handleExternalTunnelStateEvent(externalTunnel, update);
    } else {
        LOG.trace("External tunnel not found with interfaceName: {}", interfaceName);
    }
}
Also used : ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)

Example 7 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface in project netvirt by opendaylight.

the class ElanPacketInHandler method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived notification) {
    Class<? extends PacketInReason> pktInReason = notification.getPacketInReason();
    short tableId = notification.getTableId().getValue();
    if (pktInReason == NoMatch.class && tableId == NwConstants.ELAN_SMAC_TABLE) {
        ElanManagerCounters.unknown_smac_pktin_rcv.inc();
        try {
            byte[] data = notification.getPayload();
            Ethernet res = new Ethernet();
            res.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
            byte[] srcMac = res.getSourceMACAddress();
            final String macAddress = NWUtil.toStringMacAddress(srcMac);
            final BigInteger metadata = notification.getMatch().getMetadata().getMetadata();
            final long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
            long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
            Optional<IfIndexInterface> interfaceInfoOp = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
            if (!interfaceInfoOp.isPresent()) {
                LOG.warn("There is no interface for given portTag {}", portTag);
                return;
            }
            String interfaceName = interfaceInfoOp.get().getInterfaceName();
            LOG.debug("Received a packet with srcMac: {} ElanTag: {} PortTag: {} InterfaceName: {}", macAddress, elanTag, portTag, interfaceName);
            ElanTagName elanTagName = elanUtils.getElanInfoByElanTag(elanTag);
            if (elanTagName == null) {
                LOG.warn("not able to find elanTagName in elan-tag-name-map for elan tag {}", elanTag);
                return;
            }
            ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName);
            if (elanInterfaceMac == null) {
                LOG.info("There is no ElanInterfaceForwardingEntryDS created for interface :{}", interfaceName);
                return;
            }
            String elanName = elanTagName.getName();
            PhysAddress physAddress = new PhysAddress(macAddress);
            MacEntry oldMacEntry = elanUtils.getMacEntryForElanInstance(elanName, physAddress).orNull();
            boolean isVlanOrFlatProviderIface = interfaceManager.isExternalInterface(interfaceName);
            Optional<IpAddress> srcIpAddress = elanUtils.getSourceIpAddress(res);
            MacEntry newMacEntry = null;
            BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
            if (!srcIpAddress.isPresent()) {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            } else {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setIpPrefix(srcIpAddress.get()).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            }
            if (srcIpAddress.isPresent()) {
                String prefix = srcIpAddress.get().getIpv4Address().getValue();
                InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
                ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
                evpnUtils.advertisePrefix(elanInstance, macAddress, prefix, interfaceName, interfaceInfo.getDpId());
            }
            enqueueJobForMacSpecificTasks(macAddress, elanTag, interfaceName, elanName, physAddress, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
            ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
            if (interfaceInfo == null) {
                LOG.trace("Interface:{} is not present under Config DS", interfaceName);
                return;
            }
            enqueueJobForDPNSpecificTasks(macAddress, elanTag, interfaceName, physAddress, elanInstance, interfaceInfo, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
        } catch (PacketException e) {
            LOG.error("Failed to decode packet: {}", notification, e);
        }
    }
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) MacEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder) NoMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) MacEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey)

Example 8 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface in project netvirt by opendaylight.

the class EvpnUtils method advertiseEvpnRT2Routes.

@SuppressWarnings("checkstyle:IllegalCatch")
public void advertiseEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
    if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
        return;
    }
    String evpnName = evpnAugmentation.getEvpnName();
    List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
    if (macEntries == null || macEntries.isEmpty()) {
        LOG.trace("advertiseEvpnRT2Routes no elan mac entries found for {}", elanName);
        return;
    }
    String rd = vpnManager.getVpnRd(broker, evpnName);
    ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
    macEntries.stream().filter(isIpv4PrefixAvailable).forEach(macEntry -> {
        InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(macEntry.getInterface());
        if (interfaceInfo == null) {
            LOG.debug("advertiseEvpnRT2Routes, interfaceInfo is null for interface {}", macEntry.getInterface());
            return;
        }
        advertisePrefix(elanInfo, rd, macEntry.getMacAddress().getValue(), macEntry.getIpPrefix().getIpv4Address().getValue(), interfaceInfo.getInterfaceName(), interfaceInfo.getDpId());
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 9 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface in project netvirt by opendaylight.

the class HwvtepTerminationPointListener method getVlanBindings.

private List<VlanBindings> getVlanBindings(List<L2gatewayConnection> l2GwConns, NodeId hwvtepNodeId, String psName, String newPortId) {
    List<VlanBindings> vlanBindings = new ArrayList<>();
    for (L2gatewayConnection l2GwConn : l2GwConns) {
        L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GwConn.getL2gatewayId());
        if (l2Gateway == null) {
            LOG.error("L2Gateway with id {} is not present", l2GwConn.getL2gatewayId().getValue());
        } else {
            String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(l2GwConn.getNetworkId().getValue());
            List<Devices> l2Devices = l2Gateway.getDevices();
            for (Devices l2Device : l2Devices) {
                String l2DeviceName = l2Device.getDeviceName();
                if (l2DeviceName != null && l2DeviceName.equals(psName)) {
                    for (Interfaces deviceInterface : l2Device.getInterfaces()) {
                        if (deviceInterface.getInterfaceName().equals(newPortId)) {
                            if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
                                for (Integer vlanId : deviceInterface.getSegmentationIds()) {
                                    vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, vlanId, logicalSwitchName));
                                }
                            } else {
                                // Use defaultVlanId (specified in L2GatewayConnection) if Vlan
                                // ID not specified at interface level.
                                Integer segmentationId = l2GwConn.getSegmentId();
                                int defaultVlanId = segmentationId != null ? segmentationId : 0;
                                vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, defaultVlanId, logicalSwitchName));
                            }
                        }
                    }
                }
            }
        }
    }
    return vlanBindings;
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces) ArrayList(java.util.ArrayList) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 10 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface in project netvirt by opendaylight.

the class ElanBridgeManager method prepareIntegrationBridge.

private void prepareIntegrationBridge(Node ovsdbNode, Node brIntNode) {
    if (southboundUtils.getBridgeFromConfig(ovsdbNode, INTEGRATION_BRIDGE) == null) {
        LOG.debug("br-int in operational but not config, copying into config");
        copyBridgeToConfig(brIntNode);
    }
    Map<String, String> providerMappings = getOpenvswitchOtherConfigMap(ovsdbNode, PROVIDER_MAPPINGS_KEY);
    for (String value : providerMappings.values()) {
        if (southboundUtils.extractTerminationPointAugmentation(brIntNode, value) != null) {
            LOG.debug("prepareIntegrationBridge: port {} already exists on {}", value, INTEGRATION_BRIDGE);
            continue;
        }
        Node exBridgeNode = southboundUtils.readBridgeNode(ovsdbNode, value);
        if (exBridgeNode != null) {
            LOG.debug("prepareIntegrationBridge: bridge {} found. Patching to {}", value, INTEGRATION_BRIDGE);
            patchBridgeToBrInt(brIntNode, exBridgeNode, value);
        } else {
            LOG.debug("prepareIntegrationBridge: adding interface {} to {}", value, INTEGRATION_BRIDGE);
            if (!addPortToBridge(brIntNode, INTEGRATION_BRIDGE, value)) {
                LOG.error("Failed to add {} port to {}", value, brIntNode);
            }
        }
    }
    if (!addControllerToBridge(ovsdbNode, INTEGRATION_BRIDGE)) {
        LOG.error("Failed to set controller to existing integration bridge {}", brIntNode);
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)

Aggregations

BigInteger (java.math.BigInteger)131 ArrayList (java.util.ArrayList)117 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)69 ExecutionException (java.util.concurrent.ExecutionException)64 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)56 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)52 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)47 List (java.util.List)45 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)44 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)40 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)39 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)39 Logger (org.slf4j.Logger)39 LoggerFactory (org.slf4j.LoggerFactory)39 Collections (java.util.Collections)38 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)34 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)33 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)33 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)32