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);
}
}
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();
}
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);
}
}
}
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;
}
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");
}
}
}
}
}
}
}
}
Aggregations