From 6568d6e3d301476ff902b29ac5f2471fa2e614a2 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 7 May 2020 07:08:31 +0000 Subject: [PATCH] ns-list: fix when deployment and config status were empty Change-Id: If559ad034aac754feb7065db7a1f72d7c2f3b2c3 Signed-off-by: garciadeblas --- osmclient/scripts/osm.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index a17340b..c6de974 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -228,6 +228,8 @@ def ns_list(ctx, filter, long): def summarize_deployment_status(status_dict): #Nets summary = "" + if not status_dict: + return summary n_nets = 0 status_nets = {} net_list = status_dict.get('nets',[]) @@ -278,6 +280,9 @@ def ns_list(ctx, filter, long): return summary def summarize_config_status(ee_list): + summary = "" + if not ee_list: + return summary n_ee = 0 status_ee = {} for ee in ee_list: @@ -290,7 +295,6 @@ def ns_list(ctx, filter, long): status_ee[ee['elementType']][ee['status']] += 1 else: status_ee[ee['elementType']][ee['status']] = 1 - summary = "" for elementType in ["KDU", "VDU", "PDU", "VNF", "NS"]: if elementType in status_ee: message = "" @@ -341,8 +345,8 @@ def ns_list(ctx, filter, long): date = datetime.fromtimestamp(nsr['create-time']).strftime("%Y-%m-%dT%H:%M:%S") ns_state = nsr.get('nsState', nsr['_admin']['nsState']) if long: - deployment_status = summarize_deployment_status(nsr['deploymentStatus']) - config_status = summarize_config_status(nsr['configurationStatus']) + deployment_status = summarize_deployment_status(nsr.get('deploymentStatus')) + config_status = summarize_config_status(nsr.get('configurationStatus')) project_id = nsr.get('_admin').get('projects_read')[0] project_name = '-' for p in project_list: -- 2.25.1