Upgrade to Neon base platform
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / SouthboundMapper.java
index 6055ca05f4f9d27e889b69dff40d6a307323479b..7b0f86b0e39134b4874be83d61effcc76d2c5541 100644 (file)
@@ -7,6 +7,13 @@
  */
 package org.opendaylight.ovsdb.southbound;
 
+import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableBiMap;
+import com.google.common.net.InetAddresses;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -17,7 +24,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
 import org.opendaylight.ovsdb.lib.notation.UUID;
@@ -27,11 +33,12 @@ import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
 import org.opendaylight.ovsdb.schema.openvswitch.Manager;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
-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.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.ovsdb.schema.openvswitch.Qos;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+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.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeSystem;
@@ -39,6 +46,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.QosTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntry;
@@ -53,25 +62,20 @@ 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.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableBiMap;
+public final class SouthboundMapper {
+
+    private SouthboundMapper() { }
 
-public class SouthboundMapper {
     private static final Logger LOG = LoggerFactory.getLogger(SouthboundMapper.class);
     private static final String N_CONNECTIONS_STR = "n_connections";
 
-    private static NodeId createNodeId(OvsdbConnectionInstance client) {
-        NodeKey key = client.getInstanceIdentifier().firstKeyOf(Node.class, NodeKey.class);
-        return key.getNodeId();
-
-    }
-
     public static IpAddress createIpAddress(InetAddress address) {
         IpAddress ip = null;
         if (address instanceof Inet4Address) {
@@ -83,8 +87,7 @@ public class SouthboundMapper {
     }
 
     public static IpAddress createIpAddress(Inet4Address address) {
-        Ipv4Address ipv4 = new Ipv4Address(address.getHostAddress());
-        return new IpAddress(ipv4);
+        return IetfInetUtil.INSTANCE.ipAddressFor(address);
     }
 
     public static IpAddress createIpAddress(Inet6Address address) {
@@ -92,63 +95,64 @@ public class SouthboundMapper {
         return new IpAddress(ipv6);
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(NodeId nodeId) {
+    public static InstanceIdentifier<Topology> createTopologyInstanceIdentifier() {
         return InstanceIdentifier
                 .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
+                .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
+    }
+
+    public static InstanceIdentifier<Node> createInstanceIdentifier(NodeId nodeId) {
+        return createTopologyInstanceIdentifier()
                 .child(Node.class,new NodeKey(nodeId));
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(OvsdbConnectionInstance client,Bridge bridge) {
+    @SuppressWarnings("unchecked")
+    public static InstanceIdentifier<Node> createInstanceIdentifier(InstanceIdentifierCodec instanceIdentifierCodec,
+            OvsdbConnectionInstance client, Bridge bridge) {
         InstanceIdentifier<Node> iid;
         if (bridge.getExternalIdsColumn() != null
                 && bridge.getExternalIdsColumn().getData() != null
                 && bridge.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
             String iidString = bridge.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY);
-            iid = (InstanceIdentifier<Node>) SouthboundUtil.deserializeInstanceIdentifier(iidString);
+            iid = (InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializerOrNull(iidString);
         } else {
-            String nodeString = client.getNodeKey().getNodeId().getValue()
-                    + "/bridge/" + bridge.getName();
-            NodeId nodeId = new NodeId(new Uri(nodeString));
-            NodeKey nodeKey = new NodeKey(nodeId);
-            iid = InstanceIdentifier.builder(NetworkTopology.class)
-                    .child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
-                    .child(Node.class,nodeKey)
-                    .build();
+            iid = createInstanceIdentifier(client, bridge.getName());
         }
         return iid;
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(
+    @SuppressWarnings("unchecked")
+    public static InstanceIdentifier<Node> createInstanceIdentifier(InstanceIdentifierCodec instanceIdentifierCodec,
             OvsdbConnectionInstance client, Controller controller, String bridgeName) {
         InstanceIdentifier<Node> iid;
         if (controller.getExternalIdsColumn() != null
                 && controller.getExternalIdsColumn().getData() != null
                 && controller.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
             String iidString = controller.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY);
-            iid = (InstanceIdentifier<Node>) SouthboundUtil.deserializeInstanceIdentifier(iidString);
+            iid = (InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializerOrNull(iidString);
         } else {
-            // TODO retrieve bridge name
-            String nodeString = client.getNodeKey().getNodeId().getValue()
-                    + "/bridge/" + bridgeName;
-            NodeId nodeId = new NodeId(new Uri(nodeString));
-            NodeKey nodeKey = new NodeKey(nodeId);
-            iid = InstanceIdentifier.builder(NetworkTopology.class)
-                    .child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
-                    .child(Node.class,nodeKey)
-                    .build();
+            iid = createInstanceIdentifier(client, bridgeName);
         }
         return iid;
     }
 
+    public static InstanceIdentifier<Node> createInstanceIdentifier(
+            OvsdbConnectionInstance client, String bridgeName) {
+        String nodeString = client.getNodeKey().getNodeId().getValue()
+                + "/bridge/" + bridgeName;
+        NodeId nodeId = new NodeId(new Uri(nodeString));
+        return createInstanceIdentifier(nodeId);
+
+    }
+
     public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
-        NodeKey nodeKey = iid.firstKeyOf(Node.class, NodeKey.class);
+        NodeKey nodeKey = iid.firstKeyOf(Node.class);
         return nodeKey.getNodeId();
     }
 
     public static InetAddress createInetAddress(IpAddress ip) throws UnknownHostException {
         if (ip.getIpv4Address() != null) {
-            return InetAddress.getByName(ip.getIpv4Address().getValue());
+            return InetAddresses.forString(ip.getIpv4Address().getValue());
         } else if (ip.getIpv6Address() != null) {
             return InetAddress.getByName(ip.getIpv6Address().getValue());
         } else {
@@ -176,15 +180,26 @@ public class SouthboundMapper {
         }
     }
 
+    public static DatapathId createDatapathId(String dpid) {
+        Preconditions.checkNotNull(dpid);
+        DatapathId datapath;
+        if (dpid.matches("^[0-9a-fA-F]{16}")) {
+            Splitter splitter = Splitter.fixedLength(2);
+            Joiner joiner = Joiner.on(":");
+            datapath = new DatapathId(joiner.join(splitter.split(dpid)));
+        } else {
+            datapath = new DatapathId(dpid);
+        }
+        return datapath;
+    }
+
     public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
-        String datapathtype = new String(SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class));
+        String datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class);
 
-        if (mdsalbridge.getDatapathType() != null) {
-            if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
-                datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
-            } else {
-                throw new IllegalArgumentException("Unknown datapath type "
-                        + SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()));
+        if (mdsalbridge.getDatapathType() != null && !mdsalbridge.getDatapathType().equals(DatapathTypeBase.class)) {
+            datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
+            if (datapathtype == null) {
+                throw new IllegalArgumentException("Unknown datapath type " + mdsalbridge.getDatapathType().getName());
             }
         }
         return datapathtype;
@@ -201,19 +216,6 @@ public class SouthboundMapper {
         }
     }
 
-    public static DatapathId createDatapathId(String dpid) {
-        Preconditions.checkNotNull(dpid);
-        DatapathId datapath;
-        if (dpid.matches("^[0-9a-fA-F]{16}")) {
-            Splitter splitter = Splitter.fixedLength(2);
-            Joiner joiner = Joiner.on(":");
-            datapath = new DatapathId(joiner.join(splitter.split(dpid)));
-        } else {
-            datapath = new DatapathId(dpid);
-        }
-        return datapath;
-    }
-
     public static Set<String> createOvsdbBridgeProtocols(OvsdbBridgeAugmentation ovsdbBridgeNode) {
         Set<String> protocols = new HashSet<>();
         if (ovsdbBridgeNode.getProtocolEntry() != null && ovsdbBridgeNode.getProtocolEntry().size() > 0) {
@@ -245,8 +247,7 @@ public class SouthboundMapper {
         try {
             protocols = bridge.getProtocolsColumn().getData();
         } catch (SchemaVersionMismatchException e) {
-            // We don't care about the exception stack trace here
-            LOG.warn("protocols not supported by this version of ovsdb: {}", e.getMessage());
+            schemaMismatchLog("protocols", "Bridge", e);
         }
         List<ProtocolEntry> protocolList = new ArrayList<>();
         if (protocols != null && protocols.size() > 0) {
@@ -254,8 +255,7 @@ public class SouthboundMapper {
                     SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
             for (String protocol : protocols) {
                 if (protocol != null && mapper.get(protocol) != null) {
-                    protocolList.add(new ProtocolEntryBuilder().
-                            setProtocol(mapper.get(protocol)).build());
+                    protocolList.add(new ProtocolEntryBuilder().setProtocol(mapper.get(protocol)).build());
                 }
             }
         }
@@ -275,10 +275,10 @@ public class SouthboundMapper {
 
         LOG.debug("createControllerEntries Bridge: {}\n, updatedControllerRows: {}",
                 bridge, updatedControllerRows);
-        final Set<UUID> controllerUUIDs = bridge.getControllerColumn().getData();
+        final Set<UUID> controllerUuids = bridge.getControllerColumn().getData();
         final List<ControllerEntry> controllerEntries = new ArrayList<>();
-        for (UUID controllerUUID : controllerUUIDs ) {
-            final Controller controller = updatedControllerRows.get(controllerUUID);
+        for (UUID controllerUuid : controllerUuids) {
+            final Controller controller = updatedControllerRows.get(controllerUuid);
             addControllerEntries(controllerEntries, controller);
         }
         LOG.debug("controllerEntries: {}", controllerEntries);
@@ -300,7 +300,7 @@ public class SouthboundMapper {
                 bridgeNode, updatedControllerRows);
         final List<ControllerEntry> controllerEntriesCreated = new ArrayList<>();
         final OvsdbBridgeAugmentation ovsdbBridgeAugmentation =
-                bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
+                bridgeNode.augmentation(OvsdbBridgeAugmentation.class);
         if (ovsdbBridgeAugmentation == null) {
             return controllerEntriesCreated;
         }
@@ -331,31 +331,42 @@ public class SouthboundMapper {
             final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid uuid =
                     new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
                             .ietf.yang.types.rev130715.Uuid(controller.getUuid().toString());
+            ControllerEntryBuilder builder = new ControllerEntryBuilder();
 
-            controllerEntries.add(new ControllerEntryBuilder()
+            if (controller.getMaxBackoffColumn() != null && controller.getMaxBackoffColumn().getData() != null
+                    && !controller.getMaxBackoffColumn().getData().isEmpty()) {
+                builder.setMaxBackoff(controller.getMaxBackoffColumn().getData().iterator().next());
+            }
+            if (controller.getInactivityProbeColumn() != null && controller.getInactivityProbeColumn().getData() != null
+                    && !controller.getInactivityProbeColumn().getData().isEmpty()) {
+                builder.setInactivityProbe(controller.getInactivityProbeColumn().getData().iterator().next());
+            }
+            controllerEntries.add(builder
                     .setTarget(new Uri(targetString))
                     .setIsConnected(controller.getIsConnectedColumn().getData())
                     .setControllerUuid(uuid).build());
         }
     }
 
+    // This is not called from anywhere but test. Do we need this?
     public static Map<UUID, Controller> createOvsdbController(OvsdbBridgeAugmentation omn,DatabaseSchema dbSchema) {
         List<ControllerEntry> controllerEntries = omn.getControllerEntry();
         Map<UUID,Controller> controllerMap = new HashMap<>();
         if (controllerEntries != null && !controllerEntries.isEmpty()) {
             for (ControllerEntry controllerEntry : controllerEntries) {
-                String controllerNamedUUID = "Controller_" + getRandomUUID();
+                String controllerNamedUuid = "Controller_" + getRandomUuid();
                 Controller controller = TyperUtils.getTypedRowWrapper(dbSchema, Controller.class);
                 controller.setTarget(controllerEntry.getTarget().getValue());
-                controllerMap.put(new UUID(controllerNamedUUID), controller);
+                controllerMap.put(new UUID(controllerNamedUuid), controller);
             }
         }
         return controllerMap;
     }
 
-    public static String getRandomUUID() {
+    public static String getRandomUuid() {
         return "Random_" + java.util.UUID.randomUUID().toString().replace("-", "");
     }
+
     public static ConnectionInfo createConnectionInfo(OvsdbClient client) {
         ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder();
         connectionInfoBuilder.setRemoteIp(createIpAddress(client.getConnectionInfo().getRemoteAddress()));
@@ -385,10 +396,10 @@ public class SouthboundMapper {
 
         LOG.debug("createManagerEntries OpenVSwitch: {}\n, updatedManagerRows: {}",
                 ovsdbNode, updatedManagerRows);
-        final Set<UUID> managerUUIDs = ovsdbNode.getManagerOptionsColumn().getData();
+        final Set<UUID> managerUuids = ovsdbNode.getManagerOptionsColumn().getData();
         final List<ManagerEntry> managerEntries = new ArrayList<>();
-        for (UUID managerUUID : managerUUIDs ) {
-            final Manager manager = updatedManagerRows.get(managerUUID);
+        for (UUID managerUuid : managerUuids) {
+            final Manager manager = updatedManagerRows.get(managerUuid);
             addManagerEntries(managerEntries, manager);
         }
         LOG.debug("managerEntries: {}", managerEntries);
@@ -410,7 +421,7 @@ public class SouthboundMapper {
                 ovsdbNode, updatedManagerRows);
         final List<ManagerEntry> managerEntriesCreated = new ArrayList<>();
         final OvsdbNodeAugmentation ovsdbNodeAugmentation =
-                ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+                ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
         if (ovsdbNodeAugmentation == null) {
             return managerEntriesCreated;
         }
@@ -439,8 +450,9 @@ public class SouthboundMapper {
             long numberOfConnections = 0;
             final String targetString = manager.getTargetColumn().getData();
 
-            final Map<String, String> statusAttributeMap = manager.getStatusColumn().getData();
-            if (statusAttributeMap.containsKey(N_CONNECTIONS_STR)) {
+            final Map<String, String> statusAttributeMap =
+                            manager.getStatusColumn() == null ? null : manager.getStatusColumn().getData();
+            if (statusAttributeMap != null && statusAttributeMap.containsKey(N_CONNECTIONS_STR)) {
                 String numberOfConnectionValueStr = statusAttributeMap.get(N_CONNECTIONS_STR);
                 numberOfConnections = Integer.parseInt(numberOfConnectionValueStr);
             } else {
@@ -456,23 +468,84 @@ public class SouthboundMapper {
         }
     }
 
-    public static InstanceIdentifier<Node> getInstanceIdentifier(OpenVSwitch ovs) {
-        InstanceIdentifier<Node> iid = null;
+    /**
+     * Return the MD-SAL QoS type class corresponding to the QoS type {@link Qos}.
+     *
+     * @param type the QoS type to match {@link String}
+     * @return class matching the input QoS type {@link QosTypeBase}
+     */
+    public static  Class<? extends QosTypeBase> createQosType(String type) {
+        Preconditions.checkNotNull(type);
+        if (type.isEmpty()) {
+            LOG.info("QoS type not supplied");
+            return QosTypeBase.class;
+        } else {
+            ImmutableBiMap<String, Class<? extends QosTypeBase>> mapper =
+                    SouthboundConstants.QOS_TYPE_MAP.inverse();
+            if (mapper.get(type) == null) {
+                LOG.info("QoS type not found in model: {}", type);
+                return QosTypeBase.class;
+            } else {
+                return mapper.get(type);
+            }
+        }
+    }
+
+    public static String createQosType(Class<? extends QosTypeBase> qosTypeClass) {
+        String qosType = SouthboundConstants.QOS_TYPE_MAP.get(QosTypeBase.class);
+
+        if (qosTypeClass != null && !qosTypeClass.equals(QosTypeBase.class)) {
+            qosType = SouthboundConstants.QOS_TYPE_MAP.get(qosTypeClass);
+            if (qosType == null) {
+                throw new IllegalArgumentException("Unknown QoS type" + qosTypeClass.getName());
+            }
+        }
+        return qosType;
+    }
+
+
+    public static InstanceIdentifier<Node> getInstanceIdentifier(InstanceIdentifierCodec instanceIdentifierCodec,
+            OpenVSwitch ovs) {
         if (ovs.getExternalIdsColumn() != null
                 && ovs.getExternalIdsColumn().getData() != null
                 && ovs.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
             String iidString = ovs.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY);
-            iid = (InstanceIdentifier<Node>) SouthboundUtil.deserializeInstanceIdentifier(iidString);
+            return (InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializerOrNull(iidString);
         } else {
             String nodeString = SouthboundConstants.OVSDB_URI_PREFIX + "://" + SouthboundConstants.UUID + "/"
                     + ovs.getUuid().toString();
             NodeId nodeId = new NodeId(new Uri(nodeString));
             NodeKey nodeKey = new NodeKey(nodeId);
-            iid = InstanceIdentifier.builder(NetworkTopology.class)
+            return InstanceIdentifier.builder(NetworkTopology.class)
                     .child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
                     .child(Node.class,nodeKey)
                     .build();
         }
-        return iid;
+    }
+
+    public static Map<InstanceIdentifier<?>, DataObject> extractTerminationPointConfigurationChanges(
+            final Node bridgeNode) {
+        Map<InstanceIdentifier<?>, DataObject> changes = new HashMap<>();
+        final InstanceIdentifier<Node> bridgeNodeIid =
+                SouthboundMapper.createInstanceIdentifier(bridgeNode.getNodeId());
+        changes.put(bridgeNodeIid, bridgeNode);
+
+        List<TerminationPoint> terminationPoints = bridgeNode.getTerminationPoint();
+        if (terminationPoints != null && !terminationPoints.isEmpty()) {
+            for (TerminationPoint tp : terminationPoints) {
+                OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
+                        tp.augmentation(OvsdbTerminationPointAugmentation.class);
+                if (ovsdbTerminationPointAugmentation != null) {
+                    final InstanceIdentifier<OvsdbTerminationPointAugmentation> tpIid =
+                            bridgeNodeIid
+                                    .child(TerminationPoint.class, new TerminationPointKey(tp.getTpId()))
+                                    .builder()
+                                    .augmentation(OvsdbTerminationPointAugmentation.class)
+                                    .build();
+                    changes.put(tpIid, ovsdbTerminationPointAugmentation);
+                }
+            }
+        }
+        return changes;
     }
 }