Search in sources :

Example 61 with Tunnel

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

the class ItmUtils method buildLogicalTunnelInterface.

public static Interface buildLogicalTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
    builder.addAugmentation(ParentRefs.class, parentRefs);
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_IP_ADDRESS)).setTunnelSource(IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_IP_ADDRESS)).setInternal(true).setMonitorEnabled(false).setTunnelInterfaceType(TunnelTypeLogicalGroup.class).setTunnelRemoteIpFlow(false).build();
    builder.addAugmentation(IfTunnel.class, tunnel);
    return builder.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) 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) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)

Example 62 with Tunnel

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

the class ItmUtils method updateTunnelsCache.

private static void updateTunnelsCache(DataBroker broker) {
    List<InternalTunnel> internalTunnels = getAllInternalTunnels(broker);
    for (InternalTunnel tunnel : internalTunnels) {
        ITM_CACHE.addInternalTunnel(tunnel);
    }
    List<ExternalTunnel> externalTunnels = getAllExternalTunnels(broker);
    for (ExternalTunnel tunnel : externalTunnels) {
        ITM_CACHE.addExternalTunnel(tunnel);
    }
}
Also used : ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel)

Example 63 with Tunnel

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

the class ItmUtils method buildStateTunnelList.

public static StateTunnelList buildStateTunnelList(StateTunnelListKey tlKey, String name, boolean state, TunnelOperStatus tunOpStatus, IInterfaceManager ifaceManager, DataBroker broker) {
    StateTunnelListBuilder stlBuilder = new StateTunnelListBuilder();
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = ItmUtils.getInterface(name, ifaceManager);
    IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
    ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
    if (ifTunnel == null || parentRefs == null) {
        return null;
    }
    DstInfoBuilder dstInfoBuilder = new DstInfoBuilder();
    SrcInfoBuilder srcInfoBuilder = new SrcInfoBuilder();
    dstInfoBuilder.setTepIp(ifTunnel.getTunnelDestination());
    srcInfoBuilder.setTepIp(ifTunnel.getTunnelSource());
    // TODO: Add/Improve logic for device type
    InternalTunnel internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
    ExternalTunnel externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
    if (internalTunnel == null && externalTunnel == null) {
        // both not present in cache. let us update and try again.
        ItmUtils.updateTunnelsCache(broker);
        internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
        externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
    }
    if (internalTunnel != null) {
        srcInfoBuilder.setTepDeviceId(internalTunnel.getSourceDPN().toString()).setTepDeviceType(TepTypeInternal.class);
        dstInfoBuilder.setTepDeviceId(internalTunnel.getDestinationDPN().toString()).setTepDeviceType(TepTypeInternal.class);
        stlBuilder.setTransportType(internalTunnel.getTransportType());
    } else if (externalTunnel != null) {
        ExternalTunnel tunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
        srcInfoBuilder.setTepDeviceId(tunnel.getSourceDevice()).setTepDeviceType(getDeviceType(tunnel.getSourceDevice()));
        dstInfoBuilder.setTepDeviceId(tunnel.getDestinationDevice()).setTepDeviceType(getDeviceType(tunnel.getDestinationDevice())).setTepIp(ifTunnel.getTunnelDestination());
        stlBuilder.setTransportType(tunnel.getTransportType());
    }
    stlBuilder.setKey(tlKey).setTunnelInterfaceName(name).setOperState(tunOpStatus).setTunnelState(state).setDstInfo(dstInfoBuilder.build()).setSrcInfo(srcInfoBuilder.build());
    return stlBuilder.build();
}
Also used : StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) DstInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.state.tunnel.list.DstInfoBuilder) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) SrcInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.state.tunnel.list.SrcInfoBuilder)

Example 64 with Tunnel

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

the class ItmUtils method buildHwTunnelInterface.

public static Interface buildHwTunnelInterface(String tunnelIfName, String desc, boolean enabled, String topoId, String nodeId, Class<? extends TunnelTypeBase> tunType, IpAddress srcIp, IpAddress destIp, IpAddress gwIp, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(tunnelIfName)).setName(tunnelIfName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    List<NodeIdentifier> nodeIds = new ArrayList<>();
    NodeIdentifier hwNode = new NodeIdentifierBuilder().setKey(new NodeIdentifierKey(topoId)).setTopologyId(topoId).setNodeId(nodeId).build();
    nodeIds.add(hwNode);
    ParentRefs parent = new ParentRefsBuilder().setNodeIdentifier(nodeIds).build();
    builder.addAugmentation(ParentRefs.class, parent);
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(destIp).setTunnelGateway(gwIp).setTunnelSource(srcIp).setMonitorEnabled(monitorEnabled == null || monitorEnabled).setMonitorProtocol(monitorProtocol == null ? ITMConstants.DEFAULT_MONITOR_PROTOCOL : monitorProtocol).setMonitorInterval(DEFAULT_MONITORING_INTERVAL).setTunnelInterfaceType(tunType).setInternal(false).build();
    builder.addAugmentation(IfTunnel.class, tunnel);
    LOG.trace("iftunnel {} built from hwvtep {} ", tunnel, nodeId);
    return builder.build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) NodeIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifier) ArrayList(java.util.ArrayList) NodeIdentifierBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifierBuilder) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) 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) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) NodeIdentifierKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifierKey) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)

Example 65 with Tunnel

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

the class ItmUtils method getInternalTunnelsofTzone.

public static List<String> getInternalTunnelsofTzone(String tzone, DataBroker dataBroker) {
    List<String> tunnels = new ArrayList<>();
    LOG.trace("Getting internal tunnels of {}", tzone);
    InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
    Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    if (transportZoneOptional.isPresent()) {
        TransportZone transportZone = transportZoneOptional.get();
        if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
            for (Subnets sub : transportZone.getSubnets()) {
                if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
                    for (Vteps vtepLocal : sub.getVteps()) {
                        for (Vteps vtepRemote : sub.getVteps()) {
                            if (!vtepLocal.equals(vtepRemote)) {
                                InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(), transportZone.getTunnelType());
                                InstanceIdentifier<InternalTunnel> intIID = InstanceIdentifier.builder(TunnelList.class).child(InternalTunnel.class, key).build();
                                Optional<InternalTunnel> tunnelsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
                                if (tunnelsOptional.isPresent()) {
                                    List<String> tunnelInterfaceNames = tunnelsOptional.get().getTunnelInterfaceNames();
                                    if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
                                        String tunnelInterfaceName = tunnelInterfaceNames.get(0);
                                        LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
                                        tunnels.add(tunnelInterfaceName);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return tunnels;
}
Also used : InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) ArrayList(java.util.ArrayList) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

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