Support OVSDB entity name format in Phosphorus 99/98399/2
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 11 Nov 2021 04:57:35 +0000 (20:57 -0800)
committerLuis Gomez <ecelgp@gmail.com>
Fri, 12 Nov 2021 02:17:10 +0000 (02:17 +0000)
Retrieval of the OVSDB entity ownership is now supported
in Phosphorus/Sulfur (CONTROLLER-2009).
Update ClusterEntities.py to update entity name following
the OVSDB instance identifier name format to retrieve
the entity ownership information.

Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Change-Id: I9abe99f1e6bfbaabd3f9460df552f24bf8e996b9

csit/libraries/ClusterEntities.py

index bf7c017931c223bc42b86770f7c8ae2ec12ab86d..507966c9d6c21537bb72dcd3b9f30c03373ce8fc 100644 (file)
@@ -28,6 +28,25 @@ def get_entities(restconf_url):
     return resp.json()
 
 
+def get_entity_name(e_type, e_name):
+    """
+    Get the effective entity name for the given entity type.
+    If the entity type is not for odl-general-entity, entity name
+    should be the full instance identifier.
+    :param e_type: entity type
+    :param e_name: entity name
+    :return: updated entity name
+    """
+    name_templates = {
+        "ovsdb": "/network-topology:network-topology/topology[topology-id='ovsdb:1']/node[node-id='%s']",
+    }
+
+    if e_type in name_templates:
+        return name_templates[e_type] % e_name
+    else:
+        return e_name
+
+
 def get_entity(restconf_url, e_type, e_name):
     """Calls the get-entity rpc on the controller and returns the result in a
     dictionary that contains the parsed response in two keys:
@@ -43,7 +62,7 @@ def get_entity(restconf_url, e_type, e_name):
     }
     """ % (
         e_type,
-        e_name,
+        get_entity_name(e_type, e_name),
     )
 
     info("Data %s", data)
@@ -89,7 +108,7 @@ def get_entity_owner(restconf_url, e_type, e_name):
     }
     """ % (
         e_type,
-        e_name,
+        get_entity_name(e_type, e_name),
     )
 
     info("Data %s", data)