Added 'get_reroute_times.py' change
diff --git a/TestON/drivers/common/api/onosrestapidriver.py_bak b/TestON/drivers/common/api/onosrestapidriver.py_bak
new file mode 100644
index 0000000..6194d1f
--- /dev/null
+++ b/TestON/drivers/common/api/onosrestapidriver.py_bak
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+'''
+Created on 4-Jun-2013
+
+@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+
+
+ TestON is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ TestON is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+onosrestapidriver is the basic driver which will handle the onorestapi functions
+'''
+
+import struct
+import fcntl
+import os
+import signal
+import re
+import sys
+import time
+import json
+
+sys.path.append("../")
+from drivers.common.apidriver import API
+import urllib
+import __builtin__
+
+
+class OnosRestApiDriver(API):
+
+ def __init__(self):
+ super(API, self).__init__()
+
+
+ def connect(self,**connectargs):
+ for key in connectargs:
+ vars(self)[key] = connectargs[key]
+
+ self.name = self.options['name']
+ self.handle = super(OnosRestApiDriver,self).connect()
+ main.log.info(self.options['topology_url'])
+ try :
+ self.handle = urllib.urlopen(self.options['topology_url'])
+ except Exception,e:
+ main.log.error(e)
+
+ self.logFileName = main.logdir+"/"+self.name+".session"
+
+ if self.handle:
+ return self.handle
+ else :
+ return main.FALSE
+
+ def execute(self):
+ main.log.info(self.options['topology_url'])
+ response = main.FALSE
+ for i in [1,2] :
+ time.sleep(2)
+ response = self.http_request()
+ return response
+
+ def http_request(self):
+ try :
+ self.handle = urllib.urlopen(self.options['topology_url'])
+
+ resonse_lines = self.handle.readlines()
+ print resonse_lines
+ return resonse_lines
+ except Exception,e:
+ main.log.error(e)
+ return "url error"
+
+ def disconnect(self,handle):
+ response = ''
+ '''
+ if self.handle:
+ self.handle = handle
+ response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
+ else :
+ main.log.error("Connection failed to the host")
+ response = main.FALSE
+ '''
+ return response
+
+ def find_host(self,RestIP,RestPort,RestAPI,hostMAC):
+ retcode = 0
+ ##### device rest API is: 'host:8080/wm/core/topology/switches/all/json' ###
+ url ="http://%s:%s%s" %(RestIP,RestPort,RestAPI)
+
+ try:
+ command = "curl -s %s" % (url)
+ result = os.popen(command).read()
+ parsedResult = json.loads(result)
+ print parsedResult
+ except:
+ print "REST IF %s has issue" % command
+ parsedResult = ""
+ if type(parsedResult) == 'dict' and parsedResult.has_key('code'):
+ print "REST %s returned code %s" % (command, parsedResult['code'])
+ parsedResult = ""
+
+ if parsedResult == "":
+ return (retcode, "Rest API has an error")
+ else:
+ found = [item for item in parsedResult if item['mac'] == [str(hostMAC)]]
+ retcode = 1
+ return (retcode, found)
+
diff --git a/TestON/drivers/common/cli/ramcloudclidriver.py.wip b/TestON/drivers/common/cli/ramcloudclidriver.py.wip
new file mode 100644
index 0000000..6a961ee
--- /dev/null
+++ b/TestON/drivers/common/cli/ramcloudclidriver.py.wip
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+'''
+Created on 31-May-2013
+
+@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+
+
+ TestON is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ TestON is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+CassandraCliDriver is the basic driver which will handle the Cassandra functions
+'''
+
+import pexpect
+import struct
+import fcntl
+import os
+import signal
+import re
+import sys
+import core.teston
+import time
+
+sys.path.append("../")
+from drivers.common.clidriver import CLI
+
+class CassandraCliDriver(CLI):
+ '''
+ CassandraCliDriver is the basic driver which will handle the Cassandra's functions
+ '''
+ def __init__(self):
+ super(CLI, self).__init__()
+ self.handle = self
+ self.wrapped = sys.modules[__name__]
+
+ def connect(self, **connectargs):
+ # Here the main is the TestON instance after creating all the log handles.
+ self.port = None
+ for key in connectargs:
+ vars(self)[key] = connectargs[key]
+
+ self.name = self.options['name']
+ self.handle = super(CassandraCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
+
+ self.ssh_handle = self.handle
+ if self.handle :
+ #self.start()
+ return main.TRUE
+ else :
+ main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
+ main.log.error("Failed to connect to the Onos system")
+ return main.FALSE
+
+
+ def start(self):
+ '''
+ This Function will start the Cassandra
+ '''
+ main.log.info( "Starting Cassandra" )
+ self.handle.sendline("")
+ self.handle.expect("\$")
+ self.handle.sendline("~/ONOS/start-cassandra.sh start")
+ self.handle.expect("start-cassandra.sh start")
+ self.handle.expect("\$")
+ response = self.handle.before + self.handle.after
+ time.sleep(5)
+ if re.search("Starting\scassandra(.*)", response):
+ main.log.info("Cassandra Started ")
+ return main.TRUE
+ else:
+ main.log.error("Failed to start Cassandra"+ response)
+ return main.FALSE
+
+ def status(self):
+ '''
+ This Function will return the Status of the Cassandra
+ '''
+ time.sleep(5)
+ self.execute(cmd="\r",prompt="\$",timeout=10)
+ response = self.execute(cmd="~/ONOS/start-cassandra.sh status ",prompt="\d+\sinstance\sof\scassandra\srunning(.*)",timeout=10)
+
+
+ self.execute(cmd="\r",prompt="\$",timeout=10)
+ return response
+
+ if re.search("0\sinstance\sof\scassandra\srunning(.*)") :
+ main.log.info("Cassandra not running")
+ return main.TRUE
+ elif re.search("1\sinstance\sof\scassandra\srunning(.*)"):
+ main.log.warn("Cassandra Running")
+ return main.TRUE
+
+ def stop(self):
+ '''
+ This Function will stop the Cassandra if it is Running
+ '''
+ self.execute(cmd="\r",prompt="\$",timeout=10)
+ time.sleep(5)
+ response = self.execute(cmd="~/ONOS/start-cassandra.sh stop ",prompt="Killed\sexisting\sprosess(.*)",timeout=10)
+ self.execute(cmd="\r",prompt="\$",timeout=10)
+ if re.search("Killed\sexisting\sprosess(.*)",response):
+ main.log.info("Cassandra Stopped")
+ return main.TRUE
+ else:
+ main.log.warn("Cassndra is not Running")
+ return main.FALSE
+
+ def disconnect(self):
+ '''
+ Called at the end of the test to disconnect the ssh handle.
+ '''
+ response = ''
+ if self.handle:
+ self.handle.sendline("exit")
+ self.handle.expect("closed")
+ else :
+ main.log.error("Connection failed to the host")
+ response = main.FALSE
+ return response
+
+ def isup(self):
+ '''
+ A more complete status check of cassandra.
+ Tries 5 times to call start-cassandra.sh status
+ returns TRUE if it sees four occurances of both Up, and Normal
+ '''
+ tries = 5
+ main.log.info("trying %i times" % tries )
+ for i in range(tries):
+ self.execute(cmd="\r",prompt="\$",timeout=10)
+ self.handle.sendline("")
+ self.handle.expect("\$")
+ self.handle.sendline("~/ONOS/start-cassandra.sh status")
+ self.handle.expect("sh status")
+ self.handle.expect("\$")
+ result = self.handle.before + self.handle.after
+ pattern = '(.*)Up(.*)Normal(.*)\n(.*)Up(.*)Normal(.*)\n(.*)Up(.*)Normal(.*)\n(.*)Up(.*)Normal(.*)'
+ if re.search(pattern, result):
+ return main.TRUE
+ return main.FALSE