From: tierno Date: Wed, 16 Sep 2020 14:14:40 +0000 (+0000) Subject: adding operational state to the vim-list X-Git-Tag: release-v9.0-start~20 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=092a31f2a5f27b1ba83a547876bd10d68fea3bcf;p=osm%2Fosmclient.git adding operational state to the vim-list Change-Id: Ia6ed5708d64480aafb6623b91cc2bd3c062d1479 Signed-off-by: tierno --- 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):