From: garciadeblas Date: Fri, 20 Sep 2024 12:09:47 +0000 (+0200) Subject: Fix path and content for KSU creation to match NB API X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F14587%2F2;p=osm%2Fosmclient.git Fix path and content for KSU creation to match NB API Change-Id: Ib6f1de64d3cdbaa268fd01b4567b267be879c4b3 Signed-off-by: garciadeblas --- 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: