From: garciadeblas Date: Mon, 13 Jan 2025 10:09:43 +0000 (+0100) Subject: Update cluster list and show commands after combination of both cluster collections... X-Git-Tag: v18.0.0~16 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=6bf4557d8a8dd11b0240cd8c2f40e2b6ac495a7a;p=osm%2Fosmclient.git Update cluster list and show commands after combination of both cluster collections in NBI Change-Id: Id121ebf7891a9f10a2653537e737f3f6df84d504 Signed-off-by: garciadeblas --- diff --git a/osmclient/cli_commands/cluster.py b/osmclient/cli_commands/cluster.py index 4cb15b9..6f4b56f 100755 --- a/osmclient/cli_commands/cluster.py +++ b/osmclient/cli_commands/cluster.py @@ -133,7 +133,7 @@ def cluster_list(ctx, filter, output): }, ] common.generic_list( - callback=ctx.obj.cluster.list_both, + callback=ctx.obj.cluster.enhanced_list, filter=filter, format=output, extras=extra_items, @@ -153,7 +153,7 @@ def cluster_show(ctx, name, output): NAME: name or ID of the K8s cluster """ logger.debug("") - common.generic_show(callback=ctx.obj.cluster.get_both, name=name, format=output) + common.generic_show(callback=ctx.obj.cluster.get, name=name, format=output) @click.command( diff --git a/osmclient/sol005/cluster.py b/osmclient/sol005/cluster.py index 2665351..b1291c2 100644 --- a/osmclient/sol005/cluster.py +++ b/osmclient/sol005/cluster.py @@ -134,30 +134,17 @@ class Cluster(GenericOSMAPIObject): endpoint_suffix = f"{item['_id']}/update" self.generic_operation(cluster_changes, endpoint_suffix=endpoint_suffix) - def list_both(self, filter=None): - """List all clusters from both new and old APIs""" + def enhanced_list(self, filter=None): + """List all clusters with additional resolution (VIM)""" self._logger.debug("") - cluster_list1 = self.list(filter) - cluster_list2 = self._client.k8scluster.list(filter) - list1_names = {item["name"] for item in cluster_list1} - for item in cluster_list2: - if item["name"] not in list1_names: - # Complete the information for clusters from old API - item["state"] = "N/A" - old_state = item.get("_admin", {}).get("operationalState", "Unknown") - item["bootstrap"] = "NO" - item["operatingState"] = "N/A" - item["resourceState"] = old_state - item["created"] = "NO" - cluster_list1.append(item) - # Complete cluster info with vim_account name and vim_type + cluster_list = self.list(filter) vim_list = self._client.vim.list() self._logger.debug(f"VIM list: {vim_list}") if not vim_list: self._logger.warning( "Could not complete cluster info with VIM account info" ) - for item in cluster_list1: + for item in cluster_list: vim_id = item["vim_account"] vim_name, vim_type = next( ( @@ -168,20 +155,4 @@ class Cluster(GenericOSMAPIObject): (None, None), ) item["vim_account"] = f"{vim_name} ({vim_type})" - return cluster_list1 - - def get_both(self, name): - """ - Gets and shows an individual cluster - from both new and old API - """ - self._logger.debug("") - try: - cluster = self.get(name) - return cluster - except NotFound: - try: - cluster2 = self._client.k8scluster.get(name) - return cluster2 - except NotFound: - raise NotFound(f"{self._logObjectName} {name} not found") + return cluster_list