bug 376 fix 90/5590/1
authorMike Marchetti <mmarchetti@sandvine.com>
Mon, 16 Oct 2017 20:42:44 +0000 (16:42 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Mon, 16 Oct 2017 20:42:44 +0000 (16:42 -0400)
- add option to update ro manually

Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
osmclient/scripts/osm.py
osmclient/v1/vim.py

index 5d8b2b3..23f6889 100755 (executable)
@@ -460,9 +460,12 @@ def vim_delete(ctx, name):
 
 
 @cli.command(name='vim-list')
+@click.option('--ro_update/--no_ro_update',
+              default=False,
+              help='update list from RO')
 @click.pass_context
-def vim_list(ctx):
-    resp = ctx.obj.vim.list()
+def vim_list(ctx, ro_update):
+    resp = ctx.obj.vim.list(ro_update)
     table = PrettyTable(['vim name', 'uuid'])
     for vim in resp:
         table.add_row([vim['name'], vim['uuid']])
index d8a9835..b0033a1 100644 (file)
@@ -21,6 +21,7 @@ OSM vim API handling
 from osmclient.common.exceptions import ClientException
 from osmclient.common.exceptions import NotFound
 import json
+import time
 
 
 class Vim(object):
@@ -155,8 +156,13 @@ class Vim(object):
             raise ClientException("failed to delete vim {} - {}".format(vim_name, resp))
         self._update_ro_accounts()
 
-    def list(self):
-        self._update_ro_accounts()
+    def list(self, ro_update):
+        if ro_update:
+            self._update_ro_accounts()
+            # the ro_update needs to be made synchronous, for now this works around the issue
+            # and waits a resonable amount of time for the update to finish
+            time.sleep(2)
+
         if self._client._so_version == 'v3':
             resp = self._http.get_cmd('v1/api/operational/{}ro-account-state'
                     .format(self._client.so_rbac_project_path))