use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase in project genius by opendaylight.
the class TunnelMonitorChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModification) {
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
Class<? extends TunnelMonitoringTypeBase> monitorProtocol = dataObjectModification.getMonitorProtocol();
if (monitorProtocol == null) {
monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
}
if (transportZonesOptional.isPresent()) {
TransportZones transportZones = transportZonesOptional.get();
for (TransportZone tzone : transportZones.getTransportZone()) {
LOG.debug("Remove - TunnelMonitorToggleWorker with tzone = {}, Enable = {}, MonitorProtocol = {}", tzone.getZoneName(), dataObjectModification.isEnabled(), monitorProtocol);
ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), false, 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 TunnelMonitorChangeListener method add.
@Override
protected void add(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModification) {
LOG.debug("Add - TunnelMonitorToggleWorker with Enable = {}, MonitorProtocol = {}", dataObjectModification.isEnabled(), dataObjectModification.getMonitorProtocol());
Class<? extends TunnelMonitoringTypeBase> monitorProtocol = dataObjectModification.getMonitorProtocol();
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
if (monitorProtocol == null) {
monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
}
if (transportZonesOptional.isPresent()) {
TransportZones tzones = transportZonesOptional.get();
for (TransportZone tzone : tzones.getTransportZone()) {
LOG.debug("Add: TunnelMonitorToggleWorker with tzone = {} monitoringEnabled {} and " + "monitoringProtocol {}", tzone.getZoneName(), dataObjectModification.isEnabled(), dataObjectModification.getMonitorProtocol());
ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), dataObjectModification.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 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();
}
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 OVS
private boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow, 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.getInterfaceName(dpnId, portname, vlanId);
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 extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf);
transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true);
ItmUtils.ITM_CACHE.addInterface(extTunnelIf);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), 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 createTunnelsFromOVSinTransportZone.
private void createTunnelsFromOVSinTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints tep, WriteTransaction transaction, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol) {
InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
// do we need to check tunnel type?
if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
// dont mesh if hwVteps and OVS-tep have same ip-address
if (hwVtepDS.getIpAddress().equals(tep.getIpAddress())) {
continue;
}
final String cssID = dpn.getDPNID().toString();
String nodeId = hwVtepDS.getNodeId();
boolean useOfTunnel = ItmUtils.falseIfNull(tep.isOptionOfTunnel());
LOG.trace("wire up {} and {}", tep, hwVtepDS);
if (!wireUp(dpn.getDPNID(), tep.getPortname(), sub.getVlanId(), tep.getIpAddress(), useOfTunnel, nodeId, hwVtepDS.getIpAddress(), tep.getSubnetMask(), sub.getGatewayIp(), sub.getPrefix(), transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", tep.getIpAddress(), hwVtepDS.getIpAddress());
}
// TOR-OVS
LOG.trace("wire up {} and {}", hwVtepDS, tep);
if (!wireUp(hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), cssID, tep.getIpAddress(), sub.getPrefix(), sub.getGatewayIp(), tep.getSubnetMask(), transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), tep.getIpAddress());
}
}
}
}
}
}
}
Aggregations