Initial CHO Test commit
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 84c4b7f..ffafb06 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -508,7 +508,34 @@
main.cleanup()
main.exit()
- def links(self, json_format=True):
+
+ def balance_masters(self):
+ '''
+ This balances the devices across all controllers
+ by issuing command: 'onos> onos:balance-masters'
+ If required this could be extended to return devices balanced output.
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ self.handle.sendline("onos:balance-masters")
+ self.handle.expect("onos>")
+ return main.TRUE
+
+ 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()
+
+ def links(self, json_format=True, grep_str=""):
'''
Lists all core links
Optional argument:
@@ -906,7 +933,7 @@
handle = self.handle.before
#print "handle =", handle
- main.log.info("Intent installed between "+
+ main.log.info("Host intent installed between "+
str(host_id_one) + " and " + str(host_id_two))
return handle
@@ -1963,3 +1990,107 @@
main.exit()
#***********************************
+ def getDevicePortsEnabledCount(self,dpid):
+ '''
+ Get the count of all enabled ports on a particular device/switch
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ self.handle.sendline("onos:ports -e "+dpid+" | wc -l")
+ i = self.handle.expect([
+ "No such device",
+ "onos>"])
+
+ #self.handle.sendline("")
+ #self.handle.expect("onos>")
+
+ output = self.handle.before
+
+ if i == 0:
+ main.log.error("Error in getting ports")
+ return (ouput, "Error")
+ else:
+ result = output
+ return result
+
+ 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()
+
+ def getDeviceLinksActiveCount(self,dpid):
+ '''
+ Get the count of all enabled ports on a particular device/switch
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ self.handle.sendline("onos:links "+dpid+" | grep ACTIVE | wc -l")
+ i = self.handle.expect([
+ "No such device",
+ "onos>"])
+
+ output = self.handle.before
+
+ if i == 0:
+ main.log.error("Error in getting ports")
+ return (ouput, "Error")
+ else:
+ result = output
+ return result
+
+ 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()
+
+ def getAllIntentIds(self):
+ '''
+ Return a list of all Intent IDs
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ self.handle.sendline("onos:intents | grep id=")
+ i = self.handle.expect([
+ "Error",
+ "onos>"])
+
+ output = self.handle.before
+
+ if i == 0:
+ main.log.error("Error in getting ports")
+ return (ouput, "Error")
+ else:
+ result = output
+ return result
+
+ 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 678bae4..db88a57 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -270,7 +270,7 @@
return main.TRUE # So that only when git pull is done, we do mvn clean compile
elif i==3:
main.log.info(self.name + ": Git Pull - Already up to date")
- return i
+ return main.TRUE
elif i==4:
main.log.info(self.name + ": Git Pull - Aborting... Are there conflicting git files?")
return main.ERROR
@@ -1361,4 +1361,39 @@
main.log.error( traceback.print_exc())
main.log.info(self.name+" ::::::")
+ def onos_status(self, node=""):
+ '''
+ Calls onos command: 'onos-service [<node-ip>] status'
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("\$")
+ self.handle.sendline("onos-service "+str(node)+
+ " status")
+ i = self.handle.expect([
+ "start/running",
+ "stop/waiting",
+ pexpect.TIMEOUT],timeout=120)
+
+ if i == 0:
+ main.log.info("ONOS is running")
+ return main.TRUE
+ elif i == 1:
+ main.log.info("ONOS is stopped")
+ return main.FALSE
+ else:
+ main.log.error("ONOS service failed to check the status")
+ main.cleanup()
+ main.exit()
+ 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()