Add detialed_status to get the current status of the controller
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index db01cc2..ce478fb 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -27,6 +27,7 @@
import traceback
import urllib2
from urllib2 import URLError, HTTPError
+
sys.path.append("../")
from drivers.common.clidriver import CLI
@@ -198,7 +199,7 @@
main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
main.cleanup()
main.exit()
-
+
def status(self):
'''
Called onos.sh core status and returns TRUE/FALSE accordingly
@@ -286,7 +287,6 @@
main.exit()
-
def rest_status(self):
'''
Checks if the rest server is running.
@@ -674,6 +674,8 @@
if len(result) != 0:
parsed_result = json.loads(result)
print(parsed_result)
+ return parsed_result
+ return main.TRUE
except HTTPError as exc:
print "ERROR:"
print " REST DELETE URL: %s" % url
@@ -688,7 +690,7 @@
print "ERROR:"
print " REST DELETE URL: %s" % url
print " URL Error Reason: %s" % exc.reason
- return result
+ return main.ERROR
#*********************************************************************
#*********************************************************************
@@ -725,6 +727,8 @@
response.close()
if len(result) != 0:
parsed_result = json.loads(result)
+ return parsed_result
+ return main.TRUE
except HTTPError as exc:
print "ERROR:"
print " REST GET URL: %s" % url
@@ -741,9 +745,8 @@
print " REST GET URL: %s" % url
print " URL Error Reason: %s" % exc.reason
return " HTTP Error Reason: %s" % exc.reason
- return result
+ return main.ERROR
-
def add_intents(self):
@@ -1168,7 +1171,59 @@
main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
main.cleanup()
main.exit()
-
+
+ def detailed_status(self, log_filename):
+ '''
+ Reports RUNNING, STARTING, STOPPED, FROZEN, ERROR (and reason)
+ '''
+ try:
+ process_up = False
+ self.execute(cmd="\n", prompt="\$", timeout=10)
+ self.handle.sendline("cd " + self.home)
+ response = self.execute(cmd="./onos.sh core status ",prompt="\d+\sinstance\sof\sonos\srunning",timeout=10)
+ self.execute(cmd="\n",prompt="\$",timeout=10)
+ if re.search("1\sinstance\sof\sonos\srunning",response):
+ process_up = True
+ elif re.search("0\sinstance\sof\sonos\srunning",response):
+ process_up = False
+ return 'STOPPED'
+ elif re.search("Expected\sPrompt\snot found\s,\sTime Out!!",response):
+ return "ERROR", "Time out on ./onos.sh core status"
+ else :
+ main.log.warn(self.name + " WARNING: status recieved unknown response")
+ main.log.warn(response)
+ return 'Error', "Unknown response: %s" % response
+ '''
+ self.execute(cmd="\n",prompt="\$",timeout=10)
+ tail1 = self.execute(cmd="tail " + self.home + "%s" % log_filename, prompt="\$", timeout=10)
+ time.sleep(10)
+ self.execute(cmd="\n",prompt="\$",timeout=10)
+ tail2 = self.execute(cmd="tail " + self.home + "%s" % log_filename, prompt="\$", timeout=10)
+ '''
+
+ pattern = '(.*)1 instance(.*)'
+ pattern2 = '(.*)Exception: Connection refused(.*)'
+ # if utilities.assert_matches(expect=pattern,actual=response,onpass="ONOS process is running...",onfail="ONOS process not running..."):
+ running = self.execute(cmd="cat " + self.home + " %s | grep 'Sending LLDP out on all ports'" % log_filename,prompt="\$",timeout=10)
+ if re.search(pattern, response):
+ if running == '':
+ return 'STARTING',
+ else:
+ return 'RUNNING'
+ else:
+ main.log.error(self.name + ": ONOS process not running...")
+ return 'STOPPED'
+ 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(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+ main.cleanup()
+ main.exit()
def git_pull(self, comp1=""):
'''