From 092a31f2a5f27b1ba83a547876bd10d68fea3bcf Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 16 Sep 2020 14:14:40 +0000 Subject: [PATCH] adding operational state to the vim-list Change-Id: Ia6ed5708d64480aafb6623b91cc2bd3c062d1479 Signed-off-by: tierno --- osmclient/scripts/osm.py | 4 ++-- osmclient/sol005/vim.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 06d77e0..3ef81ac 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -2538,7 +2538,7 @@ def vim_list(ctx, filter, long): if long: table = PrettyTable(['vim name', 'uuid', 'project', 'operational state', 'error details']) else: - table = PrettyTable(['vim name', 'uuid']) + table = PrettyTable(['vim name', 'uuid', 'operational state']) for vim in resp: if long: vim_details = ctx.obj.vim.get(vim['uuid']) @@ -2562,7 +2562,7 @@ def vim_list(ctx, filter, long): 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.add_row([vim['name'], vim['uuid'], vim['_admin'].get('operationalState', '-')]) table.align = 'l' print(table) diff --git a/osmclient/sol005/vim.py b/osmclient/sol005/vim.py index 3441161..fa17dfc 100644 --- a/osmclient/sol005/vim.py +++ b/osmclient/sol005/vim.py @@ -228,10 +228,9 @@ class Vim(object): _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) if not resp: return list() - vim_accounts = [] - for datacenter in json.loads(resp): - vim_accounts.append({"name": datacenter['name'], "uuid": datacenter['_id'] - if '_id' in datacenter else None}) + vim_accounts = json.loads(resp) + for datacenter in vim_accounts: + datacenter["uuid"] = datacenter.get('_id') # backward compatibility? return vim_accounts def get(self, name): -- 2.25.1