help='restricts the list to the K8s clusters matching the filter')
@click.option('--literal', is_flag=True,
help='print literally, no pretty table')
+@click.option('--long', is_flag=True, help='get more details')
@click.pass_context
-def k8scluster_list(ctx, filter, literal):
+def k8scluster_list(ctx, filter, literal, long):
"""list all K8s clusters"""
# try:
check_client_version(ctx.obj, ctx.command.name)
if literal:
print(yaml.safe_dump(resp, indent=4, default_flow_style=False))
return
- table = PrettyTable(['Name', 'Id', 'Version', 'VIM', 'K8s-nets', 'Operational State', 'Description'])
+ if long:
+ table = PrettyTable(['Name', 'Id', 'Version', 'VIM', 'K8s-nets', 'Operational State', 'Op. state (details)',
+ 'Description', 'Detailed status'])
+ else:
+ table = PrettyTable(['Name', 'Id', 'VIM', 'Operational State', 'Op. state details'])
for cluster in resp:
- table.add_row([cluster['name'], cluster['_id'], cluster['k8s_version'], cluster['vim_account'],
- json.dumps(cluster['nets']), cluster["_admin"]["operationalState"],
- trunc_text(cluster.get('description') or '', 40)])
+ op_state_details = "Helm: {}\nJuju: {}".format(
+ cluster["_admin"].get("helm-chart", "-").get("operationalState", "-"),
+ cluster["_admin"].get("juju-bundle", "-").get("operationalState", "-"))
+ if long:
+ detailed_status = cluster["_admin"].get("detailedStatus","-")
+ table.add_row([cluster['name'], cluster['_id'], cluster['k8s_version'], cluster['vim_account'],
+ json.dumps(cluster['nets']), cluster["_admin"]["operationalState"],
+ op_state_details, trunc_text(cluster.get('description') or '', 40), detailed_status])
+ else:
+ table.add_row([cluster['name'], cluster['_id'], cluster['vim_account'],
+ cluster["_admin"]["operationalState"], op_state_details])
table.align = 'l'
print(table)
# except ClientException as e: