From: garciadeblas Date: Mon, 27 Apr 2020 13:30:32 +0000 (+0000) Subject: Added project to osm vim-list --long X-Git-Tag: v7.1.0rc1^2~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F8824%2F1;p=osm%2Fosmclient.git Added project to osm vim-list --long Change-Id: I2a8941c84ef371d12738965d43b8e07545f47128 Signed-off-by: garciadeblas --- diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 6161e43..59ecebd 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -2297,7 +2297,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 +2310,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'