--sol005 as default option
[osm/osmclient.git] / osmclient / scripts / osm.py
index fd92477..d581228 100755 (executable)
@@ -69,10 +69,10 @@ def check_client_version(obj, what, version='sol005'):
               envvar='OSM_RO_PORT',
               help='hostname of RO server.  ' +
                    'Also can set OSM_RO_PORT in environment')
-@click.option('--sol005',
-              is_flag=True,
+@click.option('--sol005/--no-sol005',
+              default=True,
               envvar='OSM_SOL005',
-              help='Use ETSI NFV SOL005 API')
+              help='Use ETSI NFV SOL005 API (default) or the previous SO API')
 @click.pass_context
 def cli(ctx, hostname, so_port, so_project, ro_hostname, ro_port, sol005):
     if hostname is None:
@@ -230,20 +230,41 @@ def vnf_list(ctx, ns):
     except ClientException as inst:
         print(inst.message)
         exit(1)
-    table = PrettyTable(
-        ['vnf name',
-         'id',
-         'operational status',
-         'config status'])
-    for vnfr in resp:
-        if 'mgmt-interface' not in vnfr:
-            vnfr['mgmt-interface'] = {}
-            vnfr['mgmt-interface']['ip-address'] = None
-        table.add_row(
-            [vnfr['name'],
-             vnfr['id'],
-             vnfr['operational-status'],
-             vnfr['config-status']])
+    fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
+    if fullclassname == 'osmclient.sol005.client.Client':
+        table = PrettyTable(
+            ['vnf id',
+             'name',
+             'ns id',
+             'vnf member index',
+             'vnfd name',
+             'vim account id',
+             'ip address'])
+        for vnfr in resp:
+            name = vnfr['name'] if 'name' in vnfr else '-'
+            table.add_row(
+                [vnfr['_id'],
+                 name,
+                 vnfr['nsr-id-ref'],
+                 vnfr['member-vnf-index-ref'],
+                 vnfr['vnfd-ref'],
+                 vnfr['vim-account-id'],
+                 vnfr['ip-address']])
+    else:
+        table = PrettyTable(
+            ['vnf name',
+             'id',
+             'operational status',
+             'config status'])
+        for vnfr in resp:
+            if 'mgmt-interface' not in vnfr:
+                vnfr['mgmt-interface'] = {}
+                vnfr['mgmt-interface']['ip-address'] = None
+            table.add_row(
+                [vnfr['name'],
+                 vnfr['id'],
+                 vnfr['operational-status'],
+                 vnfr['config-status']])
     table.align = 'l'
     print(table)
 
@@ -842,7 +863,7 @@ def vim_create(ctx,
         vim['vim-tenant-name'] = tenant
         vim['vim-type'] = account_type
         vim['description'] = description
-        vim ['config'] = config
+        vim['config'] = config
         if sdn_controller or sdn_port_mapping:
             ctx.obj.vim.create(name, vim, sdn_controller, sdn_port_mapping)
         else: