Avoid unnecessary bridge Oper DS read
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / SouthboundUtil.java
index 34fd897e005bd1c3500900ce252debe3306e7b8a..fe610b27ccccfa6520eb354155d92bb63f4c4df6 100644 (file)
@@ -187,4 +187,14 @@ public final class SouthboundUtil {
         }
         return nodeId;
     }
+
+    public static String getBridgeNameFromOvsdbNodeId(InstanceIdentifier<Node> nodeIid) {
+        String nodeId = getOvsdbNodeId(nodeIid);
+        if (nodeId != null && !nodeId.isEmpty() && nodeId.contains("bridge")
+                && nodeId.lastIndexOf("bridge") + 7 < nodeId.length()) {
+            return nodeId.substring(nodeId.indexOf("bridge") + 7);// to fetch bridge name ex: "/bridge/br-int"
+        } else {
+            return null;
+        }
+    }
 }