Support OVSDB entity ownership ID format 11/98211/5
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 28 Oct 2021 21:04:59 +0000 (14:04 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Thu, 28 Oct 2021 23:19:53 +0000 (16:19 -0700)
Entity type 'ovsdb' has its own entity ID format, different from
the one for ServiceEntityType & AsyncServiceCloseEntityType.
Add entity ID template for for 'ovsdb' entity type.

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

csit/libraries/ClusterEntities.py

index b8023f105f2a3ff8ea7e58bdf237b053e1f81e0c..bf7c017931c223bc42b86770f7c8ae2ec12ab86d 100644 (file)
@@ -141,6 +141,15 @@ def get_entity_type_data(restconf_url, e_type):
         auth=("admin", "admin"),
     )
 
+    info(
+        "Response %s ",
+        resp,
+    )
+    info(
+        "Entity json %s",
+        resp.json(),
+    )
+
     return resp.json()["entity-owners:entity-type"][0]
 
 
@@ -153,12 +162,15 @@ def get_entity_data(restconf_url, e_type, e_name):
     :param e_name: entity name
     :return: entity owner & candidates
     """
+    id_templates = {
+        "org.opendaylight.mdsal.ServiceEntityType": "/odl-general-entity:entity[name='%s']",
+        "org.opendaylight.mdsal.AsyncServiceCloseEntityType": "/odl-general-entity:entity[name='%s']",
+        "ovsdb": "/network-topology:network-topology/topology[topology-id='ovsdb:1']/node[node-id='%s']",
+    }
+    id_template = id_templates[e_type]
+
     entity_type = get_entity_type_data(restconf_url, e_type)
-    entity = [
-        e
-        for e in entity_type["entity"]
-        if e["id"] == "/odl-general-entity:entity[name='%s']" % e_name
-    ][0]
+    entity = [e for e in entity_type["entity"] if e["id"] == id_template % e_name][0]
 
     result = {
         "candidates": [c["name"] for c in entity["candidate"]],