Update cluster list and show commands after combination of both cluster collections in NBI
Change-Id: Id121ebf7891a9f10a2653537e737f3f6df84d504
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
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 @@
},
]
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 @@
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 @@
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 @@
(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