[WIP] ONOS-8091 Port python script and utilities to python3

Steps performed so far:
- Updated bash scripts and similar to explicitly invoke python3 (instead of python)
- Updated all python scripts using 2to3

Testing these changes will be a major headache because:
- different scripts are executed in different environments
  (e.g., Jenkins, cell servers, tutorial VMs, etc.)
- we don’t have control on all environments
- some environments we used to control have been dismissed
  (e.g., cell servers)

The approach for now is to focus on the essentials:
- Jenkins jobs for pre-merge and release

Test and fix everything else as the need arises.

Change-Id: I943e214760c9dea9a7ded0d47ef08adbc0ed0bec
diff --git a/tools/test/scenarios/bin/execute-tapi-post-call.py b/tools/test/scenarios/bin/execute-tapi-post-call.py
index f6d419a..a0fe4c7 100755
--- a/tools/test/scenarios/bin/execute-tapi-post-call.py
+++ b/tools/test/scenarios/bin/execute-tapi-post-call.py
@@ -1,16 +1,15 @@
-#! /usr/bin/env python
-
+#! /usr/bin/env python3
 import sys
 import tapiHelper
 import json
 
 if len(sys.argv) < 4:
-    print "usage: execute-tapi-post-call <onos-node> <context> <empty> [uuid]."
-    print "\t- If <empty> is \"empty\", it measn that it should be no devices, links or ports"
-    print "\t- Uuid is optional and defaults to empty"
-    print "\t- For example:\n\t\t- line-side connectivity creation: %s\n\t\t- client-side connectivity creation: %s" % \
-          ("python execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service line-side",
-           "python execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service client-side")
+    print("usage: execute-tapi-post-call <onos-node> <context> <empty> [uuid].")
+    print("\t- If <empty> is \"empty\", it measn that it should be no devices, links or ports")
+    print("\t- Uuid is optional and defaults to empty")
+    print("\t- For example:\n\t\t- line-side connectivity creation: %s\n\t\t- client-side connectivity creation: %s" % \
+          ("python3 execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service line-side",
+           "python3 execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service client-side"))
     sys.exit(1)
 
 node = sys.argv[1]
@@ -22,40 +21,40 @@
 else:
     uuid = sys.argv[4]
 # request example:
-# python execute-tapi-post-call.py localhost tapi-common:get-service-interface-point-list empty
+# python3 execute-tapi-post-call.py localhost tapi-common:get-service-interface-point-list empty
 if "get-connectivity-service-list" in context:
     connectivity_request = 'http://' + node + ':8181/onos/restconf/operations/' + context
     tapi_connection = tapiHelper.get_connection(connectivity_request, uuid)
     tapi_connection_json = tapi_connection.json()
-    print tapi_connection_json
+    print(tapi_connection_json)
     if not tapi_connection_json["tapi-connectivity:output"] and empty != "empty":
-       print "No connection was established"
+       print("No connection was established")
        sys.exit(0)
     if empty == "empty":
         if not tapi_connection_json["tapi-connectivity:output"]:
             sys.exit(0)
         else:
-            print "There exist some connectivities!!!"
+            print("There exist some connectivities!!!")
             sys.exit(1)
     if uuid == "":
         # verify empty connection
-        print tapi_connection_json
+        print(tapi_connection_json)
     elif uuid != "":
         # verify correct connection
         servs = tapi_connection_json["tapi-connectivity:output"]["service"]
         for s in range(len(servs)):
             if servs[s]['uuid'] == uuid:
-                print "Find service with uuid %s" % uuid
-                print servs[s]
+                print("Find service with uuid %s" % uuid)
+                print(servs[s])
                 sys.exit(0)
     else:
-        print "Invalid input for 3rd and 4th parameters."
+        print("Invalid input for 3rd and 4th parameters.")
         sys.exit(1)
     sys.exit(0)
 
 # test succeeds by using cmd:
-# python execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service line-side
-# python execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service client-side
+# python3 execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service line-side
+# python3 execute-tapi-post-call.py 127.0.0.1 tapi-connectivity:create-connectivity-service client-side
 if "create-connectivity-service" in context:
     context_request = 'http://' + node + ':8181/onos/restconf/data/tapi-common:context'
     connectivity_request = 'http://' + node + ':8181/onos/restconf/operations/' + context
@@ -65,8 +64,8 @@
         tapi_connection = tapiHelper.create_client_connection(context_request, connectivity_request)
     else:
         raise NotImplementedError("Not Implementation for option %s." % empty)
-    print "\nThe request context is:\t%s." % context
-    print "\nThe return message of the request is:\n\t\t%s " % json.dumps(tapi_connection.json())
+    print("\nThe request context is:\t%s." % context)
+    print("\nThe return message of the request is:\n\t\t%s " % json.dumps(tapi_connection.json()))
     sys.exit(0)
 
 sys.exit(1)