Added command patterns to update OperDS
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepSouthboundMapper.java
index 32be9a22d54146b51f12005e69589e0f9f0a292b..e487f25dc2eb5855280e2edde7c531f57946137b 100644 (file)
@@ -15,6 +15,7 @@ import java.net.UnknownHostException;
 
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.schema.hardwarevtep.Global;
+import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
 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;
@@ -120,13 +121,8 @@ public class HwvtepSouthboundMapper {
 
     public static InstanceIdentifier<Node> getInstanceIdentifier(Global global) {
         InstanceIdentifier<Node> iid = null;
-        if (global.getManagersColumn() != null
-                && global.getManagersColumn().getData() != null) {
-            String iidString = global.getManagersColumn().getData().iterator().next().toString();
-            iid = (InstanceIdentifier<Node>) HwvtepSouthboundUtil.deserializeInstanceIdentifier(iidString);
-        } else {
-            String nodeString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://" +
-                            HwvtepSouthboundConstants.UUID + "/" + global.getUuid().toString();
+        String nodeString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://" +
+                        HwvtepSouthboundConstants.UUID + "/" + global.getUuid().toString();
             NodeId nodeId = new NodeId(new Uri(nodeString));
             NodeKey nodeKey = new NodeKey(nodeId);
             TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
@@ -134,7 +130,18 @@ public class HwvtepSouthboundMapper {
                             .child(Topology.class, topoKey)
                             .child(Node.class,nodeKey)
                             .build();
-        }
+        return iid;
+    }
+
+    public static InstanceIdentifier<Node> createInstanceIdentifier(HwvtepConnectionInstance client,
+                    PhysicalSwitch pSwitch) {
+        InstanceIdentifier<Node> iid = null;
+        String nodeString = client.getNodeKey().getNodeId().getValue() + "/physicalswitch/" + pSwitch.getName();
+        NodeId nodeId = new NodeId(new Uri(nodeString));
+        NodeKey nodeKey = new NodeKey(nodeId);
+        iid =InstanceIdentifier.builder(NetworkTopology.class)
+                        .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
+                        .child(Node.class, nodeKey).build();
         return iid;
     }
 }