Added function paths. Returns path and cost of src / dst switches
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 2e085c7..77b92c4 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -400,7 +400,49 @@
main.cleanup()
main.exit()
- #Wrapper function for devices*******
+ def paths(self, src_id, dst_id):
+ '''
+ Returns string of paths, and the cost.
+ Issues command: onos:paths <src> <dst>
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ self.handle.sendline("onos:paths "+
+ str(src_id) + " " + str(dst_id))
+ i = self.handle.expect([
+ "Error",
+ "onos>"])
+
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ handle = self.handle.before
+
+ if i == 0:
+ main.log.error("Error in getting paths")
+ return handle
+ else:
+ path = handle.split(";")[0]
+ cost = handle.split(";")[1]
+ return (path, cost)
+
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
+
+
+
+ #Wrapper functions ****************
#Wrapper functions use existing driver
#functions and extends their use case.
#For example, we may use the output of
@@ -414,6 +456,11 @@
id's. Returns this list. Returns empty list if no
devices exist
List is ordered sequentially
+
+ This function may be useful if you are not sure of the
+ device id, and wish to execute other commands using
+ the ids. By obtaining the list of device ids on the fly,
+ you can iterate through the list to get mastership, etc.
'''
try:
#Call devices and store result string
diff --git a/TestON/tests/ONOSNextTest/ONOSNextTest.py b/TestON/tests/ONOSNextTest/ONOSNextTest.py
index fe63b81..cbf8afe 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.py
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.py
@@ -157,8 +157,8 @@
'''
Test the ONOS-cli functionality
- Below are demonstrations of what the driver functions can be
- used for.
+ Below are demonstrations of what the
+ ONOS cli driver functions can be used for.
'''
import time
@@ -202,7 +202,11 @@
devices_id_list = main.ONOScli.get_all_devices_id()
main.log.info(devices_id_list)
-
+ main.step("Get path and cost between device 1 and 7")
+ (path, cost) = main.ONOScli.paths(devices_id_list[0], devices_id_list[6])
+ main.log.info("Path: "+str(path))
+ main.log.info("Cost: "+str(cost))
+
######
#jhall@onlab.us
#andrew@onlab.us