[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/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)