get_all_devices_id function added. Returns list of just the device id's in order
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 4f51743..2e085c7 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -400,4 +400,53 @@
main.cleanup()
main.exit()
+ #Wrapper function for devices*******
+ #Wrapper functions use existing driver
+ #functions and extends their use case.
+ #For example, we may use the output of
+ #a normal driver function, and parse it
+ #using a wrapper function
+ def get_all_devices_id(self):
+ '''
+ Use 'devices' function to obtain list of all devices
+ and parse the result to obtain a list of all device
+ id's. Returns this list. Returns empty list if no
+ devices exist
+ List is ordered sequentially
+ '''
+ try:
+ #Call devices and store result string
+ devices_str = self.devices()
+ id_list = []
+
+ if not devices_str:
+ main.log.info("There are no devices to get id from")
+ return id_list
+
+ #Split the string into list by comma
+ device_list = devices_str.split(",")
+ #Get temporary list of all arguments with string 'id='
+ temp_list = [dev for dev in device_list if "id=" in dev]
+ #Split list further into arguments before and after string
+ # 'id='. Get the latter portion (the actual device id) and
+ # append to id_list
+ for arg in temp_list:
+ id_list.append(arg.split("id=")[1])
+
+ return id_list
+
+ 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()
+
+
+ #***********************************
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 05597f5..ff13e5d 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -409,8 +409,10 @@
#Create the cell file in the directory for writing (w+)
cell_file = open(temp_directory+file_name , 'w+')
- #Feature string is pre-defined environment variable
- #that is required in the file
+ #Feature string is hardcoded environment variables
+ #That you may wish to use by default on startup.
+ #Note that you may not want certain features listed
+ #on here.
feature_string = "export ONOS_FEATURES=webconsole,onos-api,"+\
"onos-core-trivial,onos-cli,onos-openflow,"+\
"onos-app-fwd,onos-app-mobility,onos-app-tvue,"+\
@@ -423,7 +425,7 @@
temp_onos_ip = onos_ip_addrs[0]
temp_list = []
temp_list = temp_onos_ip.split(".")
- #Omit last element of list
+ #Omit last element of list to format for NIC
temp_list = temp_list[:-1]
#Structure the nic string ip
nic_addr = ".".join(temp_list) + ".*\n"
@@ -451,7 +453,7 @@
#on the same cluster as the ONOS bench
#Note that even if TestON is located on the same cluster
#as ONOS bench, you must setup passwordless ssh
- #in order to automate the test.
+ #between TestON and ONOS bench in order to automate the test.
os.system("scp "+temp_directory+file_name+
" admin@"+bench_ip+":"+cell_directory)
diff --git a/TestON/tests/ONOSNextTest/ONOSNextTest.py b/TestON/tests/ONOSNextTest/ONOSNextTest.py
index dd34863..fe63b81 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.py
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.py
@@ -156,6 +156,9 @@
def CASE5(self, main):
'''
Test the ONOS-cli functionality
+
+ Below are demonstrations of what the driver functions can be
+ used for.
'''
import time
@@ -185,14 +188,22 @@
main.step("Add a correct node")
node_result = main.ONOScli.add_node("111", "10.128.20.12")
- main.step("List devices")
+ main.step("Assign switches and list devices")
for i in range(1,8):
main.Mininet2.handle.sendline("sh ovs-vsctl set-controller s"+str(i)+
" tcp:10.128.20.11")
main.Mininet2.handle.expect("mininet>")
#Need to sleep to allow switch add processing
- time.sleep(10)
+ time.sleep(5)
list_result = main.ONOScli.devices()
main.log.info(list_result)
+ main.step("Get all devices id")
+ devices_id_list = main.ONOScli.get_all_devices_id()
+ main.log.info(devices_id_list)
+
+######
+#jhall@onlab.us
+#andrew@onlab.us
+######