Fix bug 1265: fix error in k8scluster-list with helm and juju opState 62/9862/1 v8.0.3 v8.0.4
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 16 Oct 2020 12:42:43 +0000 (12:42 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 16 Oct 2020 14:10:41 +0000 (14:10 +0000)
K8scluster-list was showing errors when getting helm-chart and
juju-bundle operational state when keys were no present.

Change-Id: Iaf1e9d7cc7137ec6ea33bb458a4759f150c8d5d2
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/scripts/osm.py

index 054bbd1..7b3bfeb 100755 (executable)
@@ -3163,14 +3163,14 @@ def k8scluster_list(ctx, filter, literal, long):
     except:
         vim_list = []
     for cluster in resp:
+        logger.debug('Cluster details: {}'.format(yaml.safe_dump(cluster)))
         vim_name = get_vim_name(vim_list, cluster['vim_account'])
         #vim_info = '{} ({})'.format(vim_name,cluster['vim_account'])
         vim_info = vim_name
         op_state_details = "Helm: {}\nJuju: {}".format(
-                           cluster["_admin"].get("helm-chart", "-").get("operationalState", "-"),
-                           cluster["_admin"].get("juju-bundle", "-").get("operationalState", "-"))
+                           cluster["_admin"].get("helm-chart", {}).get("operationalState", "-"),
+                           cluster["_admin"].get("juju-bundle", {}).get("operationalState", "-"))
         if long:
-            logger.debug('Cluster details: {}'.format(yaml.safe_dump(cluster)))
             project_id, project_name = get_project(project_list, cluster)
             #project_info = '{} ({})'.format(project_name, project_id)
             project_info = project_name