},
]
common.generic_list(
- callback=ctx.obj.cluster.list_both,
+ callback=ctx.obj.cluster.enhanced_list,
filter=filter,
format=output,
extras=extra_items,
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(
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(
(
(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