adding operational state to the vim-list 18/9718/3
authortierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 16 Sep 2020 14:14:40 +0000 (14:14 +0000)
committerbeierlm <mark.beierl@canonical.com>
Thu, 24 Sep 2020 19:44:12 +0000 (21:44 +0200)
Fixes bug 1225

Change-Id: Ia6ed5708d64480aafb6623b91cc2bd3c062d1479
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osmclient/scripts/osm.py
osmclient/sol005/vim.py

index 06d77e0..3ef81ac 100755 (executable)
@@ -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)
 
index 3441161..fa17dfc 100644 (file)
@@ -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):