X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fscripts%2Fosm.py;h=c6de974310b56973f3dfd475861b64d730298451;hb=6568d6e3d301476ff902b29ac5f2471fa2e614a2;hp=6161e43420ae5972dff3aaf3fad14217351b9e3d;hpb=8e7a83989eb2264ad9f50c6b92cb7621bd550223;p=osm%2Fosmclient.git diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 6161e43..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 = "" @@ -302,6 +306,7 @@ def ns_list(ctx, filter, long): summary += "{}: {}".format(elementType, message) summary += "TOTAL Exec. Env.: {}".format(n_ee) return summary + logger.debug("") if filter: check_client_version(ctx.obj, '--filter') @@ -334,13 +339,14 @@ def ns_list(ctx, filter, long): fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ if fullclassname == 'osmclient.sol005.client.Client': nsr = ns + logger.debug('NS info: {}'.format(nsr)) nsr_name = nsr['name'] nsr_id = nsr['_id'] date = datetime.fromtimestamp(nsr['create-time']).strftime("%Y-%m-%dT%H:%M:%S") - ns_state = nsr['nsState'] + 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: @@ -357,9 +363,12 @@ def ns_list(ctx, filter, long): break #vim = '{} ({})'.format(vim_name, vim_id) vim = vim_name - current_operation = "{} ({})".format(nsr['currentOperation'],nsr['currentOperationID']) + if 'currentOperation' in nsr: + current_operation = "{} ({})".format(nsr['currentOperation'],nsr['currentOperationID']) + else: + current_operation = "{} ({})".format(nsr['_admin'].get('current-operation','-'), nsr['_admin']['nslcmop']) error_details = "N/A" - if ns_state == "BROKEN" or ns_state == "DEGRADED" or nsr['errorDescription']: + if ns_state == "BROKEN" or ns_state == "DEGRADED" or nsr.get('errorDescription'): error_details = "{}\nDetail: {}".format(nsr['errorDescription'], nsr['errorDetail']) else: nsopdata = ctx.obj.ns.get_opdata(ns['id']) @@ -2297,7 +2306,7 @@ def vim_list(ctx, filter, long): # else: # resp = ctx.obj.vim.list(ro_update) if long: - table = PrettyTable(['vim name', 'uuid', 'operational state', 'error details']) + table = PrettyTable(['vim name', 'uuid', 'project', 'operational state', 'error details']) else: table = PrettyTable(['vim name', 'uuid']) for vim in resp: @@ -2310,7 +2319,18 @@ def vim_list(ctx, filter, long): error_details = 'N/A' if vim_state == 'ERROR': error_details = vim_details['_admin'].get('detailed-status', 'Not found') - table.add_row([vim['name'], vim['uuid'], vim_state, wrap_text(text=error_details, width=80)]) + project_list = ctx.obj.project.list() + vim_project_list = vim_details.get('_admin').get('projects_read') + project_id = 'None' + project_name = 'None' + if vim_project_list: + project_id = vim_project_list[0] + for p in project_list: + if p['_id'] == project_id: + project_name = p['name'] + break + table.add_row([vim['name'], vim['uuid'], '{} ({})'.format(project_name, project_id), + vim_state, wrap_text(text=error_details, width=80)]) else: table.add_row([vim['name'], vim['uuid']]) table.align = 'l'