[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/check-dhcp-netcfg.py b/tools/test/scenarios/bin/check-dhcp-netcfg.py
index c828c84..2786785 100755
--- a/tools/test/scenarios/bin/check-dhcp-netcfg.py
+++ b/tools/test/scenarios/bin/check-dhcp-netcfg.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
@@ -6,7 +6,7 @@
from requests.auth import HTTPBasicAuth
if len(sys.argv) < 3:
- print "usage: find-dhcp-netcfg onos-node name1=value1 ..."
+ print("usage: find-dhcp-netcfg onos-node name1=value1 ...")
sys.exit(1)
node = sys.argv[1]
@@ -15,7 +15,7 @@
':8181/onos/v1/network/configuration/apps/org.onosproject.dhcp',
auth=HTTPBasicAuth('onos', 'rocks'))
-print cfgRequest.text
+print(cfgRequest.text)
if cfgRequest.status_code != 200:
sys.exit(1)
@@ -32,8 +32,8 @@
value = pair[1]
if dhcp[name] != value:
- print name + " differs: expected " + value + " but found " + dhcp[name]
- print cfgJson
+ print(name + " differs: expected " + value + " but found " + dhcp[name])
+ print(cfgJson)
sys.exit(1)
diff --git a/tools/test/scenarios/bin/check-masters.py b/tools/test/scenarios/bin/check-masters.py
index dfe4df6..9e68cad 100755
--- a/tools/test/scenarios/bin/check-masters.py
+++ b/tools/test/scenarios/bin/check-masters.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import json
import subprocess
@@ -6,7 +6,7 @@
import time
if len(sys.argv) != 2:
- print "usage: check-masters {node}"
+ print("usage: check-masters {node}")
sys.exit(1)
node = sys.argv[1]
diff --git a/tools/test/scenarios/bin/create-flow.py b/tools/test/scenarios/bin/create-flow.py
index 9d709a0..a5bf9ba 100755
--- a/tools/test/scenarios/bin/create-flow.py
+++ b/tools/test/scenarios/bin/create-flow.py
@@ -1,5 +1,4 @@
-#! /usr/bin/env python
-
+#! /usr/bin/env python3
import requests
from requests.auth import HTTPBasicAuth
@@ -8,7 +7,7 @@
if len(sys.argv) != 6:
- print "usage: create-flow onos-node name device in-port out-port"
+ print("usage: create-flow onos-node name device in-port out-port")
sys.exit(1)
node = sys.argv[1]
@@ -47,11 +46,11 @@
params=payload)
if flowRequest.status_code != 201:
- print flowRequest.text
+ print(flowRequest.text)
sys.exit(1)
location = flowRequest.headers["location"]
-print "@stc " + name + "Location=" + location
+print("@stc " + name + "Location=" + location)
sys.exit(0)
diff --git a/tools/test/scenarios/bin/create-intent.py b/tools/test/scenarios/bin/create-intent.py
index 4e5d4f6..aeb2492 100755
--- a/tools/test/scenarios/bin/create-intent.py
+++ b/tools/test/scenarios/bin/create-intent.py
@@ -1,5 +1,4 @@
-#! /usr/bin/env python
-
+#! /usr/bin/env python3
import requests
from requests.auth import HTTPBasicAuth
@@ -8,7 +7,7 @@
if len(sys.argv) != 7:
- print "usage: create-intent onos-node name ingressDevice ingressPort egressDevice egressPort"
+ print("usage: create-intent onos-node name ingressDevice ingressPort egressDevice egressPort")
sys.exit(1)
node = sys.argv[1]
@@ -38,11 +37,11 @@
data=intentJson)
if intentRequest.status_code != 201:
- print intentRequest.text
+ print(intentRequest.text)
sys.exit(1)
location = intentRequest.headers["location"]
-print "@stc " + name + "Location=" + location
+print("@stc " + name + "Location=" + location)
sys.exit(0)
diff --git a/tools/test/scenarios/bin/delete-netcfg.py b/tools/test/scenarios/bin/delete-netcfg.py
index 6e309c2..410bc47 100755
--- a/tools/test/scenarios/bin/delete-netcfg.py
+++ b/tools/test/scenarios/bin/delete-netcfg.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
@@ -8,7 +8,7 @@
if len(sys.argv) != 3:
- print "usage: delete-netcfg onos-node config-name"
+ print("usage: delete-netcfg onos-node config-name")
sys.exit(1)
node = sys.argv[1]
@@ -18,7 +18,7 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if intentRequest.status_code != 204:
- print intentRequest.text
+ print(intentRequest.text)
sys.exit(1)
sys.exit(0)
diff --git a/tools/test/scenarios/bin/execute-tapi-context-get-call.py b/tools/test/scenarios/bin/execute-tapi-context-get-call.py
index 22b1f27..7ddee28 100755
--- a/tools/test/scenarios/bin/execute-tapi-context-get-call.py
+++ b/tools/test/scenarios/bin/execute-tapi-context-get-call.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
@@ -7,14 +7,14 @@
from requests.auth import HTTPBasicAuth
if len(sys.argv) < 3:
- print "usage: execute-tapi-context-get-call onos-node state"
+ print("usage: execute-tapi-context-get-call onos-node state")
sys.exit(1)
node = sys.argv[1]
state = sys.argv[2] #if empty tapi context must be empty, if full it needs to contain all devices and ports
if state != "empty" and len(sys.argv) == 3:
- print "usage: execute-tapi-context-get-call onos-node full devices links ports"
+ print("usage: execute-tapi-context-get-call onos-node full devices links ports")
sys.exit(1)
request = 'http://' + node + ':8181/onos/restconf/data/tapi-common:context'
@@ -23,9 +23,9 @@
if state == "empty":
uuid = tapiContext['tapi-common:context']['tapi-topology:topology-context']['topology'][0]['uuid']
if uuid == "":
- print "empty uuid"
+ print("empty uuid")
sys.exit(1)
- print "@stc tapi topology uuid=" + uuid
+ print("@stc tapi topology uuid=" + uuid)
sys.exit(0)
if state == "full":
@@ -37,11 +37,11 @@
port_num = 0
for x in range(dev_num):
port_num=port_num+len(tapiContext['tapi-common:context']['tapi-topology:topology-context']['topology'][0]['node'][x]['owned-node-edge-point'])
- print "device\tlink\tport\n%i\t%i\t%i" % (dev_num, directed_link_num/2, port_num)
+ print("device\tlink\tport\n%i\t%i\t%i" % (dev_num, directed_link_num/2, port_num))
assert devices == dev_num
assert links == directed_link_num/2
assert ports == port_num
- print "Topology infomation checking passed."
+ print("Topology infomation checking passed.")
sys.exit(0)
sys.exit(1)
diff --git a/tools/test/scenarios/bin/execute-tapi-delete-call.py b/tools/test/scenarios/bin/execute-tapi-delete-call.py
index aa9abfc..f2cfbfe 100755
--- a/tools/test/scenarios/bin/execute-tapi-delete-call.py
+++ b/tools/test/scenarios/bin/execute-tapi-delete-call.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import sys
import tapiHelper
@@ -6,16 +6,16 @@
import requests
if len(sys.argv) != 3 and len(sys.argv) != 4:
- print "usage: execute-tapi-delete-call <onos-node> <deletion-type> [uuid]"
- print "\t- <onos-node> is onos IP. 'localhost' is invalid."
- print "\t- <deletion-type> is one of {line, client, both}, which mean line-side deletion, " \
- "client-side deletion, and all deletion respectively."
- print "\t- [uuid] is the created service uuid, which is optional. If uuid is empty, " \
- "all connectivity services with <deletion-type> will be deleted."
- print "\t If [uuid] is not empty, and <deletion-type> is 'both', this script doesn't work."
- print "\t Otherwise, delete line-side or client-side connectivity with specific uuid."
- print "For example, if we want to delete all client-side services on local host, the command should be:"
- print "\t python execute-tapi-delete-call.py 127.0.0.1 client"
+ print("usage: execute-tapi-delete-call <onos-node> <deletion-type> [uuid]")
+ print("\t- <onos-node> is onos IP. 'localhost' is invalid.")
+ print("\t- <deletion-type> is one of {line, client, both}, which mean line-side deletion, " \
+ "client-side deletion, and all deletion respectively.")
+ print("\t- [uuid] is the created service uuid, which is optional. If uuid is empty, " \
+ "all connectivity services with <deletion-type> will be deleted.")
+ print("\t If [uuid] is not empty, and <deletion-type> is 'both', this script doesn't work.")
+ print("\t Otherwise, delete line-side or client-side connectivity with specific uuid.")
+ print("For example, if we want to delete all client-side services on local host, the command should be:")
+ print("\t python3 execute-tapi-delete-call.py 127.0.0.1 client")
sys.exit(1)
@@ -55,8 +55,8 @@
#
def post_deletion(service_uuid, del_request):
delete_input_json = json.dumps(tapi_deletion_input(service_uuid))
- print "\nThe json content of deletion operation for connectivity service is \n\t\t%s." % \
- delete_input_json
+ print("\nThe json content of deletion operation for connectivity service is \n\t\t%s." % \
+ delete_input_json)
headers = {'Content-type': 'application/json'}
resp = requests.post(del_request, data=delete_input_json, headers=headers, auth=('onos', 'rocks'))
if resp.status_code != 200:
@@ -79,7 +79,7 @@
try:
services = context["tapi-connectivity:connectivity-context"]["connectivity-service"]
except KeyError:
- print "Warning - there is no connectivity service in ONOS (%s)." % node
+ print("Warning - there is no connectivity service in ONOS (%s)." % node)
sys.exit(0)
# 3. handle deletion requests according to <deletion-type> and [uuid]
if serv_uuid is None:
@@ -93,13 +93,13 @@
((del_type == "client" or del_type == "both") and tapiHelper.is_dsr_media(sip)):
json_resp = post_deletion(service["uuid"], delete_request)
del_num += 1
- print "Returns json string for deletion operations is\n %s\n" % json_resp
+ print("Returns json string for deletion operations is\n %s\n" % json_resp)
if del_num == 0:
- print "Warning - there is no %s-side connectivity servicein ONOS (%s)." % (del_type, node)
+ print("Warning - there is no %s-side connectivity servicein ONOS (%s)." % (del_type, node))
else:
# If [uuid] is not empty, check the <deletion-type>
if del_type == "both":
- print "Error - The option 'both' is illegal when [uuid] is assigned."
+ print("Error - The option 'both' is illegal when [uuid] is assigned.")
else:
is_del = False
for service in services:
@@ -110,7 +110,7 @@
(del_type == "client" and tapiHelper.is_dsr_media(sip)):
json_resp = post_deletion(service["uuid"], delete_request)
is_del = True
- print "Returns json string for deletion operations is\n %s\n" % json_resp
+ print("Returns json string for deletion operations is\n %s\n" % json_resp)
break
if not is_del:
- print "Warning - Cannot find %s-side connectivity service with service uuid %s." % (del_type, serv_uuid)
+ print("Warning - Cannot find %s-side connectivity service with service uuid %s." % (del_type, serv_uuid))
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)
diff --git a/tools/test/scenarios/bin/find-device.py b/tools/test/scenarios/bin/find-device.py
index 430e18a..f222742 100755
--- a/tools/test/scenarios/bin/find-device.py
+++ b/tools/test/scenarios/bin/find-device.py
@@ -1,13 +1,13 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
-import urllib
+import urllib.request, urllib.parse, urllib.error
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 4:
- print "usage: find-device onos-node name device-id"
+ print("usage: find-device onos-node name device-id")
sys.exit(1)
node = sys.argv[1]
@@ -15,21 +15,21 @@
id = sys.argv[3]
deviceRequest = requests.get('http://' + node + ':8181/onos/v1/devices/' +
- urllib.quote_plus(id),
+ urllib.parse.quote_plus(id),
auth=HTTPBasicAuth('onos', 'rocks'))
if deviceRequest.status_code != 200:
- print deviceRequest.text
+ print(deviceRequest.text)
sys.exit(1)
deviceJson = deviceRequest.json()
-print "@stc " + name + "Id=" + deviceJson["id"]
-print "@stc " + name + "Type=" + deviceJson["type"]
-print "@stc " + name + "Available=" + str(deviceJson["available"])
+print("@stc " + name + "Id=" + deviceJson["id"])
+print("@stc " + name + "Type=" + deviceJson["type"])
+print("@stc " + name + "Available=" + str(deviceJson["available"]))
channelId = deviceJson["annotations"]["channelId"]
channelIdWords = channelId.split(':')
-print "@stc " + name + "IpAddress=" + channelIdWords[0]
+print("@stc " + name + "IpAddress=" + channelIdWords[0])
sys.exit(0)
diff --git a/tools/test/scenarios/bin/find-flow.py b/tools/test/scenarios/bin/find-flow.py
index a2f2e4d..6d68020 100755
--- a/tools/test/scenarios/bin/find-flow.py
+++ b/tools/test/scenarios/bin/find-flow.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
@@ -6,7 +6,7 @@
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 4:
- print "usage: find-flow onos-node name device-id"
+ print("usage: find-flow onos-node name device-id")
sys.exit(1)
node = sys.argv[1]
@@ -17,7 +17,7 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if flowsRequest.status_code != 200:
- print flowsRequest.text
+ print(flowsRequest.text)
sys.exit(1)
flowsJson = flowsRequest.json()
@@ -28,9 +28,9 @@
if criterion["type"] == 'IN_PORT' and criterion["port"] > 0:
for instruction in flow["treatment"]["instructions"]:
if instruction["port"] > 0 and instruction["type"] == 'OUTPUT':
- print "@stc " + name + "FlowState=" + flow["state"]
- print "@stc " + name + "FlowId=" + flow["id"]
- print "@stc " + name + "FlowPort=" + str(instruction["port"])
+ print("@stc " + name + "FlowState=" + flow["state"])
+ print("@stc " + name + "FlowId=" + flow["id"])
+ print("@stc " + name + "FlowPort=" + str(instruction["port"]))
sys.exit(0)
sys.exit(1)
diff --git a/tools/test/scenarios/bin/find-host.py b/tools/test/scenarios/bin/find-host.py
index e87a409..4c3aea5 100755
--- a/tools/test/scenarios/bin/find-host.py
+++ b/tools/test/scenarios/bin/find-host.py
@@ -1,13 +1,12 @@
-#! /usr/bin/env python
-
+#! /usr/bin/env python3
import requests
import sys
-import urllib
+import urllib.request, urllib.parse, urllib.error
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 4:
- print "usage: find-host onos-node name device-id"
+ print("usage: find-host onos-node name device-id")
sys.exit(1)
node = sys.argv[1]
@@ -15,18 +14,18 @@
id = sys.argv[3]
hostRequest = requests.get('http://' + node + ':8181/onos/v1/hosts/' +
- urllib.quote_plus(id),
+ urllib.parse.quote_plus(id),
auth=HTTPBasicAuth('onos', 'rocks'))
if hostRequest.status_code != 200:
- print hostRequest.text
+ print(hostRequest.text)
sys.exit(1)
hostJson = hostRequest.json()
-print "@stc " + name + "Id=" + hostJson["id"]
-print "@stc " + name + "Mac=" + hostJson["mac"]
-print "@stc " + name + "IpAddress=" + hostJson["ipAddresses"][0]
+print("@stc " + name + "Id=" + hostJson["id"])
+print("@stc " + name + "Mac=" + hostJson["mac"])
+print("@stc " + name + "IpAddress=" + hostJson["ipAddresses"][0])
sys.exit(0)
diff --git a/tools/test/scenarios/bin/find-link-in-cluster.py b/tools/test/scenarios/bin/find-link-in-cluster.py
index 928531f..1eb6832 100755
--- a/tools/test/scenarios/bin/find-link-in-cluster.py
+++ b/tools/test/scenarios/bin/find-link-in-cluster.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
@@ -6,7 +6,7 @@
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 9:
- print "usage: find-link-in-cluster onos-node name cluster-id expected-length src-device-id src-port dst-device-id dst-port"
+ print("usage: find-link-in-cluster onos-node name cluster-id expected-length src-device-id src-port dst-device-id dst-port")
sys.exit(1)
node = sys.argv[1]
@@ -24,29 +24,29 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if linksRequest.status_code != 200:
- print linksRequest.text
+ print(linksRequest.text)
sys.exit(1)
linksJson = linksRequest.json()
linksLength = len(linksJson["links"])
if linksLength != length:
- print "Expected length {} but got {}".format(length, linksLength)
+ print("Expected length {} but got {}".format(length, linksLength))
sys.exit(1)
for link in linksJson["links"]:
if srcDeviceId == link["src"]["device"] and srcPort == link["src"]["port"]:
if dstDeviceId == link["dst"]["device"] and dstPort == link["dst"]["port"]:
- print "@stc " + name + "SrcDevice=" + link["src"]["device"]
- print "@stc " + name + "SrcPort=" + link["src"]["port"]
- print "@stc " + name + "DstDevice=" + link["dst"]["device"]
- print "@stc " + name + "DstPort=" + link["dst"]["port"]
- print "@stc " + name + "Type=" + link["type"]
- print "@stc " + name + "State=" + link["state"]
+ print("@stc " + name + "SrcDevice=" + link["src"]["device"])
+ print("@stc " + name + "SrcPort=" + link["src"]["port"])
+ print("@stc " + name + "DstDevice=" + link["dst"]["device"])
+ print("@stc " + name + "DstPort=" + link["dst"]["port"])
+ print("@stc " + name + "Type=" + link["type"])
+ print("@stc " + name + "State=" + link["state"])
sys.exit(0)
-print "Could not find link from {}:{} to {}:{}"\
- .format(srcDeviceId, srcPort, dstDeviceId, dstPort)
+print("Could not find link from {}:{} to {}:{}"\
+ .format(srcDeviceId, srcPort, dstDeviceId, dstPort))
sys.exit(1)
diff --git a/tools/test/scenarios/bin/find-link.py b/tools/test/scenarios/bin/find-link.py
index 9ac6e35..6e83de7 100755
--- a/tools/test/scenarios/bin/find-link.py
+++ b/tools/test/scenarios/bin/find-link.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
@@ -6,7 +6,7 @@
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 7:
- print "usage: find-link onos-node name src-device-id src-port dst-device-id dst-port"
+ print("usage: find-link onos-node name src-device-id src-port dst-device-id dst-port")
sys.exit(1)
node = sys.argv[1]
@@ -22,7 +22,7 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if linksRequest.status_code != 200:
- print linksRequest.text
+ print(linksRequest.text)
sys.exit(1)
linksJson = linksRequest.json()
@@ -30,12 +30,12 @@
for link in linksJson["links"]:
if srcDeviceId == link["src"]["device"]:
if dstDeviceId == link["dst"]["device"]:
- print "@stc " + name + "SrcDevice=" + link["src"]["device"]
- print "@stc " + name + "SrcPort=" + link["src"]["port"]
- print "@stc " + name + "DstDevice=" + link["dst"]["device"]
- print "@stc " + name + "DstPort=" + link["dst"]["port"]
- print "@stc " + name + "Type=" + link["type"]
- print "@stc " + name + "State=" + link["state"]
+ print("@stc " + name + "SrcDevice=" + link["src"]["device"])
+ print("@stc " + name + "SrcPort=" + link["src"]["port"])
+ print("@stc " + name + "DstDevice=" + link["dst"]["device"])
+ print("@stc " + name + "DstPort=" + link["dst"]["port"])
+ print("@stc " + name + "Type=" + link["type"])
+ print("@stc " + name + "State=" + link["state"])
sys.exit(0)
sys.exit(1)
diff --git a/tools/test/scenarios/bin/find-topo-infrastructure.py b/tools/test/scenarios/bin/find-topo-infrastructure.py
index 6d1970f..de6a271 100755
--- a/tools/test/scenarios/bin/find-topo-infrastructure.py
+++ b/tools/test/scenarios/bin/find-topo-infrastructure.py
@@ -1,13 +1,13 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
-import urllib
+import urllib.request, urllib.parse, urllib.error
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 4:
- print "usage: find-topo-infrastructure onos-node name connect-point"
+ print("usage: find-topo-infrastructure onos-node name connect-point")
sys.exit(1)
node = sys.argv[1]
@@ -15,16 +15,16 @@
id = sys.argv[3]
infrastructureRequest = requests.get('http://' + node + ':8181/onos/v1/topology/infrastructure/' +
- urllib.quote_plus(id),
+ urllib.parse.quote_plus(id),
auth=HTTPBasicAuth('onos', 'rocks'))
if infrastructureRequest.status_code != 200:
- print infrastructureRequest.text
+ print(infrastructureRequest.text)
sys.exit(1)
infrastructureJson = infrastructureRequest.json()
-print "@stc " + name + "Infrastructure=" + str(infrastructureJson["infrastructure"])
+print("@stc " + name + "Infrastructure=" + str(infrastructureJson["infrastructure"]))
sys.exit(0)
diff --git a/tools/test/scenarios/bin/mininet-p4-trellis b/tools/test/scenarios/bin/mininet-p4-trellis
index db19cc4..e964d0f 100755
--- a/tools/test/scenarios/bin/mininet-p4-trellis
+++ b/tools/test/scenarios/bin/mininet-p4-trellis
@@ -19,7 +19,7 @@
echo \"cd ~/routing/trellis && \
sudo -E env PYTHONPATH=/tmp/bmv2_py STRATUM_ROOT=${stratumRoot} \
ONOS_WEB_USER=$ONOS_WEB_USER ONOS_WEB_PASS=$ONOS_WEB_PASS \
- python trellisp4.py --onos-ip $OC1 --agent stratum\" \
+ python3 trellisp4.py --onos-ip $OC1 --agent stratum\" \
> ${trellisp4Sh} && chmod +x ${trellisp4Sh}
"
diff --git a/tools/test/scenarios/bin/onos-change-device-portstate b/tools/test/scenarios/bin/onos-change-device-portstate
index bc69d98..2dfbc9a 100755
--- a/tools/test/scenarios/bin/onos-change-device-portstate
+++ b/tools/test/scenarios/bin/onos-change-device-portstate
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
@@ -8,7 +8,7 @@
if len(sys.argv) != 5:
- print "usage: change-device-portstate onos-node device-id port new_enabled_state"
+ print("usage: change-device-portstate onos-node device-id port new_enabled_state")
sys.exit(1)
node = sys.argv[1]
@@ -23,7 +23,7 @@
data=payload)
if change_request.status_code != 200:
- print change_request.text
+ print(change_request.text)
sys.exit(1)
sys.exit(0)
diff --git a/tools/test/scenarios/bin/onos-find-and-check-map b/tools/test/scenarios/bin/onos-find-and-check-map
index b419ca1..46daf8c 100755
--- a/tools/test/scenarios/bin/onos-find-and-check-map
+++ b/tools/test/scenarios/bin/onos-find-and-check-map
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# Invokes the ONOS CLI and looks for a 'maps' entry with the given name
@@ -9,7 +9,7 @@
import sys
if len(sys.argv) != 4:
- print "usage: onos-find-and-check-map onos-node map-name should-be-zero"
+ print("usage: onos-find-and-check-map onos-node map-name should-be-zero")
sys.exit(1)
node = sys.argv[1]
@@ -23,8 +23,8 @@
foundMapName = map["name"]
foundMapSize = map["size"]
- print foundMapName
- print foundMapSize
+ print(foundMapName)
+ print(foundMapSize)
if foundMapName == mapName:
if (shouldBeZero == 'yes' and foundMapSize == 0) or \
diff --git a/tools/test/scenarios/bin/post-netcfg.py b/tools/test/scenarios/bin/post-netcfg.py
index 6104f2c..6c3dcbc 100755
--- a/tools/test/scenarios/bin/post-netcfg.py
+++ b/tools/test/scenarios/bin/post-netcfg.py
@@ -1,12 +1,11 @@
-#! /usr/bin/env python
-
+#! /usr/bin/env python3
import requests
from requests.auth import HTTPBasicAuth
import sys
if len(sys.argv) != 3:
- print "usage: post-netcfg onos-node json-file-name"
+ print("usage: post-netcfg onos-node json-file-name")
sys.exit(1)
node = sys.argv[1]
@@ -20,7 +19,7 @@
data=configJson)
if request.status_code != 200:
- print request.text
+ print(request.text)
sys.exit(1)
sys.exit(0)
diff --git a/tools/test/scenarios/bin/query-cluster.py b/tools/test/scenarios/bin/query-cluster.py
index 0cac7ac..8d356b3 100755
--- a/tools/test/scenarios/bin/query-cluster.py
+++ b/tools/test/scenarios/bin/query-cluster.py
@@ -1,13 +1,13 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
-import urllib
+import urllib.request, urllib.parse, urllib.error
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 4:
- print "usage: query-cluster onos-node name cluster-number"
+ print("usage: query-cluster onos-node name cluster-number")
sys.exit(1)
node = sys.argv[1]
@@ -19,15 +19,15 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if topoRequest.status_code != 200:
- print topoRequest.text
+ print(topoRequest.text)
sys.exit(1)
topoJson = topoRequest.json()
-print "@stc " + name + "Id=" + str(topoJson["id"])
-print "@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"])
-print "@stc " + name + "LinkCount=" + str(topoJson["linkCount"])
-print "@stc " + name + "Root=" + topoJson["root"]
+print("@stc " + name + "Id=" + str(topoJson["id"]))
+print("@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"]))
+print("@stc " + name + "LinkCount=" + str(topoJson["linkCount"]))
+print("@stc " + name + "Root=" + topoJson["root"])
sys.exit(0)
diff --git a/tools/test/scenarios/bin/query-topo.py b/tools/test/scenarios/bin/query-topo.py
index 9b81b4e..9ce89b0 100755
--- a/tools/test/scenarios/bin/query-topo.py
+++ b/tools/test/scenarios/bin/query-topo.py
@@ -1,13 +1,13 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
-import urllib
+import urllib.request, urllib.parse, urllib.error
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 3:
- print "usage: query-topo onos-node name"
+ print("usage: query-topo onos-node name")
sys.exit(1)
node = sys.argv[1]
@@ -17,15 +17,15 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if topoRequest.status_code != 200:
- print topoRequest.text
+ print(topoRequest.text)
sys.exit(1)
topoJson = topoRequest.json()
-print "@stc " + name + "Time=" + str(topoJson["time"])
-print "@stc " + name + "Devices=" + str(topoJson["devices"])
-print "@stc " + name + "Links=" + str(topoJson["links"])
-print "@stc " + name + "Clusters=" + str(topoJson["clusters"])
+print("@stc " + name + "Time=" + str(topoJson["time"]))
+print("@stc " + name + "Devices=" + str(topoJson["devices"]))
+print("@stc " + name + "Links=" + str(topoJson["links"]))
+print("@stc " + name + "Clusters=" + str(topoJson["clusters"]))
sys.exit(0)
diff --git a/tools/test/scenarios/bin/tapiHelper.py b/tools/test/scenarios/bin/tapiHelper.py
index 47fdd65..2f227ef 100755
--- a/tools/test/scenarios/bin/tapiHelper.py
+++ b/tools/test/scenarios/bin/tapiHelper.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
import requests
import json
@@ -143,7 +143,7 @@
if service["end-point"][id]["service-interface-point"]["service-interface-point-uuid"] == sip_uuid:
return True
except KeyError:
- print "There is no line-side service in ONOS now."
+ print("There is no line-side service in ONOS now.")
return False
@@ -239,7 +239,7 @@
used_sip_uuids.add(service["end-point"][0]["service-interface-point"]["service-interface-point-uuid"])
used_sip_uuids.add(service["end-point"][1]["service-interface-point"]["service-interface-point-uuid"])
except KeyError:
- print "There is no existed connectivity service inside ONOS."
+ print("There is no existed connectivity service inside ONOS.")
# select the first available line-side service as bridge. If there is no available line-side service,
# then only create a client-to-client service for src and dst node.
@@ -256,8 +256,8 @@
if (client_src_sip_uuid not in used_sip_uuids) and (client_dst_sip_uuid not in used_sip_uuids):
# If there is no such client-side connection exists
# Create new client-side connection directly
- print "Create client-side connection between %s and %s." % \
- (client_src_name["onos-cp"], client_dst_name["onos-cp"])
+ print("Create client-side connection between %s and %s." % \
+ (client_src_name["onos-cp"], client_dst_name["onos-cp"]))
create_input_json = json.dumps(tapi_client_input((client_src_sip_uuid, client_dst_sip_uuid)))
resp = requests.post(url_connectivity, data=create_input_json, headers=headers,
auth=('onos', 'rocks'))
@@ -286,10 +286,10 @@
# None case means all client-side services exist.
raise AssertionError("There is no available client-side service could be created.")
else:
- print "Create client-side services:"
- print "\t- from %s to %s." % (empty_client_src_name["onos-cp"], empty_client_dst_name["onos-cp"])
- print "This service should go through:"
- print "\t- %s and %s." % (empty_src_name["onos-cp"], empty_dst_name["onos-cp"])
+ print("Create client-side services:")
+ print("\t- from %s to %s." % (empty_client_src_name["onos-cp"], empty_client_dst_name["onos-cp"]))
+ print("This service should go through:")
+ print("\t- %s and %s." % (empty_src_name["onos-cp"], empty_dst_name["onos-cp"]))
create_input_json = json.dumps(tapi_client_input((empty_client_src_sip_uuid, empty_client_dst_sip_uuid)))
resp = requests.post(url_connectivity, data=create_input_json, headers=headers,
auth=('onos', 'rocks'))
@@ -344,16 +344,16 @@
# select randomly the src_sip_uuid and dst_sip_uuid with same connection id.
src_onep, dst_onep, src_sip_uuid, dst_sip_uuid = parse_src_dst(topo)
while is_port_used(src_sip_uuid, context["tapi-common:context"]["tapi-connectivity:connectivity-context"]):
- print "Conflict occurs between randomly selected line-side link and existed ones."
+ print("Conflict occurs between randomly selected line-side link and existed ones.")
src_onep, dst_onep, src_sip_uuid, dst_sip_uuid = parse_src_dst(topo)
- print "\nBuild line-side connectivity:\n|Item|SRC|DST|\n|:--|:--|:--|\n|onos-cp|%s|%s|\n|connection id|%s|%s|\n|sip uuid|%s|%s|" % \
+ print("\nBuild line-side connectivity:\n|Item|SRC|DST|\n|:--|:--|:--|\n|onos-cp|%s|%s|\n|connection id|%s|%s|\n|sip uuid|%s|%s|" % \
(src_onep["name"][2]["value"], dst_onep["name"][2]["value"],
src_onep["name"][1]["value"], dst_onep["name"][1]["value"],
- src_sip_uuid, dst_sip_uuid)
+ src_sip_uuid, dst_sip_uuid))
create_input_json = json.dumps(tapi_line_input((src_sip_uuid, dst_sip_uuid)))
- print "\nThe json content of creation operation for line-side connectivity service is \n\t\t%s." % \
- create_input_json
+ print("\nThe json content of creation operation for line-side connectivity service is \n\t\t%s." % \
+ create_input_json)
headers = {'Content-type': 'application/json'}
resp = requests.post(url_connectivity, data=create_input_json, headers=headers, auth=('onos', 'rocks'))
if resp.status_code != 200:
diff --git a/tools/test/scenarios/bin/verify-topo-devices.py b/tools/test/scenarios/bin/verify-topo-devices.py
index be834b9..fb7f929 100755
--- a/tools/test/scenarios/bin/verify-topo-devices.py
+++ b/tools/test/scenarios/bin/verify-topo-devices.py
@@ -1,13 +1,13 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import requests
import sys
-import urllib
+import urllib.request, urllib.parse, urllib.error
from requests.auth import HTTPBasicAuth
if len(sys.argv) != 5:
- print "usage: verify-topo-links onos-node cluster-id first-index last-index"
+ print("usage: verify-topo-links onos-node cluster-id first-index last-index")
sys.exit(1)
node = sys.argv[1]
@@ -23,26 +23,26 @@
auth=HTTPBasicAuth('onos', 'rocks'))
if topoRequest.status_code != 200:
- print topoRequest.text
+ print(topoRequest.text)
sys.exit(1)
topoJson = topoRequest.json()
for deviceIndex in range(first, last+1):
lookingFor = "of:" + format(deviceIndex, '016x')
- print lookingFor
+ print(lookingFor)
for arrayIndex in range(0, len(topoJson["devices"])):
device = topoJson["devices"][arrayIndex]
if device == lookingFor:
found = found + 1
- print "Match found for " + device
+ print("Match found for " + device)
break
if found == last - first:
sys.exit(0)
-print "Found " + str(found) + " matches, need " + str(last - first)
+print("Found " + str(found) + " matches, need " + str(last - first))
sys.exit(2)
diff --git a/tools/test/scenarios/net-odtn-restconf.xml b/tools/test/scenarios/net-odtn-restconf.xml
index cbfba36..549c9b8 100644
--- a/tools/test/scenarios/net-odtn-restconf.xml
+++ b/tools/test/scenarios/net-odtn-restconf.xml
@@ -23,7 +23,7 @@
<!-- Push the line-side connectivity service request -->
<group name="Net-ODTN-Restconf.Line-side-test" requires="Net-ODTN-Restconf.Confirm-conn-empty">
<step name="Net-ODTN-Restconf.Create-line-side" exec="${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py ${OC1} tapi-connectivity:create-connectivity-service line-side"/>
- <step name="Net-ODTN-Restconf.Check-line-side" requires="Net-ODTN-Restconf.Create-line-side" exec="${ONOS_SCENARIOS}/odtn/checkUntilSucc.sh 'python ${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py+${OC1}+tapi-connectivity:get-connectivity-service-list+empty+|+grep+'tapi-connectivity:output'+|+grep+connection-uuid+-o+|+wc+-l' 1" />
+ <step name="Net-ODTN-Restconf.Check-line-side" requires="Net-ODTN-Restconf.Create-line-side" exec="${ONOS_SCENARIOS}/odtn/checkUntilSucc.sh 'python3 ${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py+${OC1}+tapi-connectivity:get-connectivity-service-list+empty+|+grep+'tapi-connectivity:output'+|+grep+connection-uuid+-o+|+wc+-l' 1" />
<step name="Net-ODTN-Restconf.Delete-line-conn" requires="Net-ODTN-Restconf.Check-line-side" exec="${ONOS_SCENARIOS}/bin/execute-tapi-delete-call.py ${OC1} line"/>
<step name="Net-ODTN-Restconf.Confirm-conn-empty-2" requires="Net-ODTN-Restconf.Delete-line-conn" exec="${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py ${OC1} tapi-connectivity:get-connectivity-service-list empty"/>
<group name="Net-ODTN-Restconf.Verify-Logs" requires="Net-ODTN-Restconf.Confirm-conn-empty-2">
@@ -35,7 +35,7 @@
<!-- Push the client-side connectivity service request -->
<group name="Net-ODTN-Restconf.Client-side-test" requires="Net-ODTN-Restconf.Line-side-test" delay="10" >
<step name="Net-ODTN-Restconf.Create-client-side" exec="${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py ${OC1} tapi-connectivity:create-connectivity-service client-side"/>
- <step name="Net-ODTN-Restconf.Check-client-side" requires="Net-ODTN-Restconf.Create-client-side" exec="${ONOS_SCENARIOS}/odtn/checkUntilSucc.sh 'python ${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py+${OC1}+tapi-connectivity:get-connectivity-service-list+empty+|+grep+'tapi-connectivity:output'+|+grep+connection-uuid+-o+|+wc+-l' 1" />
+ <step name="Net-ODTN-Restconf.Check-client-side" requires="Net-ODTN-Restconf.Create-client-side" exec="${ONOS_SCENARIOS}/odtn/checkUntilSucc.sh 'python3 ${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py+${OC1}+tapi-connectivity:get-connectivity-service-list+empty+|+grep+'tapi-connectivity:output'+|+grep+connection-uuid+-o+|+wc+-l' 1" />
<step name="Net-ODTN-Restconf.Delete-client-conn" requires="Net-ODTN-Restconf.Check-client-side" exec="${ONOS_SCENARIOS}/bin/execute-tapi-delete-call.py ${OC1} both"/>
<step name="Net-ODTN-Restconf.Confirm-conn-empty-3" requires="Net-ODTN-Restconf.Delete-client-conn" exec="${ONOS_SCENARIOS}/bin/execute-tapi-post-call.py ${OC1} tapi-connectivity:get-connectivity-service-list empty"/>
<group name="Net-ODTN-Restconf.Verify-Logs-2" requires="Net-ODTN-Restconf.Confirm-conn-empty-3">