From d5173e4febc36c21453fbf7f85162bc477fae2c6 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Fri, 20 Sep 2024 14:09:47 +0200 Subject: [PATCH] Fix path and content for KSU creation to match NB API Change-Id: Ib6f1de64d3cdbaa268fd01b4567b267be879c4b3 Signed-off-by: garciadeblas --- osmclient/cli_commands/ksu.py | 8 +++++--- osmclient/sol005/osm_api_object.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osmclient/cli_commands/ksu.py b/osmclient/cli_commands/ksu.py index b89fca3..cea9005 100755 --- a/osmclient/cli_commands/ksu.py +++ b/osmclient/cli_commands/ksu.py @@ -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") diff --git a/osmclient/sol005/osm_api_object.py b/osmclient/sol005/osm_api_object.py index 4ce94b9..4dfe4cd 100644 --- a/osmclient/sol005/osm_api_object.py +++ b/osmclient/sol005/osm_api_object.py @@ -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: -- 2.25.1