X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fconfighelpers%2FItmExternalTunnelAddWorker.java;h=0b783a95d4917fda735575fa61553ea4fa28d067;hb=HEAD;hp=6a0ed5be2bd9c4a032c3a2ceef8ea17a0cc8a75e;hpb=769edd5c7e8cfa0a13a2f8e442270978f649b83f;p=vpnservice.git diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmExternalTunnelAddWorker.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmExternalTunnelAddWorker.java index 6a0ed5be..0b783a95 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmExternalTunnelAddWorker.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmExternalTunnelAddWorker.java @@ -15,9 +15,10 @@ import com.google.common.base.Optional; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.vpnservice.itm.globals.ITMConstants; import org.opendaylight.vpnservice.itm.impl.ItmUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; @@ -75,15 +76,16 @@ public class ItmExternalTunnelAddWorker { // CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0); String interfaceName = firstEndPt.getInterfaceName(); - String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()); + String tunTypeStr = tunType.getName(); + String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue(), tunTypeStr); char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue(); String subnetMaskStr = String.valueOf(subnetMaskArray); SubnetUtils utils = new SubnetUtils(subnetMaskStr); String dcGwyIpStr = String.valueOf(extIp.getValue()); - IpAddress gwyIpAddress = (utils.getInfo().isInRange(dcGwyIpStr)) ? null : firstEndPt.getGwIpAddress(); - String ifDescription = tunType.getName(); + IpAddress gatewayIpObj = new IpAddress("0.0.0.0".toCharArray()); + IpAddress gwyIpAddress = (utils.getInfo().isInRange(dcGwyIpStr)) ? gatewayIpObj : firstEndPt.getGwIpAddress(); logger.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", ifDescription, "Trunk Interface"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, firstEndPt.getVLANID(), false,false,null); + 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,null); logger.debug(" Trunk Interface builder - {} ", iface); InstanceIdentifier trunkIdentifier = ItmUtils.buildId(trunkInterfaceName); logger.debug(" Trunk Interface Identifier - {} ", trunkIdentifier); @@ -92,8 +94,9 @@ public class ItmExternalTunnelAddWorker { // update external_tunnel_list ds InstanceIdentifier path = InstanceIdentifier.create( ExternalTunnelList.class) - .child(ExternalTunnel.class, new ExternalTunnelKey(extIp.toString(), teps.getDPNID().toString())); - ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID().toString(), extIp.toString(), trunkInterfaceName); + .child(ExternalTunnel.class, new ExternalTunnelKey(extIp.toString(), teps.getDPNID().toString(), tunType)); + ExternalTunnel tnl = ItmUtils.buildExternalTunnel( teps.getDPNID().toString(), extIp.toString(), + tunType, trunkInterfaceName); t.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true); } futures.add(t.submit()); @@ -144,14 +147,16 @@ public class ItmExternalTunnelAddWorker { String cssID = dpn.getDPNID().toString(); String nodeId = hwVtepDS.getNodeId(); //CSS-TOR + Boolean monitorEnabled = ItmUtils.readMonitoringStateFromDS(dataBroker); + Integer monitorInterval = ItmUtils.readMonitorIntervalfromDS(dataBroker); logger.trace("wire up {} and {}",tep, hwVtepDS); if (!wireUp(dpn.getDPNID(), tep.getPortname(), sub.getVlanId(), tep.getIpAddress(), nodeId, hwVtepDS.getIpAddress(), tep.getSubnetMask(), - sub.getGatewayIp(), sub.getPrefix(), tZone.getTunnelType(), idManagerService, dataBroker, futures, t)) + sub.getGatewayIp(), sub.getPrefix(), tZone.getTunnelType(),monitorEnabled,ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, idManagerService, dataBroker, futures, t)) logger.error("Unable to build tunnel {} -- {}", tep.getIpAddress(), hwVtepDS.getIpAddress()); //TOR-CSS logger.trace("wire up {} and {}", hwVtepDS,tep); if (!wireUp(hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), cssID, tep.getIpAddress(), sub.getPrefix(), - sub.getGatewayIp(), tep.getSubnetMask(), tZone.getTunnelType(), idManagerService, dataBroker, futures, t)) + sub.getGatewayIp(), tep.getSubnetMask(), tZone.getTunnelType(), monitorEnabled,ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, idManagerService, dataBroker, futures, t)) logger.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), tep.getIpAddress()); } @@ -167,6 +172,7 @@ public class ItmExternalTunnelAddWorker { for (HwVtep hwTep : cfgdHwVteps) { InstanceIdentifier tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey((hwTep.getTransportZone()))).build(); Optional tZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker); + Class tunType = TunnelTypeVxlan.class; if (tZoneOptional.isPresent()) { TransportZone tZone = tZoneOptional.get(); //do we need to check tunnel type? @@ -177,14 +183,17 @@ public class ItmExternalTunnelAddWorker { if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) continue;//dont mesh with self //TOR1-TOR2 + Boolean monitorEnabled = ItmUtils.readMonitoringStateFromDS(dataBroker); + Integer monitorInterval = ItmUtils.readMonitorIntervalfromDS(dataBroker); logger.trace("wire up {} and {}",hwTep, hwVtepDS); if (!wireUp(hwTep.getTopo_id(), hwTep.getNode_id(), hwTep.getHwIp(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), - hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tZone.getTunnelType(), idManagerService, dataBroker, futures, t)) + hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType,monitorEnabled, + ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, idManagerService, dataBroker, futures, t)) logger.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), hwVtepDS.getIpAddress()); //TOR2-TOR1 logger.trace("wire up {} and {}", hwVtepDS,hwTep); if (!wireUp(hwTep.getTopo_id(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getNode_id(), hwTep.getHwIp(), - sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tZone.getTunnelType(), idManagerService, dataBroker, futures, t)) + sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, monitorEnabled,ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, idManagerService, dataBroker, futures, t)) logger.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), hwTep.getHwIp()); } } @@ -192,14 +201,17 @@ public class ItmExternalTunnelAddWorker { for (Vteps vtep : sub.getVteps()) { //TOR-CSS String cssID = vtep.getDpnId().toString(); + Boolean monitorEnabled = ItmUtils.readMonitoringStateFromDS(dataBroker); + Integer monitorInterval = ItmUtils.readMonitorIntervalfromDS(dataBroker); logger.trace("wire up {} and {}",hwTep, vtep); if(!wireUp(hwTep.getTopo_id(), hwTep.getNode_id(), hwTep.getHwIp(), cssID, vtep.getIpAddress(), hwTep.getIpPrefix(), - hwTep.getGatewayIP(), sub.getPrefix(), tZone.getTunnelType(),idManagerService, dataBroker, futures, t )) + hwTep.getGatewayIP(), sub.getPrefix(), tunType,monitorEnabled, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, idManagerService, dataBroker, futures, t )) logger.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), vtep.getIpAddress()); //CSS-TOR logger.trace("wire up {} and {}", vtep,hwTep); if(!wireUp(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId(), vtep.getIpAddress(), - hwTep.getNode_id(),hwTep.getHwIp(),sub.getPrefix(), sub.getGatewayIp(),hwTep.getIpPrefix(),tZone.getTunnelType(),idManagerService, dataBroker, futures, t )); + hwTep.getNode_id(),hwTep.getHwIp(),sub.getPrefix(), sub.getGatewayIp(),hwTep.getIpPrefix(), + tunType,monitorEnabled,ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL,idManagerService, dataBroker, futures, t )); } @@ -212,41 +224,57 @@ public class ItmExternalTunnelAddWorker { //for tunnels from TOR device private static boolean wireUp(String topo_id, String srcNodeid, IpAddress srcIp, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, - IpAddress gWIp, IpPrefix dstSubnet, Class tunType, IdManagerService idManagerService, DataBroker dataBroker, List> futures, WriteTransaction t) { - IpAddress gwyIpAddress = (srcSubnet.equals(dstSubnet)) ? null : gWIp; + IpAddress gWIp, IpPrefix dstSubnet, Class tunType,Boolean monitorEnabled, + Integer monitorInterval,IdManagerService idManagerService, DataBroker dataBroker, List> futures, WriteTransaction t) { + IpAddress gatewayIpObj = new IpAddress("0.0.0.0".toCharArray()); + IpAddress gwyIpAddress = (srcSubnet.equals(dstSubnet)) ? gatewayIpObj : gWIp; String parentIf = ItmUtils.getHwParentIf(topo_id, srcNodeid); - String tunnelIfName = ItmUtils.getTrunkInterfaceName(idManagerService, parentIf, srcIp.getIpv4Address().getValue(), dstIp.getIpv4Address().getValue()); + String tunTypeStr = tunType.getName(); + String tunnelIfName = ItmUtils.getTrunkInterfaceName(idManagerService, parentIf, + srcIp.getIpv4Address().getValue(), dstIp.getIpv4Address().getValue(), tunTypeStr); logger.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, topo_id, srcNodeid, tunType, srcIp, dstIp, gwyIpAddress, true); + true, topo_id, srcNodeid, tunType, srcIp, dstIp, gwyIpAddress, monitorEnabled, monitorInterval); InstanceIdentifier ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build(); logger.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, hwTunnelIf); + ItmUtils.itmCache.addInterface(hwTunnelIf); t.merge(LogicalDatastoreType.CONFIGURATION, ifIID, hwTunnelIf, true); // also update itm-state ds? InstanceIdentifier path = InstanceIdentifier.create( ExternalTunnelList.class) - .child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), getExternalTunnelKey(srcNodeid))); - ExternalTunnel tnl = ItmUtils.buildExternalTunnel(getExternalTunnelKey(srcNodeid), getExternalTunnelKey(dstNodeId), tunnelIfName); + .child(ExternalTunnel.class, new ExternalTunnelKey( getExternalTunnelKey(dstNodeId), getExternalTunnelKey(srcNodeid), tunType)); + ExternalTunnel tnl = ItmUtils.buildExternalTunnel( getExternalTunnelKey(srcNodeid), + getExternalTunnelKey(dstNodeId), + tunType, tunnelIfName); t.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true); + ItmUtils.itmCache.addExternalTunnel(tnl); return true; } //for tunnels from CSS private static boolean wireUp(BigInteger dpnId,String portname, Integer vlanId, IpAddress srcIp, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, - IpAddress gWIp, IpPrefix dstSubnet, Class tunType, IdManagerService idManagerService, DataBroker dataBroker, List> futures, WriteTransaction t) { - IpAddress gwyIpAddress = (srcSubnet.equals(dstSubnet)) ? null : gWIp; + IpAddress gWIp, IpPrefix dstSubnet, Class tunType,Boolean monitorEnabled, Integer monitorInterval, + IdManagerService idManagerService, DataBroker dataBroker, List> futures, WriteTransaction t) { + IpAddress gatewayIpObj = new IpAddress("0.0.0.0".toCharArray()); + IpAddress gwyIpAddress = (srcSubnet.equals(dstSubnet)) ? gatewayIpObj : gWIp; String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId); - String tunnelIfName = ItmUtils.getTrunkInterfaceName(idManagerService, parentIf, srcIp.getIpv4Address().getValue(), dstIp.getIpv4Address().getValue()); + String tunTypeStr = tunType.getName(); + String tunnelIfName = ItmUtils.getTrunkInterfaceName(idManagerService, parentIf, + srcIp.getIpv4Address().getValue(), dstIp.getIpv4Address().getValue(), tunTypeStr); logger.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, true, 5L); + Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false,monitorEnabled, monitorInterval); InstanceIdentifier ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build(); logger.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf); t.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true); + ItmUtils.itmCache.addInterface(extTunnelIf); InstanceIdentifier path = InstanceIdentifier.create( ExternalTunnelList.class) - .child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString())); - ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunnelIfName); + .child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType)); + ExternalTunnel tnl = ItmUtils.buildExternalTunnel( dpnId.toString(), + getExternalTunnelKey(dstNodeId), + tunType, tunnelIfName); t.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true); + ItmUtils.itmCache.addExternalTunnel(tnl); return true; }