Fix path and content for KSU creation to match NB API 87/14587/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 20 Sep 2024 12:09:47 +0000 (14:09 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 30 Sep 2024 15:39:47 +0000 (17:39 +0200)
Change-Id: Ib6f1de64d3cdbaa268fd01b4567b267be879c4b3
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/cli_commands/ksu.py
osmclient/sol005/osm_api_object.py

index b89fca3..cea9005 100755 (executable)
@@ -68,8 +68,9 @@ def verify_and_update_ksu(ctx, ksu):
         raise ClientException("A profile must be provided for each KSU")
     if "oka" in ksu:
         for oka in ksu["oka"]:
-            if "_id" in oka:
-                oka["_id"] = get_oka_id(ctx, oka["_id"])
+            oka_id = oka.get("_id", "")
+            if oka_id:
+                oka["_id"] = get_oka_id(ctx, oka_id)
             elif "sw_catalog_path" not in oka:
                 raise ClientException(
                     "An OKA id or name, or a SW catalog path must be provided for each OKA"
@@ -96,6 +97,7 @@ def process_common_ksu_params(ctx, ksu_dict, ksu_args):
                     raise ClientException(
                         "No path was provided after --sw-catalog-path"
                     )
+                oka_dict["_id"] = ""
                 oka_dict["sw_catalog_path"] = oka_args[i + 1]
                 i = i + 2
                 continue
@@ -248,7 +250,7 @@ def ksu_create(ctx, args, ksu_params):
     for ksu in ksu_params:
         verify_and_update_ksu(ctx, ksu)
     logger.debug(f"ksu_params:\n{yaml.safe_dump(ksu_params)}")
-    ctx.obj.ksu.multi_create_update(ksu_params, "create")
+    ctx.obj.ksu.multi_create_update({"ksus": ksu_params}, "")
 
 
 @click.command(name="ksu-delete", short_help="deletes one or several KSU")
index 4ce94b9..4dfe4cd 100644 (file)
@@ -172,7 +172,10 @@ class GenericOSMAPIObject(ABC):
         """Create or update a bundle of Generic OSM API Object specified by content"""
         self._logger.debug("")
         self._client.get_token()
-        endpoint = f"{self._apiBase}/{endpoint_suffix}"
+        if endpoint_suffix:
+            endpoint = f"{self._apiBase}/{endpoint_suffix}"
+        else:
+            endpoint = f"{self._apiBase}"
         http_code, resp = self.generic_post(endpoint=endpoint, content=content)
         if http_code in (200, 201, 202):
             if not resp: