Search in sources :

Example 1 with TunnelOptions

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.

the class ItmUtils method buildTunnelOptions.

public static List<TunnelOptions> buildTunnelOptions(TunnelEndPoints tep, ItmConfig itmConfig) {
    List<TunnelOptions> tunOptions = new ArrayList<>();
    String tos = tep.getOptionTunnelTos();
    if (tos == null) {
        tos = itmConfig.getDefaultTunnelTos();
    }
    /* populate tos option only if its not default value of 0 */
    if (tos != null && !tos.equals("0")) {
        TunnelOptionsBuilder optionsBuilder = new TunnelOptionsBuilder();
        optionsBuilder.setKey(new TunnelOptionsKey("tos"));
        optionsBuilder.setTunnelOption("tos");
        optionsBuilder.setValue(tos);
        tunOptions.add(optionsBuilder.build());
    }
    if (tep.getTunnelType() == TunnelTypeVxlan.class && itmConfig.isGpeExtensionEnabled()) {
        TunnelOptionsBuilder optionsBuilder = new TunnelOptionsBuilder();
        optionsBuilder.setKey(new TunnelOptionsKey("exts"));
        optionsBuilder.setTunnelOption("exts");
        optionsBuilder.setValue("gpe");
        tunOptions.add(optionsBuilder.build());
    }
    return tunOptions.isEmpty() ? null : tunOptions;
}
Also used : TunnelOptionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsBuilder) TunnelOptionsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsKey) ArrayList(java.util.ArrayList) TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)

Example 2 with TunnelOptions

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.

the class ItmExternalTunnelAddWorker method buildTunnelsToExternalEndPoint.

public List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(Collection<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
    if (null != cfgDpnList) {
        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
        for (DPNTEPsInfo teps : cfgDpnList) {
            // CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels
            TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
            String interfaceName = firstEndPt.getInterfaceName();
            String tunTypeStr = tunType.getName();
            String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunTypeStr);
            char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue();
            boolean useOfTunnel = ItmUtils.falseIfNull(firstEndPt.isOptionOfTunnel());
            List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(firstEndPt, itmConfig);
            String subnetMaskStr = String.valueOf(subnetMaskArray);
            SubnetUtils utils = new SubnetUtils(subnetMaskStr);
            String dcGwyIpStr = String.valueOf(extIp.getValue());
            IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
            IpAddress gwyIpAddress = utils.getInfo().isInRange(dcGwyIpStr) ? gatewayIpObj : firstEndPt.getGwIpAddress();
            LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}," + " source IP - {}, DC Gateway IP - {} gateway IP - {}", trunkInterfaceName, interfaceName, firstEndPt.getIpAddress(), extIp, gwyIpAddress);
            Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, firstEndPt.getVLANID(), false, false, ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
            LOG.debug(" Trunk Interface builder - {} ", iface);
            InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
            LOG.debug(" Trunk Interface Identifier - {} ", trunkIdentifier);
            LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface);
            transaction.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true);
            // update external_tunnel_list ds
            InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
            ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID().toString(), String.valueOf(extIp.getValue()), tunType, trunkInterfaceName);
            transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
        }
        return Collections.singletonList(transaction.submit());
    }
    return Collections.emptyList();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) SubnetUtils(org.apache.commons.net.util.SubnetUtils) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 3 with TunnelOptions

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.

the class ItmInternalTunnelAddWorker method createTunnelInterface.

private void createTunnelInterface(TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName, String parentInterfaceName) {
    String gateway = srcte.getIpAddress().getIpv4Address() != null ? "0.0.0.0" : "::";
    IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance(gateway);
    IpAddress gwyIpAddress = srcte.getSubnetMask().equals(dstte.getSubnetMask()) ? gatewayIpObj : srcte.getGwIpAddress();
    LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", trunkInterfaceName, srcte.getInterfaceName(), srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress);
    boolean useOfTunnel = ItmUtils.falseIfNull(srcte.isOptionOfTunnel());
    List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(srcte, itmCfg);
    Boolean isMonitorEnabled = tunType.isAssignableFrom(TunnelTypeLogicalGroup.class) ? false : isTunnelMonitoringEnabled;
    Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, srcte.getVLANID(), true, isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
    LOG.debug(" Trunk Interface builder - {} ", iface);
    InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
    LOG.debug(" Trunk Interface Identifier - {} ", trunkIdentifier);
    LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface);
    ITMBatchingUtils.update(trunkIdentifier, iface, ITMBatchingUtils.EntityType.DEFAULT_CONFIG);
    ItmUtils.ITM_CACHE.addInterface(iface);
}
Also used : TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 4 with TunnelOptions

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.

the class ItmUtils method buildTunnelInterface.

public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId, boolean internal, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, boolean useOfTunnel, String parentIfaceName, List<TunnelOptions> tunnelOptions) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(parentIfaceName).build();
    builder.addAugmentation(ParentRefs.class, parentRefs);
    Long monitoringInterval = null;
    if (vlanId > 0) {
        IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build();
        builder.addAugmentation(IfL2vlan.class, l2vlan);
    }
    LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}", monitorProtocol.getName(), monitorInterval);
    if (monitorInterval != null) {
        monitoringInterval = monitorInterval.longValue();
    }
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel).setTunnelOptions(tunnelOptions).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) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 5 with TunnelOptions

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.

the class SouthboundUtils method addTunnelPortToBridge.

private void addTunnelPortToBridge(IfTunnel ifTunnel, InstanceIdentifier<?> bridgeIid, Interface iface, String portName) {
    LOG.debug("adding tunnel port {} to bridge {}", portName, bridgeIid);
    Class<? extends InterfaceTypeBase> type = TUNNEL_TYPE_MAP.get(ifTunnel.getTunnelInterfaceType());
    if (type == null) {
        LOG.warn("Unknown Tunnel Type obtained while creating interface: {}", iface);
        return;
    }
    int vlanId = 0;
    IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
    if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
        vlanId = ifL2vlan.getVlanId().getValue();
    }
    Map<String, String> options = Maps.newHashMap();
    // Options common to any kind of tunnel
    if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow())) {
        options.put(TUNNEL_OPTIONS_LOCAL_IP, TUNNEL_OPTIONS_VALUE_FLOW);
    } else {
        IpAddress localIp = ifTunnel.getTunnelSource();
        options.put(TUNNEL_OPTIONS_LOCAL_IP, String.valueOf(localIp.getValue()));
    }
    if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow())) {
        options.put(TUNNEL_OPTIONS_REMOTE_IP, TUNNEL_OPTIONS_VALUE_FLOW);
    } else {
        IpAddress remoteIp = ifTunnel.getTunnelDestination();
        options.put(TUNNEL_OPTIONS_REMOTE_IP, String.valueOf(remoteIp.getValue()));
    }
    // Specific options for each type of tunnel
    if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeMplsOverGre.class)) {
        options.put(TUNNEL_OPTIONS_PKT_TYPE, TUNNEL_OPTIONS_VALUE_LEGACY_L3);
    } else {
        options.put(TUNNEL_OPTIONS_KEY, TUNNEL_OPTIONS_VALUE_FLOW);
    }
    if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlanGpe.class)) {
        options.put(TUNNEL_OPTIONS_EXTS, TUNNEL_OPTIONS_VALUE_GPE);
        options.put(TUNNEL_OPTIONS_NSI, TUNNEL_OPTIONS_VALUE_FLOW);
        options.put(TUNNEL_OPTIONS_NSP, TUNNEL_OPTIONS_VALUE_FLOW);
        options.put(TUNNEL_OPTIONS_NSHC1, TUNNEL_OPTIONS_VALUE_FLOW);
        options.put(TUNNEL_OPTIONS_NSHC2, TUNNEL_OPTIONS_VALUE_FLOW);
        options.put(TUNNEL_OPTIONS_NSHC3, TUNNEL_OPTIONS_VALUE_FLOW);
        options.put(TUNNEL_OPTIONS_NSHC4, TUNNEL_OPTIONS_VALUE_FLOW);
        // VxLAN-GPE interfaces will not use the default UDP port to avoid
        // problems with other meshes
        options.put(TUNNEL_OPTIONS_DESTINATION_PORT, TUNNEL_OPTIONS_VALUE_GPE_DESTINATION_PORT);
    }
    if (ifTunnel.getTunnelOptions() != null) {
        for (TunnelOptions tunOpt : ifTunnel.getTunnelOptions()) {
            options.putIfAbsent(tunOpt.getTunnelOption(), tunOpt.getValue());
        }
    }
    addTerminationPoint(bridgeIid, portName, vlanId, type, options, ifTunnel);
}
Also used : TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Aggregations

TunnelOptions (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)2 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)2 ArrayList (java.util.ArrayList)1 SubnetUtils (org.apache.commons.net.util.SubnetUtils)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)1 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)1 IfL2vlanBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder)1 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)1 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)1 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)1 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)1 TunnelTypeLogicalGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup)1 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)1 TunnelOptionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsBuilder)1 TunnelOptionsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsKey)1 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)1 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)1