Merge branch 'master' of github.com:OPENNETWORKINGLAB/ONLabTest
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index de5a6e7..3159dca 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -36,7 +36,7 @@
 
 class MininetCliDriver(Emulator):
     '''
-        MininetCliDriver is the basic driver which will handle the Mininet functions
+    MininetCliDriver is the basic driver which will handle the Mininet functions
     '''
     def __init__(self):
         super(Emulator, self).__init__()
@@ -45,8 +45,9 @@
         self.flag = 0
 
     def connect(self, **connectargs):
-        #,user_name, ip_address, pwd,options):
-        # Here the main is the TestON instance after creating all the log handles.
+        '''
+        Here the main is the TestON instance after creating all the log handles.
+        '''
         for key in connectargs:
             vars(self)[key] = connectargs[key]       
         
@@ -55,9 +56,7 @@
         
         self.ssh_handle = self.handle
         
-        # Copying the readme file to process the 
         if self.handle :
-            #self.handle.logfile = sys.stdout
             main.log.info("Clearing any residual state or processes")
             self.handle.sendline("sudo mn -c")
 
@@ -114,7 +113,7 @@
                        
     def pingall(self):
         '''
-           Verifies the reachability of the hosts using pingall command.
+        Verifies the reachability of the hosts using pingall command.
         '''
         if self.handle :
             main.log.info("Checking reachabilty to the hosts using pingall")
@@ -167,7 +166,7 @@
     
     def checkIP(self,host):
         '''
-            Verifies the host's ip configured or not.
+        Verifies the host's ip configured or not.
         '''
         if self.handle :
             response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
@@ -197,20 +196,21 @@
     
     def getMacAddress(self,host):
         '''
-            Verifies the host's ip configured or not.
+        Verifies the host's ip configured or not.
         '''
         if self.handle :
             response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
 
-            pattern = "HWaddr\s(((\d|\w)+:)+(\d|\w))"
-            mac_address_search = re.search(pattern, response)
-            main.log.info("Mac-Address of Host "+host +" is "+mac_address_search.group(1))
-            return mac_address_search.group(1)
+            pattern = r'HWaddr\s([0-9A-F]{2}[:-]){5}([0-9A-F]{2})'
+            mac_address_search = re.search(pattern, response, re.I)
+            mac_address = mac_address_search.group().split(" ")[1]
+            main.log.info("Mac-Address of Host "+ host + " is " + mac_address)
+            return mac_address
         else :
             main.log.error("Connection failed to the host") 
     def getIPAddress(self,host):
         '''
-            Verifies the host's ip configured or not.
+        Verifies the host's ip configured or not.
         '''
         if self.handle :
             response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
@@ -224,33 +224,33 @@
         
     def dump(self):
         main.log.info("Dump node info")
-        self.execute(cmd = 'dump',prompt = 'mininet>',timeout = 10)
-        return main.TRUE
+        response = self.execute(cmd = 'dump',prompt = 'mininet>',timeout = 10)
+        return response
             
     def intfs(self):
         main.log.info("List interfaces")
-        self.execute(cmd = 'intfs',prompt = 'mininet>',timeout = 10)
-        return main.TRUE
+        response = self.execute(cmd = 'intfs',prompt = 'mininet>',timeout = 10)
+        return response
     
     def net(self):
         main.log.info("List network connections")
-        self.execute(cmd = 'net',prompt = 'mininet>',timeout = 10)
-        return main.TRUE
+        response = self.execute(cmd = 'net',prompt = 'mininet>',timeout = 10)
+        return response
     
     def iperf(self):
         main.log.info("Simple iperf TCP test between two (optionally specified) hosts")
-        self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
-        return main.TRUE
+        response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
+        return response
     
     def iperfudp(self):
         main.log.info("Simple iperf TCP test between two (optionally specified) hosts")
-        self.execute(cmd = 'iperfudp',prompt = 'mininet>',timeout = 10)
-        return main.TRUE
+        response = self.execute(cmd = 'iperfudp',prompt = 'mininet>',timeout = 10)
+        return response
     
     def nodes(self):
         main.log.info("List all nodes.")
-        self.execute(cmd = 'nodes',prompt = 'mininet>',timeout = 10)    
-        return main.TRUE
+        response = self.execute(cmd = 'nodes',prompt = 'mininet>',timeout = 10)    
+        return response
     
     def pingpair(self):
         main.log.infoe("Ping between first two hosts")
@@ -307,7 +307,7 @@
 
     def dpctl(self,**dpctlargs):
         '''
-         Run dpctl command on all switches.
+        Run dpctl command on all switches.
         '''
         main.log.info('Run dpctl command on all switches')
         args = utilities.parse_args(["CMD","ARGS"],**dpctlargs)
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index c9b7c08..a2ac701 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -34,9 +34,9 @@
         super(CLI, self).__init__()
         
     def connect(self,**connectargs):
-'''
-Creates ssh handle for ONOS.
-'''
+        '''
+        Creates ssh handle for ONOS.
+        '''
         try:
             for key in connectargs:
                vars(self)[key] = connectargs[key]
@@ -66,9 +66,9 @@
         
     def start(self):
         '''
-Starts ONOS on remote machine.
-Returns false if any errors were encountered.
-'''
+        Starts ONOS on remote machine.
+        Returns false if any errors were encountered.
+        '''
         try:
             self.handle.sendline("")
             self.handle.expect("\$")
@@ -98,8 +98,8 @@
  
     def start_rest(self):
         '''
-Starts the rest server on ONOS.
-'''
+        Starts the rest server on ONOS.
+        '''
         try:
             response = self.execute(cmd= self.home + "/start-rest.sh start",prompt="\$",timeout=10)
             if re.search("admin",response):
@@ -118,8 +118,8 @@
     
     def status(self):
         '''
-Called onos.sh core status and returns TRUE/FALSE accordingly
-'''
+        Called onos.sh core status and returns TRUE/FALSE accordingly
+        '''
         try:
             self.execute(cmd="\n",prompt="\$",timeout=10)
             response = self.execute(cmd= self.home + "/onos.sh core status ",prompt="\d+\sinstance\sof\sonos\srunning",timeout=10)
@@ -141,12 +141,12 @@
 
     def isup(self):
         '''
-A more complete check to see if ONOS is up and running properly.
-First, it checks if the process is up.
-Second, it reads the logs for "Exception: Connection refused"
-Third, it makes sure the logs are actually moving.
-returns TRUE/FALSE accordingly.
-'''
+        A more complete check to see if ONOS is up and running properly.
+        First, it checks if the process is up.
+        Second, it reads the logs for "Exception: Connection refused"
+        Third, it makes sure the logs are actually moving.
+        returns TRUE/FALSE accordingly.
+        '''
         try:
             self.execute(cmd="\n",prompt="\$",timeout=10)
             response = self.execute(cmd= self.home + "/onos.sh core status ",prompt="running",timeout=10)
@@ -187,8 +187,8 @@
         
     def rest_status(self):
         '''
-Checks if the rest server is running.
-'''
+        Checks if the rest server is running.
+        '''
         try:
             response = self.execute(cmd= self.home + "/start-rest.sh status ",prompt="running",timeout=10)
             if re.search("rest\sserver\sis\srunning",response):
@@ -210,8 +210,8 @@
 
     def stop(self):
         '''
-Runs ./onos.sh core stop to stop ONOS
-'''
+        Runs ./onos.sh core stop to stop ONOS
+        '''
         try:
             self.handle.sendline("")
             self.handle.expect("\$")
@@ -235,8 +235,8 @@
     
     def rest_stop(self):
         '''
-Runs ./start-rest.sh stop to stop ONOS rest server
-'''
+        Runs ./start-rest.sh stop to stop ONOS rest server
+        '''
         try:
             response = self.execute(cmd= self.home + "/start-rest.sh stop ",prompt="killing",timeout=10)
             self.execute(cmd="\n",prompt="\$",timeout=10)
@@ -256,8 +256,8 @@
 
     def disconnect(self):
         '''
-Called when Test is complete to disconnect the ONOS handle.
-'''
+        Called when Test is complete to disconnect the ONOS handle.
+        '''
         response = ''
         try:
             self.handle.sendline("exit")
@@ -269,8 +269,8 @@
  
     def get_version(self):
         '''
-Writes the COMMIT number to the report to be parsed by Jenkins data collecter.
-'''
+        Writes the COMMIT number to the report to be parsed by Jenkins data collecter.
+        '''
         try:
             self.handle.sendline("export TERM=xterm-256color")
             self.handle.expect("xterm-256color")
@@ -288,9 +288,9 @@
 
     def add_flow(self, testONip, user, password, flowDef):
         '''
-Copies the flowdef file from TestStation -> ONOS machine
-Then runs ./add_flow.py to add the flows to ONOS
-'''
+        Copies the flowdef file from TestStation -> ONOS machine
+        Then runs ./add_flow.py to add the flows to ONOS
+        '''
         try:
             main.log.info("Adding Flows...")
             self.handle.sendline("scp %s@%s:%s /tmp/flowtmp" %(user,testONip,flowDef))
@@ -330,8 +330,8 @@
 
     def delete_flow(self, *delParams):
         '''
-Deletes a specific flow, a range of flows, or all flows.
-'''
+        Deletes a specific flow, a range of flows, or all flows.
+        '''
         try:
             if len(delParams)==1:
                 if str(delParams[0])=="all":
@@ -366,11 +366,11 @@
 
     def check_flow(self):
         '''
-Calls the ./get_flow.py all and checks:
-- If each FlowPath has at least one FlowEntry
-- That there are no "NOT"s found
-returns TRUE/FALSE
-'''
+        Calls the ./get_flow.py all and checks:
+        - If each FlowPath has at least one FlowEntry
+        - That there are no "NOT"s found
+        returns TRUE/FALSE
+        '''
         try:
             flowEntryDetect = 1
             count = 0
@@ -411,33 +411,33 @@
             main.exit()
 
     def get_flow(self, *flowParams):
-         '''
-Returns verbose output of ./get_flow.py
-'''
-         try:
-             if len(flowParams)==1:
-                  if str(flowParams[0])=="all":
-                       self.execute(cmd="\n",prompt="\$",timeout=60)
-                       main.log.info(self.name + ": Getting all flow data...")
-                       data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh all",prompt="done",timeout=150)
-                       self.execute(cmd="\n",prompt="\$",timeout=60)
-                       return data
-                  else:
-                       main.log.info(self.name + ": Retrieving flow "+str(flowParams[0])+" data...")
-                       data = self.execute(cmd=self.home +"/scripts/TestON_get_flow.sh "+str(flowParams[0]),prompt="done",timeout=150)
-                       self.execute(cmd="\n",prompt="\$",timeout=60)
-                       return data
-             elif len(flowParams)==5:
-                  main.log.info(self.name + ": Retrieving flow installer data...")
-                  data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3])+" "+str(flowParams[4]),prompt="done",timeout=150)
-                  self.execute(cmd="\n",prompt="\$",timeout=60)
-                  return data
-             elif len(flowParams)==4:
-                  main.log.info(self.name + ": Retrieving flow endpoints...")
-                  data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3]),prompt="done",timeout=150)
-                  self.execute(cmd="\n",prompt="\$",timeout=60)
-                  return data
-         except:
+        '''
+        Returns verbose output of ./get_flow.py
+        '''
+        try:
+            if len(flowParams)==1:
+                if str(flowParams[0])=="all":
+                    self.execute(cmd="\n",prompt="\$",timeout=60)
+                    main.log.info(self.name + ": Getting all flow data...")
+                    data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh all",prompt="done",timeout=150)
+                    self.execute(cmd="\n",prompt="\$",timeout=60)
+                    return data
+                else:
+                    main.log.info(self.name + ": Retrieving flow "+str(flowParams[0])+" data...")
+                    data = self.execute(cmd=self.home +"/scripts/TestON_get_flow.sh "+str(flowParams[0]),prompt="done",timeout=150)
+                    self.execute(cmd="\n",prompt="\$",timeout=60)
+                    return data
+            elif len(flowParams)==5:
+                main.log.info(self.name + ": Retrieving flow installer data...")
+                data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3])+" "+str(flowParams[4]),prompt="done",timeout=150)
+                self.execute(cmd="\n",prompt="\$",timeout=60)
+                return data
+            elif len(flowParams)==4:
+                main.log.info(self.name + ": Retrieving flow endpoints...")
+                data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3]),prompt="done",timeout=150)
+                self.execute(cmd="\n",prompt="\$",timeout=60)
+                return data
+        except:
             main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
             main.log.error( traceback.print_exc() )
             main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
@@ -452,8 +452,8 @@
 
     def get_json(self, url):
         '''
-Helper functions used to parse the json output of a rest call
-'''
+        Helper functions used to parse the json output of a rest call
+        '''
         try:
             try:
                 command = "curl -s %s" % (url)
@@ -476,8 +476,8 @@
 
     def check_switch(self,RestIP,correct_nr_switch, RestPort ="8080" ):
         '''
-Used by check_status
-'''
+        Used by check_status
+        '''
         try:
             buf = ""
             retcode = 0
@@ -521,8 +521,8 @@
 
     def check_link(self,RestIP, nr_links, RestPort = "8080"):
         '''
-Used by check_status
-'''
+        Used by check_status
+        '''
         try:
             buf = ""
             retcode = 0
@@ -555,9 +555,9 @@
 
     def check_status_report(self, ip, numoswitch, numolink, port="8080"):
         '''
-Checks the number of swithes & links that ONOS sees against the supplied values.
-Writes to the report log.
-'''
+        Checks the number of swithes & links that ONOS sees against the supplied values.
+        Writes to the report log.
+        '''
         try:
             main.log.info(self.name + ": Making some rest calls...")
             switch = self.check_switch(ip, int(numoswitch), port)
@@ -579,9 +579,9 @@
 
     def check_status(self, ip, numoswitch, numolink, port = "8080"):
         '''
-Checks the number of swithes & links that ONOS sees against the supplied values.
-Writes to the main log.
-'''
+        Checks the number of swithes & links that ONOS sees against the supplied values.
+        Writes to the main log.
+        '''
         try:
             main.log.info(self.name + ": Making some rest calls...")
             switch = self.check_switch(ip, int(numoswitch), port)
@@ -603,8 +603,8 @@
  
     def drop_keyspace(self):
         '''
-Drops the ONOS keyspace
-'''
+        Drops the ONOS keyspace
+        '''
         try:
             self.handle.sendline(self.home + "/scripts/drop-keyspace.sh")
             self.handle.expect("keyspace")
@@ -622,9 +622,9 @@
     
     def check_for_no_exceptions(self):
         '''
-TODO: Rewrite
-Used by CassndraCheck.py to scan ONOS logs for Exceptions
-'''
+        TODO: Rewrite
+        Used by CassndraCheck.py to scan ONOS logs for Exceptions
+        '''
         try:
             self.handle.sendline("dsh 'grep Exception ~/ONOS/onos-logs/onos.*.log'")
             self.handle.expect("\$ dsh")
@@ -645,9 +645,9 @@
 
     def git_pull(self):
         '''
-Stops the ONOS, pulls the latest code, and builds with mvn.
-Assumes that "git pull" works without login
-'''
+        Stops the ONOS, pulls the latest code, and builds with mvn.
+        Assumes that "git pull" works without login
+        '''
         try:
             main.log.info(self.name + ": Stopping ONOS")
             self.stop()
diff --git a/TestON/drivers/common/cli/ramcloudclidriver.py b/TestON/drivers/common/cli/ramcloudclidriver.py
index e651034..f900ddc 100644
--- a/TestON/drivers/common/cli/ramcloudclidriver.py
+++ b/TestON/drivers/common/cli/ramcloudclidriver.py
@@ -190,6 +190,7 @@
             return main.TRUE
         else:
             main.log.warn(self.name+": RAMCloud was not Running")
+            return main.FALSE
  
     def disconnect(self):
         ''' 
diff --git a/TestON/tests/OnosSanity4ARP/OnosSanity4ARP.py b/TestON/tests/OnosSanity4ARP/OnosSanity4ARP.py
index e9049c7..2163878 100644
--- a/TestON/tests/OnosSanity4ARP/OnosSanity4ARP.py
+++ b/TestON/tests/OnosSanity4ARP/OnosSanity4ARP.py
@@ -337,7 +337,6 @@
 
     def CASE21(self,main) :
         import json
-        from drivers.common.api.onosrestapidriver import *
         main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
         main.log.report("Check initially hostMAC/IP exist on the mininet...")
         host = main.params['YANK']['hostname']
@@ -349,8 +348,7 @@
         #print "host=" + host + ";  RestIP=" + RestIP1 + ";  RestPort=" + str(RestPort)
        
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        restcall = OnosRestApiDriver()
-        Reststatus, RestSwitch, RestPort = restcall.find_host(RestIP1,RestPort,url, hostip)
+        Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
         try:
             attachedSW = RestSwitch[0]['dpid']
             host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
@@ -377,8 +375,7 @@
 
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        restcall = OnosRestApiDriver()
-        Reststatus, RestSwitch, RestPort = restcall.find_host(RestIP1,RestPort,url, hostip)
+        Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
         try:
             attachedSW = RestSwitch[0]['dpid']
             host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
@@ -403,8 +400,7 @@
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
 
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        restcall = OnosRestApiDriver()
-        Reststatus, RestSwitch, RestPort = restcall.find_host(RestIP1,RestPort,url, hostip)
+        Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
         try:
             attachedSW = RestSwitch[0]['dpid']
             host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']
@@ -430,8 +426,7 @@
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
 
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        restcall = OnosRestApiDriver()
-        Reststatus, RestSwitch, RestPort = restcall.find_host(RestIP1,RestPort,url, hostip)
+        Reststatus, RestSwitch, RestPort = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
         try:
             attachedSW = RestSwitch[0]['dpid']
             host_ip = RestSwitch[0]['devices'][0]['ipv4addresses']