Changes to drivers to fix isup with tracing, to add mininet tcpdumps, and adding onossanityclidriver
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 341b693..b3186b0 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -25,6 +25,8 @@
import re
import json
import traceback
+import urllib2
+from urllib2 import URLError, HTTPError
sys.path.append("../")
from drivers.common.clidriver import CLI
@@ -207,12 +209,11 @@
self.execute(cmd="\n",prompt="\$",timeout=10)
tail2 = self.execute(cmd="tail " + self.home + "/onos-logs/onos.*.log",prompt="\$",timeout=10)
pattern = '(.*)1 instance(.*)'
- patternUp = 'Sending LLDP out'
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+"/onos-logs/onos.*.log | grep 'Sending LLDP out on all ports'",prompt="\$",timeout=10)
if re.search(pattern, response):
- if re.search(patternUp,tail2):
+ if running != "":
main.log.info(self.name + ": ONOS process is running...")
if tail1 == tail2:
main.log.error(self.name + ": ONOS is frozen...")#logs aren't moving
@@ -428,33 +429,80 @@
main.cleanup()
main.exit()
- def ad_flow(self):
- main.log.info("AD_FLOW RUNNING!!!!")
+
+ def add_intent(self, intent_id,src_dpid,dst_dpid,src_mac,dst_mac,intentIP,intentPort=8080,intentURL="wm/onos/intent/high" , intent_type = 'SHORTEST_PATH', static_path=False, src_port=1,dst_port=1):
+ "CLI command callback: set intent"
+
+ intents = []
+ oper = {}
+ # Create the POST payload
+ oper['intentId'] = intent_id
+ oper['intentType'] = intent_type # XXX: Hardcoded
+ oper['staticPath'] = static_path # XXX: Hardcoded
+ oper['srcSwitchDpid'] = src_dpid
+ oper['srcSwitchPort'] = src_port
+ oper['dstSwitchDpid'] = dst_dpid
+ oper['dstSwitchPort'] = dst_port
+ oper['matchSrcMac'] = src_mac
+ oper['matchDstMac'] = dst_mac
+ intents.append(oper)
+ url = "http://%s:%s/%s"%(intentIP,intentPort,intentURL)
+ parsed_result = []
+ data_json = json.dumps(intents)
+ try:
+ request = urllib2.Request(url,data_json)
+ request.add_header("Content-Type", "application/json")
+ response=urllib2.urlopen(request)
+ result = response.read()
+ response.close()
+ if len(result) != 0:
+ parsed_result = json.loads(result)
+ except HTTPError as exc:
+ print "ERROR:"
+ print " REST GET URL: %s" % url
+ # NOTE: exc.fp contains the object with the response payload
+ error_payload = json.loads(exc.fp.read())
+ print " REST Error Code: %s" % (error_payload['code'])
+ print " REST Error Summary: %s" % (error_payload['summary'])
+ print " REST Error Description: %s" % (error_payload['formattedDescription'])
+ print " HTTP Error Code: %s" % exc.code
+ print " HTTP Error Reason: %s" % exc.reason
+ except URLError as exc:
+ print "ERROR:"
+ print " REST GET URL: %s" % url
+ print " URL Error Reason: %s" % exc.reason
+ return parsed_result
+
+
+
+
+ def add_intents(self):
+ main.log.info("Sending new intents to ONOS")
self.handle.sendline("cd "+self.home+ "/scripts")
self.handle.expect("scripts")
- main.log.info("Adding flows")
+ main.log.info("Adding intents")
self.handle.sendline("./pyintents.py")
self.handle.expect(["$",pexpect.EOF,pexpect.TIMEOUT])
response = self.handle.before
self.handle.sendline("cd "+self.home)
return main.TRUE
- def rm_flow(self):
- main.log.info("RM_FLOW RUNNING!!!")
+ def rm_intents(self):
+ main.log.info("Deleteing Intents from ONOS")
self.handle.sendline("cd "+self.home+ "/scripts")
self.handle.expect("scripts")
- main.log.info("Removing flows")
+ main.log.info("Deleting Intnents")
self.handle.sendline("./rmpyintents.py")
self.handle.expect(["$",pexpect.EOF,pexpect.TIMEOUT])
response = self.handle.before
self.handle.sendline("cd "+self.home)
return main.TRUE
- def purge(self):
+ def purge_intents(self):
main.log.info("Purging dead intents")
self.handle.sendline("cd "+self.home+ "/scripts")
self.handle.expect("scripts")
- print("Purging Intents")
+ main.log.info("Sending Purge Intent Rest call to ONOS")
self.handle.sendline("./purgeintents.py")
self.handle.sendline("cd "+self.home)
return main.TRUE
@@ -1033,9 +1081,9 @@
main.exit()
def find_host(self,RestIP,RestPort,RestAPI,hostMAC):
- retcode = 0 # number of devices found with given MAC
- retswitch = [] # Switch DPID's of devices found with MAC
- retport = [] # Switch port connected to to devices found with MAC
+ retcode = 0 # number of hosts found with given MAC
+ retswitch = [] # Switch DPID's of hosts found with MAC
+ retport = [] # Switch port connected to to hosts found with MAC
foundHost = []
try:
##### device rest API is: 'host:8080/wm/onos/topology/switches' ###
@@ -1071,15 +1119,15 @@
'''
for switch in enumerate(parsedResult):
for port in enumerate(switch[1]['ports']):
- if ( port[1]['devices'] != [] ):
+ if ( port[1]['hosts'] != [] ):
try:
- foundHost = port[1]['devices'][0]['ipv4addresses'][0]['ipv4']
+ foundHost = port[1]['hosts'][0]['ipv4addresses'][0]['ipv4']
except:
print "Error in detecting MAC address."
if foundHost == hostMAC:
retswitch.append(switch[1]['dpid'])
retport.append(port[1]['desc'])
- retmac.append(port[1]['devices'][0]['mac'])
+ retmac.append(port[1]['hosts'][0]['mac'])
retcode = retcode +1
foundHost =''
'''