Optimize String formatting
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / impl / ItmUtils.java
index c1f08646a15c7bbd295a251fa4d27943ef5168e1..13c03419f44fe34fa7415dc60a05fa0aa2ae26ab 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.genius.itm.impl;
 import static java.util.Collections.emptyList;
 
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.net.InetAddresses;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.math.BigInteger;
 import java.net.InetAddress;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -28,11 +27,7 @@ import java.util.List;
 import java.util.Objects;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.net.util.SubnetUtils;
-import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -44,7 +39,6 @@ import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
-import org.opendaylight.genius.itm.api.IITMProvider;
 import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
 import org.opendaylight.genius.itm.confighelpers.HwVtep;
 import org.opendaylight.genius.itm.confighelpers.ItmTunnelAggregationHelper;
@@ -71,8 +65,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.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.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs;
@@ -90,18 +82,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepConfigSchemas;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepIpPools;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIdsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIdsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpoints;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpointsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeExternal;
@@ -129,17 +110,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tun
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.state.tunnel.list.DstInfoBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.state.tunnel.list.SrcInfoBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.NotHostedTransportZones;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -149,13 +126,14 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public final class ItmUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(ItmUtils.class);
-
+    private static final String ITM_LLDP_FLOW_ENTRY =  "ITM Flow Entry ::" + ITMConstants.LLDP_SERVICE_ID;
     private static final String TUNNEL = "tun";
     private static final IpPrefix DUMMY_IP_PREFIX = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
     private static final long DEFAULT_MONITORING_INTERVAL = 100L;
@@ -171,18 +149,20 @@ public final class ItmUtils {
 
     private static final BiMap<String,Class<? extends TunnelTypeBase>> STRING_CLASS_IMMUTABLE_BI_MAP =
             ImmutableBiMap.copyOf(TUNNEL_TYPE_MAP);
+    private static final Uint64 COOKIE_ITM_LLD = Uint64.fromLongBits(
+        ITMConstants.COOKIE_ITM.longValue() + ITMConstants.LLDP_SERVICE_ID).intern();
 
     private ItmUtils() {
     }
 
-    public static final FutureCallback<Void> DEFAULT_CALLBACK = new FutureCallback<Void>() {
+    public static final FutureCallback<Void> DEFAULT_WRITE_CALLBACK = new FutureCallback<>() {
         @Override
         public void onSuccess(Void result) {
             LOG.debug("Success in Datastore write operation");
         }
 
         @Override
-        public void onFailure(@Nonnull Throwable error) {
+        public void onFailure(Throwable error) {
             LOG.error("Error in Datastore write operation", error);
         }
     };
@@ -217,7 +197,7 @@ public final class ItmUtils {
                                                          FutureCallback<Void> callback) {
         WriteTransaction tx = broker.newWriteOnlyTransaction();
         tx.put(datastoreType, path, data, true);
-        Futures.addCallback(tx.submit(), callback);
+        Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
     }
 
     /**
@@ -231,7 +211,7 @@ public final class ItmUtils {
                                                           FutureCallback<Void> callback) {
         WriteTransaction tx = broker.newWriteOnlyTransaction();
         tx.merge(datastoreType, path, data, true);
-        Futures.addCallback(tx.submit(), callback);
+        Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
     }
 
     /**
@@ -245,7 +225,7 @@ public final class ItmUtils {
                                                           FutureCallback<Void> callback) {
         WriteTransaction tx = broker.newWriteOnlyTransaction();
         tx.delete(datastoreType, path);
-        Futures.addCallback(tx.submit(), callback);
+        Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
     }
 
     /**
@@ -263,17 +243,14 @@ public final class ItmUtils {
             for (InstanceIdentifier<T> path : pathList) {
                 tx.delete(datastoreType, path);
             }
-            Futures.addCallback(tx.submit(), callback);
+            Futures.addCallback(tx.submit(), callback ,MoreExecutors.directExecutor());
         }
     }
 
-    public static String getInterfaceName(final BigInteger datapathid, final String portName, final Integer vlanId) {
-        return String.format("%s:%s:%s", datapathid, portName, vlanId);
-    }
-
-    public static BigInteger getDpnIdFromInterfaceName(String interfaceName) {
-        String[] dpnStr = interfaceName.split(":");
-        return new BigInteger(dpnStr[0]);
+    //ITM cleanup:portname and vlanId are removed, causes change in generated
+    //interface name: This has upgrade impact
+    public static String getInterfaceName(final Uint64 datapathid, final String portName, final Integer vlanId) {
+        return datapathid + ":" + portName + ":" + vlanId;
     }
 
     public static String getTrunkInterfaceName(String parentInterfaceName,
@@ -286,11 +263,10 @@ public final class ItmUtils {
         } else {
             tunnelTypeStr = ITMConstants.TUNNEL_TYPE_VXLAN;
         }
-        String trunkInterfaceName = String.format("%s:%s:%s:%s", parentInterfaceName, localHostName,
-                remoteHostName, tunnelTypeStr);
+        String trunkInterfaceName = trunkInterfaceName(parentInterfaceName, localHostName, remoteHostName,
+            tunnelTypeStr);
         LOG.trace("trunk interface name is {}", trunkInterfaceName);
-        trunkInterfaceName = String.format("%s%s", TUNNEL, getUniqueIdString(trunkInterfaceName));
-        return trunkInterfaceName;
+        return TUNNEL + getUniqueIdString(trunkInterfaceName);
     }
 
     public static void releaseIdForTrunkInterfaceName(String parentInterfaceName,
@@ -301,48 +277,56 @@ public final class ItmUtils {
         } else {
             tunnelTypeStr = ITMConstants.TUNNEL_TYPE_VXLAN;
         }
-        String trunkInterfaceName = String.format("%s:%s:%s:%s", parentInterfaceName, localHostName,
-                remoteHostName, tunnelTypeStr);
-        LOG.trace("Releasing Id for trunkInterface - {}", trunkInterfaceName);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Releasing Id for trunkInterface - {}", trunkInterfaceName(parentInterfaceName, localHostName,
+                remoteHostName, tunnelTypeStr));
+        }
     }
 
-    public static String getLogicalTunnelGroupName(BigInteger srcDpnId, BigInteger destDpnId) {
-        String tunnelTypeStr = ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
-        String groupName = String.format("%s:%s:%s", srcDpnId.toString(), destDpnId.toString(), tunnelTypeStr);
+    private static String trunkInterfaceName(String parentInterfaceName, String localHostName, String remoteHostName,
+            String tunnelType) {
+        return parentInterfaceName + ":" + localHostName + ":" + remoteHostName + ":" + tunnelType;
+    }
+
+    public static String getLogicalTunnelGroupName(Uint64 srcDpnId, Uint64 destDpnId) {
+        String groupName = srcDpnId + ":" + destDpnId + ":" + ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
         LOG.trace("logical tunnel group name is {}", groupName);
-        groupName = String.format("%s%s", TUNNEL, getUniqueIdString(groupName));
-        return groupName;
+        return TUNNEL +  getUniqueIdString(groupName);
     }
 
     public static InetAddress getInetAddressFromIpAddress(IpAddress ip) {
         return IetfInetUtil.INSTANCE.inetAddressFor(ip);
     }
 
-    public static InstanceIdentifier<DPNTEPsInfo> getDpnTepInstance(BigInteger dpIdKey) {
+    public static InstanceIdentifier<DPNTEPsInfo> getDpnTepInstance(Uint64 dpIdKey) {
         return InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(dpIdKey))
                 .build();
     }
 
-    public static DPNTEPsInfo createDPNTepInfo(BigInteger dpId, List<TunnelEndPoints> endpoints) {
+    public static DPNTEPsInfo createDPNTepInfo(Uint64 dpId, List<TunnelEndPoints> endpoints) {
         return new DPNTEPsInfoBuilder().withKey(new DPNTEPsInfoKey(dpId)).setTunnelEndPoints(endpoints).build();
     }
 
-    public static TunnelEndPoints createTunnelEndPoints(BigInteger dpnId, IpAddress ipAddress, String portName,
-                                                        boolean isOfTunnel, int vlanId, IpPrefix prefix,
-                                                        IpAddress gwAddress, List<TzMembership> zones,
+    public static TunnelEndPoints createTunnelEndPoints(Uint64 dpnId, IpAddress ipAddress, String portName,
+                                                        boolean isOfTunnel, int vlanId, List<TzMembership> zones,
                                                         Class<? extends TunnelTypeBase>  tunnelType,
                                                         String tos) {
         // when Interface Mgr provides support to take in Dpn Id
-        return new TunnelEndPointsBuilder().withKey(new TunnelEndPointsKey(ipAddress, portName,tunnelType, vlanId))
-                .setSubnetMask(prefix).setGwIpAddress(gwAddress).setTzMembership(zones)
+        return new TunnelEndPointsBuilder().withKey(new TunnelEndPointsKey(ipAddress, tunnelType))
+                .setTzMembership(zones)
                 .setOptionOfTunnel(isOfTunnel).setInterfaceName(ItmUtils.getInterfaceName(dpnId, portName, vlanId))
                 .setTunnelType(tunnelType)
                 .setOptionTunnelTos(tos)
                 .build();
     }
 
-    public static DpnEndpoints createDpnEndpoints(List<DPNTEPsInfo> dpnTepInfo) {
-        return new DpnEndpointsBuilder().setDPNTEPsInfo(dpnTepInfo).build();
+    public static TunnelEndPoints createDummyTunnelEndPoints(Uint64 dpnID, IpAddress ipAddress, boolean ofTunnel,
+                                                             String tos, List<TzMembership> zones,
+                                                             Class<? extends TunnelTypeBase>  tunnelType,
+                                                             String port, int vlanID) {
+
+        return ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, ofTunnel,vlanID, zones,
+                tunnelType, tos);
     }
 
     public static InstanceIdentifier<Interface> buildId(String interfaceName) {
@@ -355,7 +339,7 @@ public final class ItmUtils {
                 .child(Interface.class, new InterfaceKey(ifName)).augmentation(IfTunnel.class).build();
     }
 
-    public static Interface buildLogicalTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled) {
+    public static Interface buildLogicalTunnelInterface(Uint64 dpn, String ifName, String desc, boolean enabled) {
         InterfaceBuilder builder = new InterfaceBuilder().withKey(new InterfaceKey(ifName)).setName(ifName)
                 .setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
         ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
@@ -370,23 +354,23 @@ public final class ItmUtils {
         return builder.build();
     }
 
-    public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled,
+    public static Interface buildTunnelInterface(Uint64 dpn, String ifName, String desc, boolean enabled,
                                                  Class<? extends TunnelTypeBase> tunType, IpAddress localIp,
-                                                 IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId,
-                                                 boolean internal, Boolean monitorEnabled,
+                                                 IpAddress remoteIp, boolean internal,
+                                                 Boolean monitorEnabled,
                                                  Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
                                                  Integer monitorInterval, boolean useOfTunnel,
                                                  List<TunnelOptions> tunOptions) {
 
-        return buildTunnelInterface(dpn, ifName, desc, enabled, tunType, localIp, remoteIp,  gatewayIp,  vlanId,
-                                    internal,  monitorEnabled, monitorProtocol, monitorInterval,  useOfTunnel, null,
-                                    tunOptions);
+        return buildTunnelInterface(dpn, ifName, desc, enabled, tunType, localIp, remoteIp, internal,
+                monitorEnabled, monitorProtocol, monitorInterval,  useOfTunnel, null,
+                tunOptions);
     }
 
-    public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled,
+    public static Interface buildTunnelInterface(Uint64 dpn, String ifName, String desc, boolean enabled,
                                                  Class<? extends TunnelTypeBase> tunType, IpAddress localIp,
-                                                 IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId,
-                                                 boolean internal, Boolean monitorEnabled,
+                                                 IpAddress remoteIp, boolean internal,
+                                                 Boolean monitorEnabled,
                                                  Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
                                                  Integer monitorInterval, boolean useOfTunnel, String parentIfaceName,
                                                  List<TunnelOptions> tunnelOptions) {
@@ -396,10 +380,6 @@ public final class ItmUtils {
                 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);
 
@@ -407,11 +387,11 @@ public final class ItmUtils {
             monitoringInterval = monitorInterval.longValue();
         }
 
-        IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp)
-                .setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal)
+        IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp)
+                .setTunnelSource(localIp).setTunnelInterfaceType(tunType)
                 .setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol)
                 .setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel)
-                .setTunnelOptions(tunnelOptions)
+                .setTunnelOptions(tunnelOptions).setInternal(internal)
                 .build();
         builder.addAugmentation(IfTunnel.class, tunnel);
         return builder.build();
@@ -441,7 +421,7 @@ public final class ItmUtils {
         return builder.build();
     }
 
-    public static InternalTunnel buildInternalTunnel(BigInteger srcDpnId, BigInteger dstDpnId,
+    public static InternalTunnel buildInternalTunnel(Uint64 srcDpnId, Uint64 dstDpnId,
                                                      Class<? extends TunnelTypeBase> tunType,
                                                      String trunkInterfaceName) {
         return new InternalTunnelBuilder().withKey(new InternalTunnelKey(dstDpnId, srcDpnId, tunType))
@@ -465,10 +445,10 @@ public final class ItmUtils {
                 .replace("-", "");
     }
 
-    public static List<DPNTEPsInfo> getDpnTepListFromDpnId(DPNTEPsInfoCache dpnTEPsInfoCache, List<BigInteger> dpnIds) {
+    public static List<DPNTEPsInfo> getDpnTepListFromDpnId(DPNTEPsInfoCache dpnTEPsInfoCache, List<Uint64> dpnIds) {
         Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
         List<DPNTEPsInfo> cfgDpnList = new ArrayList<>();
-        for (BigInteger dpnId : dpnIds) {
+        for (Uint64 dpnId : dpnIds) {
             for (DPNTEPsInfo teps : meshedDpnList) {
                 if (dpnId.equals(teps.getDPNID())) {
                     cfgDpnList.add(teps);
@@ -481,7 +461,7 @@ public final class ItmUtils {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public static void addTerminatingServiceTable(TypedReadWriteTransaction<Configuration> tx,
-        BigInteger dpnId, IMdsalApiManager mdsalManager) {
+                                                  Uint64 dpnId, IMdsalApiManager mdsalManager) {
         LOG.trace("Installing PUNT to Controller flow in DPN {} ", dpnId);
         List<ActionInfo> listActionInfo = new ArrayList<>();
         listActionInfo.add(new ActionPuntToController());
@@ -489,17 +469,16 @@ public final class ItmUtils {
         try {
             List<MatchInfo> mkMatches = new ArrayList<>();
 
-            mkMatches.add(new MatchTunnelId(BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID)));
+            mkMatches.add(new MatchTunnelId(Uint64.valueOf(ITMConstants.LLDP_SERVICE_ID)));
 
             List<InstructionInfo> mkInstructions = new ArrayList<>();
             mkInstructions.add(new InstructionApplyActions(listActionInfo));
 
             FlowEntity terminatingServiceTableFlowEntity = MDSALUtil
-                .buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE,
-                    getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
-                    5, String.format("%s:%d","ITM Flow Entry ", ITMConstants.LLDP_SERVICE_ID), 0, 0,
-                    ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID)),
-                    mkMatches, mkInstructions);
+                    .buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE,
+                            getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
+                            5, ITM_LLDP_FLOW_ENTRY, 0, 0,
+                            COOKIE_ITM_LLD, mkMatches, mkInstructions);
             mdsalManager.addFlow(tx, terminatingServiceTableFlowEntity);
         } catch (Exception e) {
             LOG.error("Error while setting up Table 36 for {}", dpnId, e);
@@ -508,13 +487,13 @@ public final class ItmUtils {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public static void removeTerminatingServiceTable(TypedReadWriteTransaction<Configuration> tx,
-        BigInteger dpnId, IMdsalApiManager mdsalManager) {
+                                                     Uint64 dpnId, IMdsalApiManager mdsalManager) {
         LOG.trace("Removing PUNT to Controller flow in DPN {} ", dpnId);
 
         try {
             mdsalManager.removeFlow(tx, dpnId,
-                getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
-                NwConstants.INTERNAL_TUNNEL_TABLE);
+                    getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
+                    NwConstants.INTERNAL_TUNNEL_TABLE);
         } catch (Exception e) {
             LOG.error("Error while setting up Table 36 for {}", dpnId, e);
         }
@@ -524,272 +503,24 @@ public final class ItmUtils {
         return String.valueOf(termSvcTable) + svcId;
     }
 
-    public static InstanceIdentifier<VtepConfigSchema> getVtepConfigSchemaIdentifier(String schemaName) {
-        return InstanceIdentifier.builder(VtepConfigSchemas.class)
-                .child(VtepConfigSchema.class, new VtepConfigSchemaKey(schemaName)).build();
-    }
-
-    public static InstanceIdentifier<VtepConfigSchema> getVtepConfigSchemaIdentifier() {
-        return InstanceIdentifier.builder(VtepConfigSchemas.class).child(VtepConfigSchema.class).build();
-    }
-
-    public static InstanceIdentifier<VtepConfigSchemas> getVtepConfigSchemasIdentifier() {
-        return InstanceIdentifier.builder(VtepConfigSchemas.class).build();
-    }
-
-    public static InstanceIdentifier<VtepIpPool> getVtepIpPoolIdentifier(String subnetCidr) {
-        return InstanceIdentifier.builder(VtepIpPools.class).child(VtepIpPool.class, new VtepIpPoolKey(subnetCidr))
-                .build();
-    }
-
-    public static VtepConfigSchema validateForAddVtepConfigSchema(VtepConfigSchema schema,
-                                                                  List<VtepConfigSchema> existingSchemas) {
-        VtepConfigSchema validSchema = validateVtepConfigSchema(schema);
-        for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
-            if (!(!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName())
-                    && Objects.equals(schema.getSubnet(), existingSchema.getSubnet()))) {
-                String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
-                Preconditions.checkArgument(
-                    !(!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName())
-                        && Objects.equals(schema.getSubnet(), existingSchema.getSubnet())),
-                    "VTEP schema with subnet [" + subnetCidr
-                        + "] already exists. Multiple VTEP schemas with same subnet is not allowed.");
-            }
-        }
-        if (isNotEmpty(getDpnIdList(validSchema.getDpnIds()))) {
-            String tzone = validSchema.getTransportZoneName();
-            List<BigInteger> lstDpns = getConflictingDpnsAlreadyConfiguredWithTz(validSchema.getSchemaName(), tzone,
-                    getDpnIdList(validSchema.getDpnIds()), existingSchemas);
-            Preconditions.checkArgument(lstDpns.isEmpty(),
-                "DPN's " + lstDpns + " already configured for transport zone "
-                    + tzone + ". Only one end point per transport Zone per Dpn is allowed.");
-            if (TunnelTypeGre.class.equals(schema.getTunnelType())) {
-                validateForSingleGreTep(validSchema.getSchemaName(), getDpnIdList(validSchema.getDpnIds()),
-                        existingSchemas);
-            }
-        }
-        return validSchema;
-    }
-
-    private static void validateForSingleGreTep(String schemaName, List<BigInteger> lstDpnsForAdd,
-                                                List<VtepConfigSchema> existingSchemas) {
-        for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
-            if (TunnelTypeGre.class.equals(existingSchema.getTunnelType())
-                    && !StringUtils.equalsIgnoreCase(schemaName, existingSchema.getSchemaName())) {
-                List<BigInteger> lstConflictingDpns = new ArrayList<>(getDpnIdList(existingSchema.getDpnIds()));
-                lstConflictingDpns.retainAll(emptyIfNull(lstDpnsForAdd));
-                Preconditions.checkArgument(lstConflictingDpns.isEmpty(), "DPN's " + lstConflictingDpns
-                    + " already configured with GRE TEP. Mutiple GRE TEP's on a single DPN are not allowed.");
-            }
-        }
-    }
-
-    public static VtepConfigSchema validateVtepConfigSchema(VtepConfigSchema schema) {
-        Preconditions.checkNotNull(schema);
-        Preconditions.checkArgument(StringUtils.isNotBlank(schema.getSchemaName()));
-        Preconditions.checkArgument(StringUtils.isNotBlank(schema.getPortName()));
-        Preconditions.checkArgument(schema.getVlanId() >= 0 && schema.getVlanId() < 4095,
-                "Invalid VLAN ID, range (0-4094)");
-        Preconditions.checkArgument(StringUtils.isNotBlank(schema.getTransportZoneName()));
-        Preconditions.checkNotNull(schema.getSubnet());
-        String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
-        SubnetUtils subnetUtils = new SubnetUtils(subnetCidr);
-        IpAddress gatewayIp = schema.getGatewayIp();
-        if (gatewayIp != null) {
-            String strGatewayIp = gatewayIp.stringValue();
-            Preconditions.checkArgument(
-                ITMConstants.DUMMY_IP_ADDRESS.equals(strGatewayIp) || subnetUtils.getInfo().isInRange(strGatewayIp),
-                "Gateway IP address " + strGatewayIp + " is not in subnet range " + subnetCidr);
-        }
-        ItmUtils.getExcludeIpAddresses(schema.getExcludeIpFilter(), subnetUtils.getInfo());
-        return new VtepConfigSchemaBuilder(schema).setTunnelType(schema.getTunnelType()).build();
-    }
-
-    public static String validateTunnelType(String tunnelType) {
-        if (tunnelType == null) {
-            tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
-        } else {
-            tunnelType = StringUtils.upperCase(tunnelType);
-            String error = "Invalid tunnel type. Valid values: "
-                    + ITMConstants.TUNNEL_TYPE_VXLAN + " | " + ITMConstants.TUNNEL_TYPE_GRE;
-            Preconditions.checkArgument(ITMConstants.TUNNEL_TYPE_VXLAN.equals(tunnelType)
-                    || ITMConstants.TUNNEL_TYPE_GRE.equals(tunnelType), error);
-        }
-        return tunnelType;
-    }
-
-    private static List<BigInteger> getConflictingDpnsAlreadyConfiguredWithTz(String schemaName, String tzone,
-                                                                              List<BigInteger> lstDpns,
-                                                                              List<VtepConfigSchema> existingSchemas) {
-        List<BigInteger> lstConflictingDpns = new ArrayList<>();
-        for (VtepConfigSchema schema : emptyIfNull(existingSchemas)) {
-            if (!StringUtils.equalsIgnoreCase(schemaName, schema.getSchemaName())
-                    && StringUtils.equals(schema.getTransportZoneName(), tzone)) {
-                lstConflictingDpns = new ArrayList<>(getDpnIdList(nullToEmpty(schema.getDpnIds())));
-                lstConflictingDpns.retainAll(lstDpns);
-                if (!lstConflictingDpns.isEmpty()) {
-                    break;
-                }
-            }
-        }
-        return lstConflictingDpns;
-    }
-
-    public static VtepConfigSchema constructVtepConfigSchema(String schemaName, String portName, Integer vlanId,
-                                                             String subnetMask, String gatewayIp, String transportZone,
-                                                             String tunnelType, List<BigInteger> dpnIds,
-                                                             String excludeIpFilter) {
-        IpAddress gatewayIpObj = StringUtils.isBlank(gatewayIp) ? null : IpAddressBuilder.getDefaultInstance(gatewayIp);
-        IpPrefix subnet = StringUtils.isBlank(subnetMask) ? null : IpPrefixBuilder.getDefaultInstance(subnetMask);
-        Class<? extends TunnelTypeBase> tunType ;
-        if (tunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
-            tunType = TunnelTypeVxlan.class ;
-        } else {
-            tunType = TunnelTypeGre.class ;
-        }
-        VtepConfigSchemaBuilder schemaBuilder = new VtepConfigSchemaBuilder().setSchemaName(schemaName)
-                .setPortName(portName).setVlanId(vlanId).setSubnet(subnet).setGatewayIp(gatewayIpObj)
-                .setTransportZoneName(transportZone).setTunnelType(tunType).setDpnIds(getDpnIdsListFromBigInt(dpnIds))
-                .setExcludeIpFilter(excludeIpFilter);
-        return schemaBuilder.build();
-    }
-
-    public static List<IpAddress> getExcludeIpAddresses(String excludeIpFilter, SubnetInfo subnetInfo) {
-        final List<IpAddress> lstIpAddress = new ArrayList<>();
-        if (StringUtils.isBlank(excludeIpFilter)) {
-            return lstIpAddress;
-        }
-        final String[] arrIps = StringUtils.split(excludeIpFilter, ',');
-        for (String ip : arrIps) {
-            if (StringUtils.countMatches(ip, "-") == 1) {
-                final String[] arrIpRange = StringUtils.split(ip, '-');
-                String strStartIp = StringUtils.trim(arrIpRange[0]);
-                String strEndIp = StringUtils.trim(arrIpRange[1]);
-                Preconditions.checkArgument(InetAddresses.isInetAddress(strStartIp),
-                        "Invalid exclude IP filter: invalid IP address value " + strStartIp);
-                Preconditions.checkArgument(InetAddresses.isInetAddress(strEndIp),
-                        "Invalid exclude IP filter: invalid IP address value " + strEndIp);
-                Preconditions.checkArgument(subnetInfo.isInRange(strStartIp),
-                        "Invalid exclude IP filter: IP address [" + strStartIp
-                                + "] not in subnet range " + subnetInfo.getCidrSignature());
-                Preconditions.checkArgument(subnetInfo.isInRange(strEndIp),
-                        "Invalid exclude IP filter: IP address [" + strEndIp
-                                + "] not in subnet range " + subnetInfo.getCidrSignature());
-                int startIp = subnetInfo.asInteger(strStartIp);
-                int endIp = subnetInfo.asInteger(strEndIp);
-
-                Preconditions.checkArgument(startIp < endIp,
-                        "Invalid exclude IP filter: Invalid range [" + ip + "] ");
-                for (int iter = startIp; iter <= endIp; iter++) {
-                    String ipAddress = ipFormat(toIpArray(iter));
-                    validateAndAddIpAddressToList(subnetInfo, lstIpAddress, ipAddress);
-                }
-            } else {
-                validateAndAddIpAddressToList(subnetInfo, lstIpAddress, ip);
-            }
-        }
-        return lstIpAddress;
-    }
-
-    private static void validateAndAddIpAddressToList(SubnetInfo subnetInfo, final List<IpAddress> lstIpAddress,
-                                                      String ipAddress) {
-        String ip = StringUtils.trim(ipAddress);
-        Preconditions.checkArgument(InetAddresses.isInetAddress(ip),
-                "Invalid exclude IP filter: invalid IP address value " + ip);
-        Preconditions.checkArgument(subnetInfo.isInRange(ip),
-                "Invalid exclude IP filter: IP address [" + ip + "] not in subnet range "
-                        + subnetInfo.getCidrSignature());
-        lstIpAddress.add(IpAddressBuilder.getDefaultInstance(ip));
-    }
-
-    private static int[] toIpArray(int val) {
-        int[] ret = new int[4];
-        for (int iter = 3; iter >= 0; --iter) {
-            ret[iter] |= val >>> 8 * (3 - iter) & 0xff;
-        }
-        return ret;
-    }
-
-    private static String ipFormat(int[] octets) {
-        StringBuilder str = new StringBuilder();
-        for (int iter = 0; iter < octets.length; ++iter) {
-            str.append(octets[iter]);
-            if (iter != octets.length - 1) {
-                str.append(".");
-            }
-        }
-        return str.toString();
-    }
-
-    public static VtepConfigSchema validateForUpdateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd,
-                                                               List<BigInteger> lstDpnsForDelete,
-                                                               IITMProvider itmProvider) {
-        Preconditions.checkArgument(StringUtils.isNotBlank(schemaName));
-        Preconditions.checkArgument(lstDpnsForAdd != null && !lstDpnsForAdd.isEmpty() && lstDpnsForDelete != null
-                && !lstDpnsForDelete.isEmpty(),
-            "DPN ID list for add | delete is null or empty in schema " + schemaName);
-        VtepConfigSchema schema = itmProvider.getVtepConfigSchema(schemaName);
-        Preconditions.checkArgument(schema != null, "Specified VTEP Schema [" + schemaName + "] doesn't exist!");
-        List<BigInteger> existingDpnIds = getDpnIdList(nullToEmpty(schema.getDpnIds()));
-        if (isNotEmpty(lstDpnsForAdd)) {
-            List<BigInteger> lstAlreadyExistingDpns = new ArrayList<>(existingDpnIds);
-            lstAlreadyExistingDpns.retainAll(lstDpnsForAdd);
-            Preconditions.checkArgument(lstAlreadyExistingDpns.isEmpty(),
-                    "DPN ID's " + lstAlreadyExistingDpns
-                            + " already exists in VTEP schema [" + schemaName + "]");
-            if (TunnelTypeGre.class.equals(schema.getTunnelType())) {
-                validateForSingleGreTep(schema.getSchemaName(), lstDpnsForAdd, itmProvider.getAllVtepConfigSchemas());
-            }
-        }
-        if (isNotEmpty(lstDpnsForDelete)) {
-            Preconditions.checkArgument(!existingDpnIds.isEmpty(), "DPN ID's " + lstDpnsForDelete
-                + " specified for delete from VTEP schema [" + schemaName
-                + "] are not configured in the schema.");
-            if (!existingDpnIds.containsAll(lstDpnsForDelete)) {
-                List<BigInteger> lstConflictingDpns = new ArrayList<>(lstDpnsForDelete);
-                lstConflictingDpns.removeAll(existingDpnIds);
-                throw new IllegalArgumentException("DPN ID's " + lstConflictingDpns
-                    + " specified for delete from VTEP schema [" + schemaName
-                    + "] are not configured in the schema.");
-            }
-        }
-        return schema;
-    }
-
-    public static String getSubnetCidrAsString(IpPrefix subnet) {
-        return subnet == null ? StringUtils.EMPTY : subnet.stringValue();
-    }
-
-    public static <T> List<T> emptyIfNull(List<T> list) {
-        return list == null ? emptyList() : list;
-    }
-
     public static <T> boolean isEmpty(Collection<T> collection) {
         return collection == null || collection.isEmpty();
     }
 
-    public static <T> boolean isNotEmpty(Collection<T> collection) {
-        return !isEmpty(collection);
-    }
-
-    @Nonnull
-    public static HwVtep createHwVtepObject(String topoId, String nodeId, IpAddress ipAddress, IpPrefix ipPrefix,
-                                            IpAddress gatewayIP, int vlanID,
-                                            Class<? extends TunnelTypeBase> tunneltype, TransportZone transportZone) {
+    public static @NonNull HwVtep createHwVtepObject(String topoId, String nodeId, IpAddress ipAddress,
+                                                     Class<? extends TunnelTypeBase> tunneltype,
+                                                     TransportZone transportZone) {
         HwVtep hwVtep = new HwVtep();
-        hwVtep.setGatewayIP(gatewayIP);
         hwVtep.setHwIp(ipAddress);
-        hwVtep.setIpPrefix(ipPrefix);
         hwVtep.setNodeId(nodeId);
         hwVtep.setTopoId(topoId);
         hwVtep.setTransportZone(transportZone.getZoneName());
         hwVtep.setTunnelType(tunneltype);
-        hwVtep.setVlanID(vlanID);
         return hwVtep;
     }
 
     public static String getHwParentIf(String topoId, String srcNodeid) {
-        return String.format("%s:%s", topoId, srcNodeid);
+        return topoId + ":" + srcNodeid;
     }
 
     /**
@@ -812,36 +543,18 @@ public final class ItmUtils {
         }
     }
 
-    @Nonnull
-    public static List<BigInteger> getDpnIdList(List<DpnIds> dpnIds) {
-        List<BigInteger> dpnList = new ArrayList<>() ;
-        for (DpnIds dpn : dpnIds) {
-            dpnList.add(dpn.getDPN()) ;
-        }
-        return dpnList ;
-    }
-
-    public static List<DpnIds> getDpnIdsListFromBigInt(List<BigInteger> dpnIds) {
-        List<DpnIds> dpnIdList = new ArrayList<>();
-        DpnIdsBuilder builder = new DpnIdsBuilder();
-        for (BigInteger dpnId : dpnIds) {
-            dpnIdList.add(builder.withKey(new DpnIdsKey(dpnId)).setDPN(dpnId).build());
-        }
-        return dpnIdList;
-    }
-
     public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
             .rev140508.interfaces.state.Interface> buildStateInterfaceId(
             String interfaceName) {
         return InstanceIdentifier.builder(InterfacesState.class)
                 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
-                               .state.Interface.class,
-                       new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
-                               .rev140508.interfaces.state.InterfaceKey(
-                               interfaceName)).build();
+                                .state.Interface.class,
+                        new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
+                                .rev140508.interfaces.state.InterfaceKey(
+                                interfaceName)).build();
     }
 
-    @Nonnull
+    @NonNull
     public static List<String> getInternalTunnelInterfaces(DataBroker dataBroker) {
         Collection<String> internalInterfaces = ITM_CACHE.getAllInternalInterfaces();
         List<String> tunnelList = new ArrayList<>();
@@ -872,126 +585,6 @@ public final class ItmUtils {
         return tunnelList;
     }
 
-    public static List<String> getTunnelsofTzone(List<HwVtep> hwVteps, String tzone, DataBroker dataBroker,
-                                                 Boolean hwVtepsExist) {
-        List<String> tunnels = new ArrayList<>();
-        InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class)
-                .child(TransportZone.class, new TransportZoneKey(tzone)).build();
-        Optional<TransportZone> transportZoneOptional =
-                ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
-        if (transportZoneOptional.isPresent()) {
-            TransportZone transportZone = transportZoneOptional.get();
-            Class<? extends TunnelTypeBase> tunType = transportZone.getTunnelType();
-            if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
-                for (Subnets sub : transportZone.getSubnets()) {
-                    if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
-                        for (Vteps vtepLocal : sub.getVteps()) {
-                            for (Vteps vtepRemote : sub.getVteps()) {
-                                if (!vtepLocal.equals(vtepRemote)) {
-                                    InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(),
-                                            vtepLocal.getDpnId(), tunType);
-                                    InstanceIdentifier<InternalTunnel> intIID =
-                                            InstanceIdentifier.builder(TunnelList.class)
-                                                    .child(InternalTunnel.class, key).build();
-                                    Optional<InternalTunnel> tunnelsOptional =
-                                            ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
-                                    if (tunnelsOptional.isPresent()) {
-                                        List<String> tunnelInterfaceNames = tunnelsOptional
-                                                .get().getTunnelInterfaceNames();
-                                        if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
-                                            String tunnelInterfaceName = tunnelInterfaceNames.get(0);
-                                            LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
-                                            tunnels.add(tunnelInterfaceName);
-                                        }
-                                    }
-                                }
-                            }
-                            if (hwVteps != null && !hwVteps.isEmpty()) {
-                                for (HwVtep hwVtep : hwVteps) {
-                                    tunnels.add(getExtTunnel(hwVtep.getNodeId(), vtepLocal.getDpnId().toString(),
-                                            tunType, dataBroker));
-                                    tunnels.add(getExtTunnel(vtepLocal.getDpnId().toString(), hwVtep.getNodeId(),
-                                            tunType, dataBroker));
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            if (hwVtepsExist) {
-                for (HwVtep hwVtep : nullToEmpty(hwVteps)) {
-                    for (HwVtep hwVtepOther : nullToEmpty(hwVteps)) {
-                        if (!hwVtep.getHwIp().equals(hwVtepOther.getHwIp())) {
-                            tunnels.add(getExtTunnel(hwVtep.getNodeId(), hwVtepOther.getNodeId(),
-                                    tunType, dataBroker));
-                            tunnels.add(getExtTunnel(hwVtepOther.getNodeId(), hwVtep.getNodeId(),
-                                    tunType, dataBroker));
-                        }
-                    }
-                }
-            }
-        }
-        return tunnels;
-    }
-
-    public static List<String> getInternalTunnelsofTzone(String tzone, DataBroker dataBroker) {
-        List<String> tunnels = new ArrayList<>();
-        LOG.trace("Getting internal tunnels of {}",tzone);
-        InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class)
-                .child(TransportZone.class, new TransportZoneKey(tzone)).build();
-        Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
-                path, dataBroker);
-        if (transportZoneOptional.isPresent()) {
-            TransportZone transportZone = transportZoneOptional.get();
-            if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
-                for (Subnets sub : transportZone.getSubnets()) {
-                    if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
-                        for (Vteps vtepLocal : sub.getVteps()) {
-                            for (Vteps vtepRemote : sub.getVteps()) {
-                                if (!vtepLocal.equals(vtepRemote)) {
-                                    InternalTunnelKey key =
-                                            new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(),
-                                                    transportZone.getTunnelType());
-                                    InstanceIdentifier<InternalTunnel> intIID =
-                                            InstanceIdentifier.builder(TunnelList.class)
-                                                    .child(InternalTunnel.class, key).build();
-                                    Optional<InternalTunnel> tunnelsOptional =
-                                            ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
-                                    if (tunnelsOptional.isPresent()) {
-                                        List<String> tunnelInterfaceNames = tunnelsOptional.get()
-                                                .getTunnelInterfaceNames();
-                                        if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
-                                            String tunnelInterfaceName = tunnelInterfaceNames.get(0);
-                                            LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
-                                            tunnels.add(tunnelInterfaceName);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return tunnels;
-    }
-
-    private static String getExtTunnel(String nodeId, String dpId,Class<? extends TunnelTypeBase> tunType, DataBroker
-            dataBroker) {
-        LOG.trace("getting ext tunnel for {} and dpId {}",nodeId,dpId);
-        ExternalTunnelKey key = getExternalTunnelKey(dpId, nodeId, tunType);
-        InstanceIdentifier<ExternalTunnel> intIID = InstanceIdentifier.builder(ExternalTunnelList.class)
-                .child(ExternalTunnel.class, key).build();
-        Optional<ExternalTunnel> tunnelsOptional =
-                ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
-        if (tunnelsOptional.isPresent()) {
-            String tunnelInterfaceName = tunnelsOptional.get().getTunnelInterfaceName();
-            LOG.trace("ext tunnel returned {} ", tunnelInterfaceName);
-            return tunnelInterfaceName;
-        }
-        return null;
-    }
-
     @SuppressFBWarnings("RV_CHECK_FOR_POSITIVE_INDEXOF")
     public static ExternalTunnelKey getExternalTunnelKey(String dst , String src,
                                                          Class<? extends TunnelTypeBase> tunType) {
@@ -1006,10 +599,10 @@ public final class ItmUtils {
         return new ExternalTunnelKey(dst, src, tunType);
     }
 
-    public static List<TunnelEndPoints> getTEPsForDpn(BigInteger srcDpn, Collection<DPNTEPsInfo> dpnList) {
+    public static List<TunnelEndPoints> getTEPsForDpn(Uint64 srcDpn, Collection<DPNTEPsInfo> dpnList) {
         for (DPNTEPsInfo dpn : dpnList) {
             if (Objects.equals(dpn.getDPNID(), srcDpn)) {
-                return new ArrayList<>(nullToEmpty(dpn.getTunnelEndPoints()));
+                return new ArrayList<>(dpn.nonnullTunnelEndPoints());
             }
         }
         return null;
@@ -1060,7 +653,7 @@ public final class ItmUtils {
         if (externalTunnels !=  null) {
             for (ExternalTunnel tunnel : externalTunnels) {
                 String tunnelInterfaceName = tunnel.getTunnelInterfaceName();
-                if (tunnelInterfaceName != null && (tunnelInterfaceName.equalsIgnoreCase(interfaceName))) {
+                if (tunnelInterfaceName != null && tunnelInterfaceName.equalsIgnoreCase(interfaceName)) {
                     LOG.trace("getExternalTunnelFromDS tunnelInterfaceName: {} ", tunnelInterfaceName);
                     return tunnel;
                 }
@@ -1131,20 +724,6 @@ public final class ItmUtils {
         return result;
     }
 
-    public static List<DcGatewayIp> getDcGatewayIpList(DataBroker broker) {
-        InstanceIdentifier<DcGatewayIpList> dcGatewayIpListid =
-                InstanceIdentifier.builder(DcGatewayIpList.class).build();
-        Optional<DcGatewayIpList> dcGatewayIpListConfig =
-                ItmUtils.read(LogicalDatastoreType.CONFIGURATION, dcGatewayIpListid, broker);
-        if (dcGatewayIpListConfig.isPresent()) {
-            DcGatewayIpList containerList = dcGatewayIpListConfig.get();
-            if (containerList != null) {
-                return containerList.getDcGatewayIp();
-            }
-        }
-        return null;
-    }
-
     public static boolean falseIfNull(Boolean value) {
         return value == null ? false : value;
     }
@@ -1180,13 +759,13 @@ public final class ItmUtils {
      * @return the TepsInNotHostedTransportZone object in the TepsNotHosted list in Oper DS
      */
     public static TepsInNotHostedTransportZone getUnknownTransportZoneFromITMOperDS(
-        String unknownTz, DataBroker dataBroker) {
+            String unknownTz, DataBroker dataBroker) {
         InstanceIdentifier<TepsInNotHostedTransportZone> unknownTzPath =
-            InstanceIdentifier.builder(NotHostedTransportZones.class)
-                    .child(TepsInNotHostedTransportZone.class,
-                    new TepsInNotHostedTransportZoneKey(unknownTz)).build();
+                InstanceIdentifier.builder(NotHostedTransportZones.class)
+                        .child(TepsInNotHostedTransportZone.class,
+                                new TepsInNotHostedTransportZoneKey(unknownTz)).build();
         Optional<TepsInNotHostedTransportZone> unknownTzOptional =
-            ItmUtils.read(LogicalDatastoreType.OPERATIONAL, unknownTzPath, dataBroker);
+                ItmUtils.read(LogicalDatastoreType.OPERATIONAL, unknownTzPath, dataBroker);
         if (unknownTzOptional.isPresent()) {
             return unknownTzOptional.get();
         }
@@ -1212,13 +791,13 @@ public final class ItmUtils {
         NodeId ovsdbNodeId = node.key().getNodeId();
 
         NodeId brNodeId = new NodeId(ovsdbNodeId.getValue()
-            + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
+                + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
 
         InstanceIdentifier<Node> bridgeIid =
-            InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class,new NodeKey(brNodeId));
+                InstanceIdentifier
+                        .create(NetworkTopology.class)
+                        .child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID))
+                        .child(Node.class,new NodeKey(brNodeId));
 
         Optional<Node> opBridgeNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
 
@@ -1246,12 +825,12 @@ public final class ItmUtils {
      * @return the Network Topology Node i.e. OVSDB node which is managing the specified bridge
      */
     public static Node getOvsdbNode(OvsdbBridgeAugmentation bridgeAugmentation,
-        DataBroker dataBroker) {
+                                    DataBroker dataBroker) {
         Node ovsdbNode = null;
         Optional<Node> opOvsdbNode = Optional.absent();
         if (bridgeAugmentation != null) {
             InstanceIdentifier<Node> ovsdbNodeIid =
-                (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
+                    (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
             opOvsdbNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbNodeIid, dataBroker);
         }
         if (opOvsdbNode.isPresent()) {
@@ -1333,7 +912,7 @@ public final class ItmUtils {
 
     public static List<TzMembership> removeTransportZoneMembership(TunnelEndPoints endPts, List<TzMembership> zones) {
         LOG.trace(" RemoveTransportZoneMembership TEPs {}, Membership to be removed {} ", endPts, zones);
-        List<TzMembership> existingTzList = new ArrayList<>(nullToEmpty(endPts.getTzMembership())) ;
+        List<TzMembership> existingTzList = new ArrayList<>(endPts.nonnullTzMembership()) ;
         for (TzMembership membership : zones) {
             existingTzList.remove(new TzMembershipBuilder().setZoneName(membership.getZoneName()).build());
         }
@@ -1341,16 +920,15 @@ public final class ItmUtils {
         return existingTzList;
     }
 
-    @Nonnull
-    public static List<TzMembership> getOriginalTzMembership(TunnelEndPoints srcTep, BigInteger dpnId,
+    @NonNull
+    public static List<TzMembership> getOriginalTzMembership(TunnelEndPoints srcTep, Uint64 dpnId,
                                                              Collection<DPNTEPsInfo> meshedDpnList) {
         LOG.trace("Original Membership for source DPN {}, source TEP {}", dpnId, srcTep);
         for (DPNTEPsInfo dstDpn : meshedDpnList) {
             if (dpnId.equals(dstDpn.getDPNID())) {
-                List<TunnelEndPoints> endPts = dstDpn.getTunnelEndPoints();
-                for (TunnelEndPoints tep : nullToEmpty(endPts)) {
+                for (TunnelEndPoints tep : dstDpn.nonnullTunnelEndPoints()) {
                     if (Objects.equals(tep.getIpAddress(), srcTep.getIpAddress())) {
-                        List<TzMembership> tzMemberships = nullToEmpty(tep.getTzMembership());
+                        List<TzMembership> tzMemberships = tep.nonnullTzMembership();
                         LOG.debug("Original Membership size {}", tzMemberships.size()) ;
                         return tzMemberships;
                     }
@@ -1415,12 +993,11 @@ public final class ItmUtils {
     }
 
     public static InstanceIdentifier<StateTunnelList> buildStateTunnelListId(StateTunnelListKey tlKey) {
-        return InstanceIdentifier.builder(TunnelsState.class)
-                .child(StateTunnelList.class, tlKey).build();
+        return InstanceIdentifier.builder(TunnelsState.class).child(StateTunnelList.class, tlKey).build();
     }
 
-    @Nonnull
-    public static  Optional<InternalTunnel> getInternalTunnelFromDS(BigInteger srcDpn, BigInteger destDpn,
+    @NonNull
+    public static  Optional<InternalTunnel> getInternalTunnelFromDS(Uint64 srcDpn, Uint64 destDpn,
                                                                     Class<? extends TunnelTypeBase> type,
                                                                     DataBroker dataBroker) {
         InstanceIdentifier<InternalTunnel> pathLogicTunnel = InstanceIdentifier.create(TunnelList.class)
@@ -1497,7 +1074,7 @@ public final class ItmUtils {
         InstanceIdentifier<DpnEndpoints> iid = InstanceIdentifier.builder(DpnEndpoints.class).build();
         Optional<DpnEndpoints> dpnEndpoints = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, iid, dataBroker);
         if (dpnEndpoints.isPresent()) {
-            return dpnEndpoints.get().getDPNTEPsInfo();
+            return new ArrayList<>(dpnEndpoints.get().getDPNTEPsInfo());
         } else {
             return new ArrayList<>();
         }
@@ -1534,9 +1111,23 @@ public final class ItmUtils {
         return tunType ;
     }
 
-    // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3.0.2
-    @Nonnull
-    public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
-        return input != null ? input : emptyList();
+    public static List<Uint64> getDpIdFromTransportzone(DataBroker dataBroker, String tzone) {
+        List<Uint64> listOfDpId = new ArrayList<>();
+        InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class)
+                .child(TransportZone.class, new TransportZoneKey(tzone)).build();
+        Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
+                path, dataBroker);
+        if (transportZoneOptional.isPresent()) {
+            TransportZone transportZone = transportZoneOptional.get();
+            if (transportZone.getVteps() != null && !transportZone.getVteps().isEmpty()) {
+                List<Vteps> vtepsList = transportZone.getVteps();
+                if (vtepsList != null && !vtepsList.isEmpty()) {
+                    for (Vteps vtep : vtepsList) {
+                        listOfDpId.add(vtep.getDpnId());
+                    }
+                }
+            }
+        }
+        return listOfDpId;
     }
 }