Fix profile_type used in KSU creation and parse responses in multicreate calls 88/14588/3
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 23 Sep 2024 10:33:43 +0000 (12:33 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 3 Oct 2024 11:31:14 +0000 (13:31 +0200)
Change-Id: Iaf29de73ad774c501178bf6ce5429079b4ba97b2
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/cli_commands/ksu.py
osmclient/sol005/osm_api_object.py

index cea9005..27f050d 100755 (executable)
@@ -49,6 +49,13 @@ def verify_and_update_ksu(ctx, ksu):
         else:
             raise ClientException("Unexpected failure when reading the profile")
 
+    profile_type_mapping = {
+        "infra-controller-profile": "infra_controller_profiles",
+        "infra-config-profile": "infra_config_profiles",
+        "app-profile": "app_profiles",
+        "resource-profile": "resource_profiles",
+    }
+
     logger.debug("")
     if "name" not in ksu:
         raise ClientException("A name must be provided for each KSU")
@@ -64,6 +71,8 @@ def verify_and_update_ksu(ctx, ksu):
             )
         else:
             raise ClientException("A profile id or name must be provided for each KSU")
+        # Finally update the profile type to use the string expected by NBI
+        ksu_profile["profile_type"] = profile_type_mapping[ksu_profile_type]
     else:
         raise ClientException("A profile must be provided for each KSU")
     if "oka" in ksu:
index 4dfe4cd..0c1ba1e 100644 (file)
@@ -181,7 +181,9 @@ class GenericOSMAPIObject(ABC):
             if not resp:
                 raise ClientException(f"unexpected response from server - {resp}")
             resp = json.loads(resp)
-            print(resp)
+            # print(resp)
+            output = ",".join(resp["id"])
+            print(output)
         elif http_code == 204:
             print("Received")