Rename netconf-impl to netconf-api
[integration/test.git] / csit / libraries / ClusterEntities.py
index 507966c9d6c21537bb72dcd3b9f30c03373ce8fc..ad396a83d8a1e10e4b09baece72517c46d8957b7 100644 (file)
@@ -18,14 +18,28 @@ def get_entities(restconf_url):
             "User-Agent": "csit agent",
         },
         auth=("admin", "admin"),
+        timeout=10.0,
     )
 
     info(
-        "Response %s ",
+        "Response %s",
         resp,
     )
+    info(
+        "Response JSON %s",
+        resp.json(),
+    )
 
-    return resp.json()
+    if resp.status_code == status_codes["bad_request"]:
+        info(
+            "Status code is '%s' - trying operational data instead.",
+            resp.status_code,
+        )
+        result = get_entities_data(restconf_url)
+    else:
+        result = resp.json()
+
+    return result
 
 
 def get_entity_name(e_type, e_name):
@@ -76,10 +90,15 @@ def get_entity(restconf_url, e_type, e_name):
         },
         data=data,
         auth=("admin", "admin"),
+        timeout=10.0,
     )
 
     info(
-        "Entity json %s",
+        "Response %s",
+        resp,
+    )
+    info(
+        "Response JSON %s",
         resp.json(),
     )
 
@@ -122,12 +141,17 @@ def get_entity_owner(restconf_url, e_type, e_name):
         },
         data=data,
         auth=("admin", "admin"),
+        timeout=10.0,
     )
 
     info(
-        "Response %s ",
+        "Response %s",
         resp,
     )
+    info(
+        "Response JSON %s",
+        resp.json(),
+    )
 
     if resp.status_code == status_codes["bad_request"]:
         info(
@@ -141,6 +165,34 @@ def get_entity_owner(restconf_url, e_type, e_name):
     return result
 
 
+def get_entities_data(restconf_url):
+    """
+    Get the entity information from the datastore for Silicon
+    or earlier versions.
+    :param restconf_url: RESTCONF URL up to the RESTCONF root
+    """
+    resp = get(
+        url=restconf_url + "/data/entity-owners:entity-owners",
+        headers={
+            "Accept": "application/yang-data+json",
+            "User-Agent": "csit agent",
+        },
+        auth=("admin", "admin"),
+        timeout=10.0,
+    )
+
+    info(
+        "Response %s",
+        resp,
+    )
+    info(
+        "Response JSON %s",
+        resp.json(),
+    )
+
+    return resp.json()
+
+
 def get_entity_type_data(restconf_url, e_type):
     """
     Get the entity information for the given entity type from the datastore
@@ -158,14 +210,15 @@ def get_entity_type_data(restconf_url, e_type):
             "User-Agent": "csit agent",
         },
         auth=("admin", "admin"),
+        timeout=10.0,
     )
 
     info(
-        "Response %s ",
+        "Response %s",
         resp,
     )
     info(
-        "Entity json %s",
+        "Response JSON %s",
         resp.json(),
     )