Search in sources :

Example 6 with TunnelMonitoringTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase in project genius by opendaylight.

the class TepCommandHelper method configureTunnelMonitorParams.

public void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol) {
    InstanceIdentifier<TunnelMonitorParams> path = InstanceIdentifier.builder(TunnelMonitorParams.class).build();
    Optional<TunnelMonitorParams> storedTunnelMonitor = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    Class<? extends TunnelMonitoringTypeBase> monitorType;
    if (storedTunnelMonitor.isPresent() && storedTunnelMonitor.get().getMonitorProtocol() != null) {
        monitorType = storedTunnelMonitor.get().getMonitorProtocol();
    } else {
        if (monitorProtocol != null && monitorProtocol.equalsIgnoreCase(ITMConstants.MONITOR_TYPE_LLDP)) {
            monitorType = TunnelMonitoringTypeLldp.class;
        } else {
            monitorType = TunnelMonitoringTypeBfd.class;
        }
    }
    if (!storedTunnelMonitor.isPresent() || storedTunnelMonitor.get().isEnabled() != monitorEnabled) {
        TunnelMonitorParams tunnelMonitor = new TunnelMonitorParamsBuilder().setEnabled(monitorEnabled).setMonitorProtocol(monitorType).build();
        ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tunnelMonitor, dataBroker, ItmUtils.DEFAULT_CALLBACK);
    }
}
Also used : TunnelMonitorParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder) TunnelMonitorParams(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParams)

Example 7 with TunnelMonitoringTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase 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 8 with TunnelMonitoringTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase in project genius by opendaylight.

the class TunnelMonitorChangeListener method update.

@Override
protected void update(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModificationBefore, TunnelMonitorParams dataObjectModificationAfter) {
    LOG.debug("update TunnelMonitorChangeListener called with {}", dataObjectModificationAfter.isEnabled());
    Class<? extends TunnelMonitoringTypeBase> monitorProtocolBefore = dataObjectModificationBefore.getMonitorProtocol();
    Class<? extends TunnelMonitoringTypeBase> monitorProtocolAfter = dataObjectModificationAfter.getMonitorProtocol();
    Class<? extends TunnelMonitoringTypeBase> monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
    if (monitorProtocolAfter != null) {
        monitorProtocol = dataObjectModificationAfter.getMonitorProtocol();
    }
    if (monitorProtocolBefore != null && monitorProtocolAfter != null) {
        LOG.debug("TunnelMonitorChangeListener Update : Existing_MonitorProtocol {}, New_MonitorProtocol {} ", monitorProtocolBefore.getName(), monitorProtocolAfter.getName());
        if (!monitorProtocolAfter.getName().equalsIgnoreCase(monitorProtocolBefore.getName())) {
            LOG.error("Updation of monitor protocol not allowed");
        }
    }
    if (transportZonesOptional.isPresent()) {
        TransportZones tzones = transportZonesOptional.get();
        for (TransportZone tzone : tzones.getTransportZone()) {
            LOG.debug("Update - TunnelMonitorToggleWorker with tzone = {}, Enable = {}, MonitorProtocol = {}", tzone.getZoneName(), dataObjectModificationAfter.isEnabled(), monitorProtocol);
            ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), dataObjectModificationAfter.isEnabled(), monitorProtocol, broker);
            jobCoordinator.enqueueJob(tzone.getZoneName(), toggleWorker);
        }
    }
}
Also used : ItmMonitorToggleWorker(org.opendaylight.genius.itm.confighelpers.ItmMonitorToggleWorker) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 9 with TunnelMonitoringTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase in project genius by opendaylight.

the class ItmExternalTunnelAddWorker method wireUp.

// for tunnels from TOR device
private boolean wireUp(String topoId, String srcNodeid, IpAddress srcIp, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
    IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
    IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
    String parentIf = ItmUtils.getHwParentIf(topoId, srcNodeid);
    String tunTypeStr = tunType.getName();
    String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
    LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress);
    Interface hwTunnelIf = ItmUtils.buildHwTunnelInterface(tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, topoId, srcNodeid, tunType, srcIp, dstIp, gwyIpAddress, monitorEnabled, monitorProtocol, monitorInterval);
    InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
    LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, hwTunnelIf);
    ItmUtils.ITM_CACHE.addInterface(hwTunnelIf);
    transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, hwTunnelIf, true);
    // also update itm-state ds?
    InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), getExternalTunnelKey(srcNodeid), tunType));
    ExternalTunnel tnl = ItmUtils.buildExternalTunnel(getExternalTunnelKey(srcNodeid), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
    transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
    ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
    return true;
}
Also used : 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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 10 with TunnelMonitoringTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase in project genius by opendaylight.

the class ItmExternalTunnelAddWorker method tunnelsFromhWVtep.

private void tunnelsFromhWVtep(List<HwVtep> cfgdHwVteps, WriteTransaction transaction, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol) {
    for (HwVtep hwTep : cfgdHwVteps) {
        InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(hwTep.getTransportZone())).build();
        Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
        Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
        if (transportZoneOptional.isPresent()) {
            TransportZone tzone = transportZoneOptional.get();
            // do we need to check tunnel type?
            if (tzone.getSubnets() != null && !tzone.getSubnets().isEmpty()) {
                for (Subnets sub : tzone.getSubnets()) {
                    if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
                        for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
                            if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
                                // dont mesh with self
                                continue;
                            }
                            LOG.trace("wire up {} and {}", hwTep, hwVtepDS);
                            if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), hwVtepDS.getIpAddress());
                            }
                            // TOR2-TOR1
                            LOG.trace("wire up {} and {}", hwVtepDS, hwTep);
                            if (!wireUp(hwTep.getTopoId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), hwTep.getHwIp());
                            }
                        }
                    }
                    if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
                        for (Vteps vtep : sub.getVteps()) {
                            if (vtep.getIpAddress().equals(hwTep.getHwIp())) {
                                continue;
                            }
                            // TOR-OVS
                            String cssID = vtep.getDpnId().toString();
                            LOG.trace("wire up {} and {}", hwTep, vtep);
                            if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), cssID, vtep.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), vtep.getIpAddress());
                            }
                            // OVS-TOR
                            LOG.trace("wire up {} and {}", vtep, hwTep);
                            boolean useOfTunnel = ItmUtils.falseIfNull(vtep.isOptionOfTunnel());
                            if (!wireUp(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId(), vtep.getIpAddress(), useOfTunnel, hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.debug("wireUp returned false");
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) 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) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Aggregations

TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)5 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)4 ItmMonitorToggleWorker (org.opendaylight.genius.itm.confighelpers.ItmMonitorToggleWorker)3 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)2 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)2 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)2 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)2 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)2 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)2 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)2 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)2 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)2 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)2 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)2 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)2 ArrayList (java.util.ArrayList)1 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)1 IfL2vlanBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder)1