osm.py: ns-list providing detailed status of the instantiation
[osm/osmclient.git] / osmclient / scripts / osm.py
index 16ac7d7..75b3be2 100755 (executable)
@@ -36,9 +36,9 @@ def check_client_version(obj, what, version='sol005'):
     :raises ClientError: if the specified version does not match the client version
     '''
     fullclassname = obj.__module__ + "." + obj.__class__.__name__
-    message = 'the following commands or options are only supported with the option "--sol005": {}'.format(what)
+    message = 'The following commands or options are only supported with the option "--sol005": {}'.format(what)
     if version == 'v1':
-        message = 'the following commands or options are not supported when using option "--sol005": {}'.format(what)
+        message = 'The following commands or options are not supported when using option "--sol005": {}'.format(what)
     if fullclassname != 'osmclient.{}.client.Client'.format(version):
         raise ClientException(message)
     return
@@ -112,7 +112,8 @@ def ns_list(ctx, filter):
         ['ns instance name',
          'id',
          'operational status',
-         'config status'])
+         'config status',
+         'detailed status'])
     for ns in resp:
         fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
         if fullclassname == 'osmclient.sol005.client.Client':
@@ -126,13 +127,15 @@ def ns_list(ctx, filter):
             nsr_id = nsr['ns-instance-config-ref']
         opstatus = nsr['operational-status'] if 'operational-status' in nsr else 'Not found'
         configstatus = nsr['config-status'] if 'config-status' in nsr else 'Not found'
+        detailed_status = nsr['detailed-status'] if 'detailed-status' in nsr else 'Not found'
         if configstatus == "config_not_needed":
             configstatus = "configured (no charms)"
         table.add_row(
             [nsr_name,
              nsr_id,
              opstatus,
-             configstatus])
+             configstatus,
+             detailed_status])
     table.align = 'l'
     print(table)
 
@@ -217,7 +220,12 @@ def vnfd_list2(ctx, filter):
 @click.pass_context
 def vnf_list(ctx):
     ''' list all VNF instances'''
-    resp = ctx.obj.vnf.list()
+    try:
+        check_client_version(ctx.obj, ctx.command.name, 'v1')
+        resp = ctx.obj.vnf.list()
+    except ClientException as inst:
+        print(inst.message)
+        exit(1)
     table = PrettyTable(
         ['vnf name',
          'id',
@@ -861,6 +869,8 @@ def vim_show(ctx, name):
     '''
     try:
         resp = ctx.obj.vim.get(name)
+        if 'vim_password' in resp:
+            resp['vim_password']='********'
     except ClientException as inst:
         print(inst.message)
         exit(1)