OSM_HOSTNAME defaults to 127.0.0.1 instead of None 54/6854/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 6 Nov 2018 04:02:45 +0000 (05:02 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 19 Nov 2018 21:00:38 +0000 (22:00 +0100)
Change-Id: I8b53c03daf1b244feedd00a3457ef75b907b2e70
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/scripts/osm.py

index e2e60ae..d1cd349 100755 (executable)
@@ -25,6 +25,7 @@ from prettytable import PrettyTable
 import yaml
 import json
 import time
+import pycurl
 
 def check_client_version(obj, what, version='sol005'):
     '''
@@ -45,7 +46,7 @@ def check_client_version(obj, what, version='sol005'):
 
 @click.group()
 @click.option('--hostname',
-              default=None,
+              default="127.0.0.1",
               envvar='OSM_HOSTNAME',
               help='hostname of server.  ' +
                    'Also can set OSM_HOSTNAME in environment')
@@ -1567,4 +1568,11 @@ def ns_action(ctx,
 
 
 if __name__ == '__main__':
-    cli()
+    try:
+        cli()
+    except pycurl.error as e:
+        print(e)
+        print('Maybe "--hostname" option or OSM_HOSTNAME' +
+            'environment variable needs to be specified')
+        exit(1)
+