Search in sources :

Example 31 with Tunnels

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.

the class ElanItmUtils method buildItmEgressActions.

/**
 * Builds the list of actions to be taken when sending the packet over external port such as tunnel, physical
 * port etc.
 *
 * @param interfaceName
 *            the interface name
 * @param tunnelKey
 *            can be VNI for VxLAN tunnel interfaces, Gre Key for GRE
 *            tunnels, etc.
 * @return the list
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey) {
    List<Action> result = Collections.emptyList();
    try {
        GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActInput);
        if (egressActionsOutputFuture.get().isSuccessful()) {
            GetEgressActionsForInterfaceOutput egressActionsOutput = egressActionsOutputFuture.get().getResult();
            result = egressActionsOutput.getAction();
        }
    } catch (Exception e) {
        LOG.error("Error in RPC call getEgressActionsForInterface {}", e);
    }
    if (result == null || result.isEmpty()) {
        LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) GetEgressActionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 32 with Tunnels

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.

the class ElanUtils method getEgressActionsForInterface.

/**
 * Returns the list of Actions to be taken when sending the packet through
 * an Elan interface. Note that this interface can refer to an ElanInterface
 * where the Elan VM is attached to a DPN or an ITM tunnel interface where
 * Elan traffic can be sent through. In this latter case, the tunnelKey is
 * mandatory and it can hold serviceId for internal tunnels or the VNI for
 * external tunnels.
 *
 * @param ifName
 *            the if name
 * @param tunnelKey
 *            the tunnel key
 * @return the egress actions for interface
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> getEgressActionsForInterface(String ifName, Long tunnelKey) {
    List<Action> listAction = new ArrayList<>();
    try {
        GetEgressActionsForInterfaceInput getEgressActionInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).setTunnelKey(tunnelKey).build();
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput);
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
        } else {
            List<Action> actions = rpcResult.getResult().getAction();
            listAction = actions;
        }
    } catch (Exception e) {
        LOG.warn("Exception when egress actions for interface {}", ifName, e);
    }
    return listAction;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) ArrayList(java.util.ArrayList) GetEgressActionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException)

Example 33 with Tunnels

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method added.

@Override
protected void added(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, final PhysicalSwitchAugmentation phySwitchAdded) {
    String globalNodeId = getManagedByNodeId(identifier);
    final InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
    NodeId nodeId = getNodeId(identifier);
    if (TUNNEL_IP_NOT_AVAILABLE.test(phySwitchAdded)) {
        LOG.error("Could not find the /tunnel ips for node {}", nodeId.getValue());
        return;
    }
    final String psName = getPsName(identifier);
    LOG.trace("Received physical switch {} added event received for node {}", psName, nodeId.getValue());
    haOpClusteredListener.runAfterNodeIsConnected(globalNodeIid, (node) -> {
        LOG.trace("Running job for node {} ", globalNodeIid);
        if (!node.isPresent()) {
            LOG.error("Global node is absent {}", globalNodeId);
            return;
        }
        HAOpClusteredListener.addToCacheIfHAChildNode(globalNodeIid, node.get());
        if (hwvtepHACache.isHAEnabledDevice(globalNodeIid)) {
            LOG.trace("Ha enabled device {}", globalNodeIid);
            return;
        }
        LOG.trace("Updating cache for node {}", globalNodeIid);
        L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
        if (childConnectedAfterParent.test(l2GwDevice, globalNodeIid)) {
            LOG.trace("Device {} {} is already Connected by {}", psName, globalNodeId, l2GwDevice.getHwvtepNodeId());
            return;
        }
        InstanceIdentifier<Node> existingIid = globalNodeIid;
        if (l2GwDevice != null && l2GwDevice.getHwvtepNodeId() != null) {
            existingIid = HwvtepHAUtil.convertToInstanceIdentifier(l2GwDevice.getHwvtepNodeId());
        }
        if (parentConnectedAfterChild.test(l2GwDevice, globalNodeIid) && alreadyHasL2Gwids.test(l2GwDevice)) {
            LOG.error("Child node {} having l2gw configured became ha node " + " removing the l2device {} from all elan cache and provision parent node {}", existingIid, psName, globalNodeIid);
            ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(l2GwDevice.getHwvtepNodeId());
        }
        l2GwDevice = l2GatewayCache.addOrGet(psName);
        l2GwDevice.setConnected(true);
        l2GwDevice.setHwvtepNodeId(globalNodeId);
        List<TunnelIps> tunnelIps = phySwitchAdded.getTunnelIps();
        if (tunnelIps != null) {
            for (TunnelIps tunnelIp : tunnelIps) {
                IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
                l2GwDevice.addTunnelIp(tunnelIpAddr);
            }
        }
        handleAdd(l2GwDevice);
        elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ", () -> {
            try {
                updateConfigTunnelIp(identifier, phySwitchAdded);
            } catch (ReadFailedException e) {
                LOG.error("Failed to update tunnel ips {}", identifier);
            }
        });
        return;
    });
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TunnelIps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 34 with Tunnels

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method handleAdd.

/**
 * Handle add.
 *
 * @param l2GwDevice
 *            the l2 gw device
 */
private void handleAdd(L2GatewayDevice l2GwDevice) {
    final String psName = l2GwDevice.getDeviceName();
    final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
    Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
    for (final IpAddress tunnelIpAddr : tunnelIps) {
        if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
            LOG.debug("L2Gateway {} associated for {} physical switch; creating ITM tunnels for {}", l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
            l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
        } else {
            LOG.info("l2gw.provision.skip {}:{}", hwvtepNodeId, psName);
        }
    }
    elanClusterUtils.runOnlyInOwnerNode("Stale entry cleanup", () -> {
        InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
        InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
        staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
    });
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 35 with Tunnels

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.

the class TunnelCmd method areEqual.

@Override
public boolean areEqual(Tunnels updated, Tunnels orig) {
    InstanceIdentifier<TerminationPoint> remoteLocatorRefUpdated = (InstanceIdentifier<TerminationPoint>) updated.getRemoteLocatorRef().getValue();
    InstanceIdentifier<TerminationPoint> remoteLocatorRefOriginal = (InstanceIdentifier<TerminationPoint>) orig.getRemoteLocatorRef().getValue();
    TpId tpId1 = remoteLocatorRefUpdated.firstKeyOf(TerminationPoint.class).getTpId();
    TpId tpId2 = remoteLocatorRefOriginal.firstKeyOf(TerminationPoint.class).getTpId();
    return tpId1.equals(tpId2);
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Aggregations

ArrayList (java.util.ArrayList)14 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)9 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)8 TunnelsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey)8 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 BigInteger (java.math.BigInteger)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)7 ExecutionException (java.util.concurrent.ExecutionException)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)6 Tunnels (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels)6 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)5 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)5 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)5 TunnelsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)4