ONOS host formatting functions
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index f8ee9c2..03fc5ca 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -976,9 +976,30 @@
# main.log.error(str(json.dumps(onos, sort_keys=True,indent=4,separators=(',', ': '))))
return results
+ def get_hosts(self):
+ '''
+ Returns a list of all hosts
+ Don't ask questions just use it
+ '''
+ self.handle.sendline("")
+ self.handle.expect("mininet>")
+
+ self.handle.sendline("py [ host.name for host in net.hosts ]")
+ self.handle.expect("mininet>")
+ handle_py = self.handle.before
+ handle_py = handle_py.split("]\r\n",1)[1]
+ handle_py = handle_py.rstrip()
+ self.handle.sendline("")
+ self.handle.expect("mininet>")
+ host_str = handle_py.replace("]", "")
+ host_str = host_str.replace("'", "")
+ host_str = host_str.replace("[", "")
+ host_list = host_str.split(",")
+
+ return host_list
if __name__ != "__main__":
import sys
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index d023a99..8df4dce 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -521,6 +521,54 @@
main.log.info(self.name+" ::::::")
main.cleanup()
main.exit()
+
+ #TODO:
+ #def hosts(self):
+
+ def get_hosts_id(self, host_list):
+ '''
+ Obtain list of hosts
+ Issues command: 'onos> hosts'
+
+ Required:
+ * host_list: List of hosts obtained by Mininet
+ IMPORTANT:
+ This function assumes that you started your
+ topology with the option '--mac'.
+ Furthermore, it assumes that value of VLAN is '-1'
+ Description:
+ Converts mininet hosts (h1, h2, h3...) into
+ ONOS format (00:00:00:00:00:01/-1 , ...)
+ '''
+
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ onos_host_list = []
+
+ for host in host_list:
+ host = host.replace("h", "")
+ host_hex = hex(int(host)).zfill(12)
+ host_hex = str(host_hex).replace('x','0')
+ i = iter(str(host_hex))
+ host_hex = ":".join(a+b for a,b in zip(i,i))
+ host_hex = host_hex + "/-1"
+ onos_host_list.append(host_hex)
+
+ return onos_host_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()
#Wrapper functions ****************
#Wrapper functions use existing driver
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 00adf27..62aad08 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -385,7 +385,7 @@
main.exit()
def create_cell_file(self, bench_ip, file_name, mn_ip_addrs,
- extra_feature_string="onos-core-trivial", *onos_ip_addrs):
+ extra_feature_string, *onos_ip_addrs):
'''
Creates a cell file based on arguments
Required: