aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/test/scenarios/bin
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-09-09 22:15:21 -0700
committerAshlee Young <ashlee@onosfw.com>2015-09-09 22:15:21 -0700
commit13d05bc8458758ee39cb829098241e89616717ee (patch)
tree22a4d1ce65f15952f07a3df5af4b462b4697cb3a /framework/src/onos/tools/test/scenarios/bin
parent6139282e1e93c2322076de4b91b1c85d0bc4a8b3 (diff)
ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60
Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd
Diffstat (limited to 'framework/src/onos/tools/test/scenarios/bin')
-rwxr-xr-xframework/src/onos/tools/test/scenarios/bin/create-flow.py56
-rwxr-xr-xframework/src/onos/tools/test/scenarios/bin/create-intent.py49
-rwxr-xr-xframework/src/onos/tools/test/scenarios/bin/find-device.py39
-rwxr-xr-xframework/src/onos/tools/test/scenarios/bin/find-flow.py40
-rwxr-xr-xframework/src/onos/tools/test/scenarios/bin/find-host.py36
-rwxr-xr-xframework/src/onos/tools/test/scenarios/bin/find-link.py45
6 files changed, 265 insertions, 0 deletions
diff --git a/framework/src/onos/tools/test/scenarios/bin/create-flow.py b/framework/src/onos/tools/test/scenarios/bin/create-flow.py
new file mode 100755
index 00000000..4e9b452b
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/bin/create-flow.py
@@ -0,0 +1,56 @@
+#! /usr/bin/env python
+
+import requests
+
+from requests.auth import HTTPBasicAuth
+import sys
+
+
+
+if len(sys.argv) != 6:
+ print "usage: create-flow onos-node name device in-port out-port"
+ sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+device = sys.argv[3]
+inPort = sys.argv[4]
+outPort = sys.argv[5]
+
+flowJsonTemplate = \
+ '{{' + \
+ '"priority": 1,' + \
+ '"isPermanent": true,' + \
+ '"treatment": {{' + \
+ '"instructions": [' + \
+ '{{' + \
+ '"type": "OUTPUT",' + \
+ '"port": {}' + \
+ '}}' + \
+ ']' + \
+ '}},' + \
+ '"selector": {{' + \
+ '"criteria": [' + \
+ '{{' + \
+ '"type": "IN_PORT",' + \
+ '"port": {}' + \
+ '}}' + \
+ ']' + \
+ '}}' + \
+ '}}'
+
+flowJson = flowJsonTemplate.format(inPort, outPort)
+intentRequest = requests.post('http://' + node + ':8181/onos/v1/flows/' + device,
+ auth=HTTPBasicAuth('onos', 'rocks'),
+ data=flowJson)
+
+if intentRequest.status_code != 201:
+ print intentRequest.text
+ sys.exit(1)
+
+location = intentRequest.headers["location"]
+print "@stc " + name + "Location=" + location
+sys.exit(0)
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/create-intent.py b/framework/src/onos/tools/test/scenarios/bin/create-intent.py
new file mode 100755
index 00000000..4e5d4f62
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/bin/create-intent.py
@@ -0,0 +1,49 @@
+#! /usr/bin/env python
+
+import requests
+
+from requests.auth import HTTPBasicAuth
+import sys
+
+
+
+if len(sys.argv) != 7:
+ print "usage: create-intent onos-node name ingressDevice ingressPort egressDevice egressPort"
+ sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+ingress = sys.argv[3]
+ingressPort = sys.argv[4]
+egress = sys.argv[5]
+egressPort = sys.argv[6]
+
+intentJsonTemplate = \
+ '{{' + \
+ '"type": "PointToPointIntent",' + \
+ '"appId": "org.onosproject.cli",' + \
+ '"ingressPoint": {{' + \
+ ' "device": "{}",' + \
+ ' "port": "{}"' + \
+ '}},' + \
+ '"egressPoint": {{' + \
+ ' "device": "{}",' + \
+ ' "port": "{}"' + \
+ '}}' + \
+ '}}'
+
+intentJson = intentJsonTemplate.format(ingress, ingressPort, egress, egressPort)
+intentRequest = requests.post('http://' + node + ':8181/onos/v1/intents/',
+ auth=HTTPBasicAuth('onos', 'rocks'),
+ data=intentJson)
+
+if intentRequest.status_code != 201:
+ print intentRequest.text
+ sys.exit(1)
+
+location = intentRequest.headers["location"]
+print "@stc " + name + "Location=" + location
+sys.exit(0)
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/find-device.py b/framework/src/onos/tools/test/scenarios/bin/find-device.py
new file mode 100755
index 00000000..430e18ad
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/bin/find-device.py
@@ -0,0 +1,39 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+import urllib
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 4:
+ print "usage: find-device onos-node name device-id"
+ sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+id = sys.argv[3]
+
+deviceRequest = requests.get('http://' + node + ':8181/onos/v1/devices/' +
+ urllib.quote_plus(id),
+ auth=HTTPBasicAuth('onos', 'rocks'))
+
+if deviceRequest.status_code != 200:
+ 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"])
+channelId = deviceJson["annotations"]["channelId"]
+channelIdWords = channelId.split(':')
+print "@stc " + name + "IpAddress=" + channelIdWords[0]
+
+sys.exit(0)
+
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/find-flow.py b/framework/src/onos/tools/test/scenarios/bin/find-flow.py
new file mode 100755
index 00000000..a2f2e4d1
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/bin/find-flow.py
@@ -0,0 +1,40 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 4:
+ print "usage: find-flow onos-node name device-id"
+ sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+deviceId = sys.argv[3]
+
+flowsRequest = requests.get('http://' + node + ':8181/onos/v1/flows/' + deviceId,
+ auth=HTTPBasicAuth('onos', 'rocks'))
+
+if flowsRequest.status_code != 200:
+ print flowsRequest.text
+ sys.exit(1)
+
+flowsJson = flowsRequest.json()
+
+for flow in flowsJson["flows"]:
+ if deviceId == flow["deviceId"]:
+ for criterion in flow["selector"]["criteria"]:
+ 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"])
+ sys.exit(0)
+
+sys.exit(1)
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/find-host.py b/framework/src/onos/tools/test/scenarios/bin/find-host.py
new file mode 100755
index 00000000..e87a4090
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/bin/find-host.py
@@ -0,0 +1,36 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+import urllib
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 4:
+ print "usage: find-host onos-node name device-id"
+ sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+id = sys.argv[3]
+
+hostRequest = requests.get('http://' + node + ':8181/onos/v1/hosts/' +
+ urllib.quote_plus(id),
+ auth=HTTPBasicAuth('onos', 'rocks'))
+
+if hostRequest.status_code != 200:
+ 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]
+
+sys.exit(0)
+
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/find-link.py b/framework/src/onos/tools/test/scenarios/bin/find-link.py
new file mode 100755
index 00000000..9ac6e358
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/bin/find-link.py
@@ -0,0 +1,45 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+
+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"
+ sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+srcDeviceId = sys.argv[3]
+srcPort = sys.argv[4]
+dstDeviceId = sys.argv[5]
+dstPort = sys.argv[6]
+
+
+linksRequest = requests.get('http://' + node + ':8181/onos/v1/links?device=' +
+ srcDeviceId + '&port=' + srcPort,
+ auth=HTTPBasicAuth('onos', 'rocks'))
+
+if linksRequest.status_code != 200:
+ print linksRequest.text
+ sys.exit(1)
+
+linksJson = linksRequest.json()
+
+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"]
+ sys.exit(0)
+
+sys.exit(1)
+
+
+
+