From: garciadeblas Date: Wed, 23 Sep 2020 11:03:41 +0000 (+0000) Subject: Fix bug 1230: show Helm and Juju status when listing K8s clusters X-Git-Tag: v8.0.2~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f4036d090fc8a49c37d62e774d7725095d2a8376;p=osm%2Fosmclient.git Fix bug 1230: show Helm and Juju status when listing K8s clusters Added --long option to k8scluster_list and moved some fields there Change-Id: I24d660b571e44e861f218063c22339923315baed Signed-off-by: garciadeblas --- diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 0ff195f..71506cd 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -3129,8 +3129,9 @@ def k8scluster_delete(ctx, name, force): 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) @@ -3140,11 +3141,23 @@ def k8scluster_list(ctx, filter, literal): 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: