Search in sources :

Example 86 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.

the class TepCommandHelper method showState.

@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showState(Collection<StateTunnelList> tunnelLists, boolean tunnelMonitorEnabled, CommandSession session) throws TepException {
    if (tunnelLists == null || tunnelLists.isEmpty()) {
        handleError("No Internal Tunnels Exist", session);
        return;
    }
    if (!tunnelMonitorEnabled) {
        if (session != null) {
            session.getConsole().println("Tunnel Monitoring is Off");
        }
    }
    String displayFormat = "%-16s  %-16s  %-16s  %-16s  %-16s  %-10s  %-10s";
    System.out.println(String.format(displayFormat, "Tunnel Name", "Source-DPN", "Destination-DPN", "Source-IP", "Destination-IP", "Trunk-State", "Transport Type"));
    System.out.println("-----------------------------------------------------------------------------------------" + "--------------------------------------------");
    for (StateTunnelList tunnelInst : tunnelLists) {
        // Display only the internal tunnels
        if (tunnelInst.getDstInfo().getTepDeviceType().equals(TepTypeInternal.class)) {
            String tunnelInterfaceName = tunnelInst.getTunnelInterfaceName();
            LOG.trace("tunnelInterfaceName::: {}", tunnelInterfaceName);
            String tunnelState = ITMConstants.TUNNEL_STATE_UNKNOWN;
            if (tunnelInst.getOperState() == TunnelOperStatus.Up) {
                tunnelState = ITMConstants.TUNNEL_STATE_UP;
            } else if (tunnelInst.getOperState() == TunnelOperStatus.Down) {
                tunnelState = ITMConstants.TUNNEL_STATE_DOWN;
            }
            Class<? extends TunnelTypeBase> tunType = tunnelInst.getTransportType();
            String tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
            if (tunType.equals(TunnelTypeVxlan.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
            } else if (tunType.equals(TunnelTypeGre.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_GRE;
            } else if (tunType.equals(TunnelTypeMplsOverGre.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_MPLSoGRE;
            } else if (tunType.equals(TunnelTypeLogicalGroup.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
            }
            System.out.println(String.format(displayFormat, tunnelInst.getTunnelInterfaceName(), tunnelInst.getSrcInfo().getTepDeviceId(), tunnelInst.getDstInfo().getTepDeviceId(), new String(tunnelInst.getSrcInfo().getTepIp().getValue()), new String(tunnelInst.getDstInfo().getTepIp().getValue()), tunnelState, tunnelType));
        }
    }
}
Also used : TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)

Example 87 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.

the class InterfaceManagerCommonUtils method addTunnelIngressFlow.

public void addTunnelIngressFlow(IfTunnel tunnel, BigInteger dpnId, long portNo, String interfaceName, int ifIndex) {
    if (isTunnelWithoutIngressFlow(tunnel)) {
        return;
    }
    LOG.debug("add tunnel ingress flow for {}", interfaceName);
    List<MatchInfoBase> matches = new ArrayList<>();
    matches.add(new MatchInPort(dpnId, portNo));
    if (BooleanUtils.isTrue(tunnel.isTunnelRemoteIpFlow())) {
        matches.add(new NxMatchTunnelSourceIp(tunnel.getTunnelDestination().getIpv4Address()));
    }
    if (BooleanUtils.isTrue(tunnel.isTunnelSourceIpFlow())) {
        matches.add(new NxMatchTunnelDestinationIp(tunnel.getTunnelSource().getIpv4Address()));
    }
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionWriteMetadata(MetaDataUtil.getLportTagMetaData(ifIndex).or(BigInteger.ONE), MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG));
    short tableId = tunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class) ? NwConstants.L3_LFIB_TABLE : tunnel.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE : NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL;
    mkInstructions.add(new InstructionGotoTable(tableId));
    mdsalApiManager.batchedAddFlow(dpnId, buildTunnelIngressFlowEntity(dpnId, interfaceName, matches, mkInstructions));
}
Also used : NxMatchTunnelDestinationIp(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTunnelDestinationIp) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) NxMatchTunnelSourceIp(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTunnelSourceIp) MatchInPort(org.opendaylight.genius.mdsalutil.matches.MatchInPort) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre)

Example 88 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.

the class InterfaceManagerCommonUtils method updateOpState.

/*
     * update operational state of interface based on events like tunnel
     * monitoring
     */
public static void updateOpState(WriteTransaction transaction, String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus) {
    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    LOG.debug("updating tep interface state as {} for {}", operStatus.name(), interfaceName);
    InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setOperStatus(operStatus);
    ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
    transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), false);
}
Also used : InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)

Example 89 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.

the class InterfaceInventoryStateListener method remove.

@Override
protected void remove(InstanceIdentifier<FlowCapableNodeConnector> key, FlowCapableNodeConnector flowCapableNodeConnectorOld) {
    if (interfacemgrProvider.isItmDirectTunnelsEnabled() && interfaceManagerCommonUtils.isTunnelInternal(flowCapableNodeConnectorOld.getName())) {
        LOG.debug("ITM Direct Tunnels is enabled, ignoring node connector removed for internal tunnel {}", flowCapableNodeConnectorOld.getName());
        return;
    }
    if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY, IfmConstants.INTERFACE_CONFIG_ENTITY)) {
        return;
    }
    LOG.debug("Received NodeConnector Remove Event: {}, {}", key, flowCapableNodeConnectorOld);
    NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
    String portName = InterfaceManagerCommonUtils.getPortNameForInterface(nodeConnectorId, flowCapableNodeConnectorOld.getName());
    remove(nodeConnectorId, null, flowCapableNodeConnectorOld, portName, true);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)

Example 90 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.

the class InterfaceHelper method buildVxlanTunnelInterfaceFromInfo.

public static Interface buildVxlanTunnelInterfaceFromInfo(TunnelInterfaceDetails tunnelInterfaceDetails) {
    InterfaceInfo interfaceInfo = tunnelInterfaceDetails.getInterfaceInfo();
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(interfaceInfo.getDpId()).setParentInterface(interfaceInfo.getInterfaceName()).build();
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(new IpAddress(new Ipv4Address(tunnelInterfaceDetails.getDstIp()))).setTunnelGateway(new IpAddress(new Ipv4Address(DEFAULT_GW))).setTunnelSource(new IpAddress(new Ipv4Address(tunnelInterfaceDetails.getSrcIp()))).setTunnelInterfaceType(TunnelTypeVxlan.class).setInternal(!tunnelInterfaceDetails.isExternal()).setTunnelRemoteIpFlow(false).setTunnelOptions(Collections.emptyList()).build();
    return new InterfaceBuilder().setKey(new InterfaceKey(interfaceInfo.getInterfaceName())).setName(interfaceInfo.getInterfaceName()).setDescription("Tunnel interface").setEnabled(true).setType(Tunnel.class).addAugmentation(ParentRefs.class, parentRefs).addAugmentation(IfTunnel.class, tunnel).build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Aggregations

BigInteger (java.math.BigInteger)45 ArrayList (java.util.ArrayList)43 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)27 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)23 ExecutionException (java.util.concurrent.ExecutionException)19 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)17 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)17 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)17 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)16 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)15 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)14 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)12 List (java.util.List)12 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)12 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)12 Test (org.junit.Test)8 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)7 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)7