Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONLabTest into cleanup
diff --git a/README.md b/README.md
index b29c092..5986719 100644
--- a/README.md
+++ b/README.md
@@ -26,13 +26,47 @@
------------
1. ONOS
-2. Mininet
+2. Mininet - Some driver functions rely on a modified version of Mininet. These functions are noted in the mininet driver file. To checkout this branch from your Mininet folder:
-3. Install python packages configObj and pexpect. they can be installed as :
+ $ git remote add jhall11 https://github.com/jhall11/mininet.git
- $ sudo pip install configObj
+ $ git fetch jhall11
- $ sudo easy_install pexpect
+ $ git checkout -b dynamic_topo remotes/jhall11/dynamic_topo
+
+ $ git pull
+
+ Note that you may need to run 'sudo make develop' if your mnexec.c file changed when switching branches.
+
+3. Install python packages configObj and pexpect (Note: pexpect 3.3 has a known bug. We recommend using version 3.2 for now). They can be installed as :
+
+ $ sudo pip install configObj
+
+ $ sudo pip install pexpect==3.2
+
+ $ sudo pip install numpy
+
+4. STS - This can be installed by:
+
+ $ git clone https://github.com/jhall11/sts.git
+
+5. Linc-OE - Some testcases use this to emulate optical devices
+
+ Requirements:
+
+ 1. Erlang R15B, R16B, R17 - if possible please use R17
+
+ 2. libpcap-dev package if eth interfaces will be used
+
+ Building and Running:
+
+ $ git clone https://github.com/shivarammysore/LINC-Switch.git linc-oe
+
+ $ cd linc-oe
+
+ $ git checkout tags/oe-0.3
+
+ $ make rel
Configuration
------------
@@ -58,7 +92,7 @@
3. Run the test
- teston> run MininetTest
+ teston> run PingallExample
The Tests
-----------------------------------------------
@@ -68,7 +102,7 @@
1. .ospk file
- - This is written in Openspeak, an word based language developed by Paxterra.
+ - This is written in Openspeak, a word based language developed by Paxterra.
- It defines the cases and sequence of events for the test
diff --git a/TestON/bin/unpep8 b/TestON/bin/unpep8
index 090865a..733d5a3 100755
--- a/TestON/bin/unpep8
+++ b/TestON/bin/unpep8
@@ -179,7 +179,8 @@
def convertFromPep8( program ):
oldProgram = program
# Program text transforms
- # program = reinstateCapWords( program ) # Turning off for now
+ program = reinstateCapWords( program ) # Turning off for now
+ program = reinstateCapWords( program )
program = fixKeywords( program )
program = insertExtraSpaces( program )
# Undo string damage
diff --git a/TestON/core/testparser.py b/TestON/core/testparser.py
index f158259..37f50f0 100644
--- a/TestON/core/testparser.py
+++ b/TestON/core/testparser.py
@@ -96,7 +96,7 @@
if step == 0 :
i = 0
block = ''
- while i <= index :
+ while i < index :
block += caseStatements[i]
i = i + 1
stepCode[step] = block
diff --git a/TestON/drivers/common/cli/.onosclidriver.py.swo b/TestON/drivers/common/cli/.onosclidriver.py.swo
new file mode 100644
index 0000000..87ea889
--- /dev/null
+++ b/TestON/drivers/common/cli/.onosclidriver.py.swo
Binary files differ
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 944eded..8c5793f 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -58,7 +58,7 @@
port=None,
pwd=self.pwd )
- self.ssh_handle = self.handle
+ self.sshHandle = self.handle
if self.handle:
main.log.info( "Handle successfully created" )
@@ -67,31 +67,9 @@
self.handle.sendline( "cd " + self.home )
self.handle.expect( "oe$" )
- #self.handle.sendline( "pgrep -g linc" )
- # self.handle.expect( "\$" )
print "handle = ", self.handle.before
return main.TRUE
- """
- main.log.info( "Building Linc-OE" )
- self.handle.sendline( "make rel" )
- i = self.handle.expect( [ "ERROR","linc-oe\$" ],timeout=60 )
- if i == 0:
- self.handle.sendline( "sudo pkill -9 epmd" )
- self.handle.expect( "\$" )
- self.handle.sendline( "make rel" )
- x = self.handle.expect( [ "\$",pexpect.EOF,pexpect.TIMEOUT ] )
- main.log.info( "make rel returned: "+ str( x ) )
- else:
-
- main.log.info( self.name+": Starting Linc-OE CLI.. This may take a while" )
- time.sleep( 30 )
- self.handle.sendline( "sudo ./rel/linc/bin/linc console" )
- j = self.handle.expect( [ "linc@",pexpect.EOF,pexpect.TIMEOUT ] )
- if j == 0:
- main.log.info( "Linc-OE CLI started" )
- return main.TRUE
- """
else:
main.log.error( self.name +
": Connection failed to the host " +
@@ -100,7 +78,7 @@
": Failed to connect to Linc-OE" )
return main.FALSE
- def start_console( self ):
+ def startConsole( self ):
import time
main.log.info(
self.name +
@@ -108,7 +86,7 @@
time.sleep( 30 )
self.handle.sendline( "sudo ./rel/linc/bin/linc console" )
j = self.handle.expect( [ "linc@", pexpect.EOF, pexpect.TIMEOUT ] )
- start_result = self.handle.before
+ startResult = self.handle.before
if j == 0:
main.log.info( "Linc-OE CLI started" )
return main.TRUE
@@ -134,8 +112,6 @@
"\$" ] )
if i == 0:
- # If error, try to resolve the most common error
- #( epmd running and cannot compile )
self.handle.sendline( "sudo pkill -9 epmd" )
self.handle.sendline( "make rel" )
self.handle.expect( "\$" )
@@ -153,12 +129,12 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def set_interface_up( self, intfs ):
+ def setInterfaceUp( self, intfs ):
"""
Specify interface to bring up.
When Linc-OE is started, tap interfaces should
@@ -179,17 +155,17 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def start_switch( self, sw_id ):
+ def startSwitch( self, swId ):
"""
Start a logical switch using switch id
"""
try:
- self.handle.sendline( "linc:start_switch(" + str( sw_id ) + ")." )
+ self.handle.sendline( "linc:start_switch(" + str( swId ) + ")." )
self.handle.expect( "linc@" )
handle = self.handle.before
@@ -201,17 +177,17 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def stop_switch( self, sw_id ):
+ def stopSwitch( self, swId ):
"""
Stop a logical switch using switch id
"""
try:
- self.handle.sendline( "linc:stop_switch(" + str( sw_id ) + ")." )
+ self.handle.sendline( "linc:stop_switch(" + str( swId ) + ")." )
self.handle.expect( "linc@" )
handle = self.handle.before
@@ -223,18 +199,18 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def get_datapath_id( self, sw_id ):
+ def getDatapathId( self, swId ):
"""
Get datapath id of a specific switch by switch id
"""
try:
self.handle.sendline( "linc_logic:get_datapath_id(" +
- str( sw_id ) + ")." )
+ str( swId ) + ")." )
self.handle.expect( "linc@" )
handle = self.handle.before
@@ -246,17 +222,17 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def list_ports( self, sw_id ):
+ def listPorts( self, swId ):
"""
List all ports of a switch by switch id
"""
try:
- self.handle.sendline( "linc:ports(" + str( sw_id ) + ")." )
+ self.handle.sendline( "linc:ports(" + str( swId ) + ")." )
self.handle.expect( "linc@" )
handle = self.handle.before
@@ -268,18 +244,18 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def port_up( self, sw_id, pt_id ):
+ def portUp( self, swId, ptId ):
"""
Bring port up using switch id and port id
"""
try:
self.handle.sendline( "linc:port_up(" +
- str( sw_id ) + ", " + str( pt_id ) + ")." )
+ str( swId ) + ", " + str( ptId ) + ")." )
self.handle.expect( "linc@" )
handle = self.handle.before
@@ -291,18 +267,18 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
- def port_down( self, sw_id, pt_id ):
+ def portDown( self, swId, ptId ):
"""
Bring port down using switch id and port id
"""
try:
self.handle.sendline( "linc:port_down(" +
- str( sw_id ) + ", " + str( pt_id ) + ")." )
+ str( swId ) + ", " + str( ptId ) + ")." )
self.handle.expect( "linc@" )
handle = self.handle.before
@@ -314,7 +290,7 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
@@ -361,7 +337,7 @@
main.exit()
except:
main.log.info( self.name + " :::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " :::::::" )
main.cleanup()
main.exit()
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index bc0fcc5..95e0cb9 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -2,7 +2,7 @@
"""
Created on 26-Oct-2012
-author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
+author: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
TestON is free software: you can redistribute it and/or modify
@@ -19,7 +19,22 @@
along with TestON. If not, see <http://www.gnu.org/licenses/>.
-MininetCliDriver is the basic driver which will handle the Mininet functions"""
+MininetCliDriver is the basic driver which will handle the Mininet functions
+
+Some functions rely on STS module. To install this,
+ git clone https://github.com/jhall11/sts.git
+
+Some functions rely on a modified version of Mininet. These functions
+should all be noted in the comments. To get this MN version run these commands
+from within your Mininet folder:
+ git remote add jhall11 https://github.com/jhall11/mininet.git
+ git fetch jhall11
+ git checkout -b dynamic_topo remotes/jhall11/dynamic_topo
+ git pull
+
+
+ Note that you may need to run 'sudo make develop' if your mnexec.c file
+changed when switching branches."""
import traceback
import pexpect
import re
@@ -56,7 +71,7 @@
port=None,
pwd=self.pwd )
- self.ssh_handle = self.handle
+ self.sshHandle = self.handle
if self.handle:
main.log.info(
@@ -139,7 +154,7 @@
main.log.error( self.name + ": Failed to connect to the Mininet" )
return main.FALSE
- def num_switches_n_links( self, topoType, depth, fanout ):
+ def numSwitchesNlinks( self, topoType, depth, fanout ):
if topoType == 'tree':
# In tree topology, if fanout arg is not given, by default it is 2
if fanout is None:
@@ -149,36 +164,36 @@
while( k <= depth - 1 ):
count = count + pow( fanout, k )
k = k + 1
- num_switches = count
+ numSwitches = count
while( k <= depth - 2 ):
# depth-2 gives you only core links and not considering
# edge links as seen by ONOS. If all the links including
# edge links are required, do depth-1
count = count + pow( fanout, k )
k = k + 1
- num_links = count * fanout
+ numLinks = count * fanout
# print "num_switches for %s(%d,%d) = %d and links=%d" %(
- # topoType,depth,fanout,num_switches,num_links )
+ # topoType,depth,fanout,numSwitches,numLinks )
elif topoType == 'linear':
- # In linear topology, if fanout or num_hosts_per_sw is not given,
+ # In linear topology, if fanout or numHostsPerSw is not given,
# by default it is 1
if fanout is None:
fanout = 1
- num_switches = depth
- num_hosts_per_sw = fanout
- total_num_hosts = num_switches * num_hosts_per_sw
- num_links = total_num_hosts + ( num_switches - 1 )
+ numSwitches = depth
+ numHostsPerSw = fanout
+ totalNumHosts = numSwitches * numHostsPerSw
+ numLinks = totalNumHosts + ( numSwitches - 1 )
print "num_switches for %s(%d,%d) = %d and links=%d" %\
- ( topoType, depth, fanout, num_switches, num_links )
+ ( topoType, depth, fanout, numSwitches, numLinks )
topoDict = {}
topoDict = {
- "num_switches": int( num_switches ),
- "num_corelinks": int( num_links ) }
+ "num_switches": int( numSwitches ),
+ "num_corelinks": int( numLinks ) }
return topoDict
- def calculate_sw_and_links( self ):
- topoDict = self.num_switches_n_links( *topoArgList )
+ def calculateSwAndLinks( self ):
+ topoDict = self.numSwitchesN_links( *topoArgList )
return topoDict
def pingall( self, timeout=300 ):
@@ -212,13 +227,13 @@
# NOTE: mininet's pingall rounds, so we will check the number of
# passed and number of failed
pattern = "Results\:\s0\%\sdropped\s\(" +\
- "(?P<passed>[\d]+)/(?P=passed)"
+ "(?P<passed>[\d]+)/(?P=passed)"
if re.search( pattern, response ):
main.log.info( self.name + ": All hosts are reachable" )
return main.TRUE
else:
main.log.error( self.name + ": Unable to reach all the hosts" )
- main.log.info( "Pingall ouput: " + str( response ) )
+ main.log.info( "Pingall output: " + str( response ) )
# NOTE: Send ctrl-c to make sure pingall is done
self.handle.send( "\x03" )
self.handle.expect( "Interrupt" )
@@ -282,13 +297,13 @@
main.log.info( self.name + ": Ping Response: " + response )
if re.search( ',\s0\%\spacket\sloss', response ):
main.log.info( self.name + ": no packets lost, host is reachable" )
- main.last_result = main.TRUE
+ main.lastResult = main.TRUE
return main.TRUE
else:
main.log.error(
self.name +
": PACKET LOST, HOST IS NOT REACHABLE" )
- main.last_result = main.FALSE
+ main.lastResult = main.FALSE
return main.FALSE
def checkIP( self, host ):
@@ -453,15 +468,15 @@
main.exit()
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 ]
+ macAddressSearch = re.search( pattern, response, re.I )
+ macAddress = macAddressSearch.group().split( " " )[ 1 ]
main.log.info(
self.name +
": Mac-Address of Host " +
host +
" is " +
- mac_address )
- return mac_address
+ macAddress )
+ return macAddress
else:
main.log.error( self.name + ": Connection failed to the host" )
@@ -479,19 +494,19 @@
main.exit()
pattern = r'HWaddr\s([0-9A-F]{2}[:-]){5}([0-9A-F]{2})'
- mac_address_search = re.search( pattern, response, re.I )
- if mac_address_search is None:
+ macAddressSearch = re.search( pattern, response, re.I )
+ if macAddressSearch is None:
main.log.info( "No mac address found in %s" % response )
return main.FALSE
- mac_address = mac_address_search.group().split( " " )[ 1 ]
+ macAddress = macAddressSearch.group().split( " " )[ 1 ]
main.log.info(
"Mac-Address of " +
host +
":" +
interface +
" is " +
- mac_address )
- return mac_address
+ macAddress )
+ return macAddress
else:
main.log.error( "Connection failed to the host" )
@@ -512,14 +527,14 @@
main.exit()
pattern = "inet\saddr:(\d+\.\d+\.\d+\.\d+)"
- ip_address_search = re.search( pattern, response )
+ ipAddressSearch = re.search( pattern, response )
main.log.info(
self.name +
": IP-Address of Host " +
host +
" is " +
- ip_address_search.group( 1 ) )
- return ip_address_search.group( 1 )
+ ipAddressSearch.group( 1 ) )
+ return ipAddressSearch.group( 1 )
else:
main.log.error( self.name + ": Connection failed to the host" )
@@ -695,11 +710,11 @@
if re.search( ',\s0\%\spacket\sloss', response ):
main.log.info( self.name + ": Ping between two hosts SUCCESSFUL" )
- main.last_result = main.TRUE
+ main.lastResult = main.TRUE
return main.TRUE
else:
main.log.error( self.name + ": PACKET LOST, HOSTS NOT REACHABLE" )
- main.last_result = main.FALSE
+ main.lastResult = main.FALSE
return main.FALSE
def link( self, **linkargs ):
@@ -789,17 +804,17 @@
main.exit()
return main.TRUE
- def get_version( self ):
- file_input = path + '/lib/Mininet/INSTALL'
- version = super( Mininet, self ).get_version()
+ def getVersion( self ):
+ fileInput = path + '/lib/Mininet/INSTALL'
+ version = super( Mininet, self ).getVersion()
pattern = 'Mininet\s\w\.\w\.\w\w*'
- for line in open( file_input, 'r' ).readlines():
+ for line in open( fileInput, 'r' ).readlines():
result = re.match( pattern, line )
if result:
version = result.group( 0 )
return version
- def get_sw_controller( self, sw ):
+ def getSwController( self, sw ):
"""
Parameters:
sw: The name of an OVS switch. Example "s1"
@@ -822,7 +837,7 @@
main.cleanup()
main.exit()
- def assign_sw_controller( self, **kwargs ):
+ def assignSwController( self, **kwargs ):
"""
count is only needed if there is more than 1 controller"""
args = utilities.parse_args( [ "COUNT" ], **kwargs )
@@ -872,7 +887,7 @@
main.cleanup()
main.exit()
- def delete_sw_controller( self, sw ):
+ def deleteSwController( self, sw ):
"""
Removes the controller target from sw"""
command = "sh ovs-vsctl del-controller " + str( sw )
@@ -889,10 +904,11 @@
else:
main.log.info( response )
- def add_switch( self, sw, **kwargs ):
+ def addSwitch( self, sw, **kwargs ):
"""
adds a switch to the mininet topology
- NOTE: this uses a custom mn function
+ NOTE: This uses a custom mn function. MN repo should be on
+ dynamic_topo branch
NOTE: cannot currently specify what type of switch
required params:
switchname = name of the new switch as a string
@@ -924,13 +940,14 @@
main.cleanup()
main.exit()
- def del_switch( self, sw ):
+ def delSwitch( self, sw ):
"""
- delete a switch from the mininet topology
- NOTE: this uses a custom mn function
- required params:
+ delete a switch from the mininet topology
+ NOTE: This uses a custom mn function. MN repo should be on
+ dynamic_topo branch
+ required params:
switchname = name of the switch as a string
- returns: main.FASLE on an error, else main.TRUE"""
+ returns: main.FASLE on an error, else main.TRUE"""
command = "delswitch " + str( sw )
try:
response = self.execute(
@@ -954,10 +971,11 @@
main.cleanup()
main.exit()
- def add_link( self, node1, node2 ):
+ def addLink( self, node1, node2 ):
"""
add a link to the mininet topology
- NOTE: this uses a custom mn function
+ NOTE: This uses a custom mn function. MN repo should be on
+ dynamic_topo branch
NOTE: cannot currently specify what type of link
required params:
node1 = the string node name of the first endpoint of the link
@@ -986,10 +1004,11 @@
main.cleanup()
main.exit()
- def del_link( self, node1, node2 ):
+ def delLink( self, node1, node2 ):
"""
delete a link from the mininet topology
- NOTE: this uses a custom mn function
+ NOTE: This uses a custom mn function. MN repo should be on
+ dynamic_topo branch
required params:
node1 = the string node name of the first endpoint of the link
node2 = the string node name of the second endpoint of the link
@@ -1017,10 +1036,11 @@
main.cleanup()
main.exit()
- def add_host( self, hostname, **kwargs ):
+ def addHost( self, hostname, **kwargs ):
"""
Add a host to the mininet topology
- NOTE: this uses a custom mn function
+ NOTE: This uses a custom mn function. MN repo should be on
+ dynamic_topo branch
NOTE: cannot currently specify what type of host
required params:
hostname = the string hostname
@@ -1055,9 +1075,11 @@
main.cleanup()
main.exit()
- def del_host( self, hostname ):
+ def delHost( self, hostname ):
"""
delete a host from the mininet topology
+ NOTE: This uses a custom mn function. MN repo should be on
+ dynamic_topo branch
NOTE: this uses a custom mn function
required params:
hostname = the string hostname
@@ -1154,10 +1176,10 @@
else:
main.log.error( "Connection failed to the Mininet host" )
- def check_flows( self, sw, dump_format=None ):
- if dump_format:
+ def checkFlows( self, sw, dumpFormat=None ):
+ if dumpFormat:
command = "sh ovs-ofctl -F " + \
- dump_format + " dump-flows " + str( sw )
+ dumpFormat + " dump-flows " + str( sw )
else:
command = "sh ovs-ofctl dump-flows " + str( sw )
try:
@@ -1174,7 +1196,7 @@
else:
main.log.info( response )
- def start_tcpdump( self, filename, intf="eth0", port="port 6633" ):
+ def startTcpdump( self, filename, intf="eth0", port="port 6633" ):
"""
Runs tpdump on an intferface and saves the file
intf can be specified, or the default eth0 is used"""
@@ -1233,7 +1255,7 @@
main.cleanup()
main.exit()
- def stop_tcpdump( self ):
+ def stopTcpdump( self ):
"pkills tcpdump"
try:
self.handle.sendline( "sh sudo pkill tcpdump" )
@@ -1252,14 +1274,14 @@
main.cleanup()
main.exit()
- def compare_switches( self, topo, switches_json ):
+ def compareSwitches( self, topo, switchesJson ):
"""
Compare mn and onos switches
topo: sts TestONTopology object
- switches_json: parsed json object from the onos devices api
+ switchesJson: parsed json object from the onos devices api
This uses the sts TestONTopology object"""
- # main.log.debug( "Switches_json string: ", switches_json )
+ # main.log.debug( "Switches_json string: ", switchesJson )
output = { "switches": [] }
# iterate through the MN topology and pull out switches and and port
# info
@@ -1268,7 +1290,7 @@
for port in switch.ports.values():
ports.append( { 'of_port': port.port_no,
'mac': str( port.hw_addr ).replace( '\'',
- '' ),
+ '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1277,12 +1299,12 @@
# print "mn"
# print json.dumps( output,
- # sort_keys=True,
+ # sortKeys=True,
# indent=4,
# separators=( ',', ': ' ) )
# print "onos"
- # print json.dumps( switches_json,
- # sort_keys=True,
+ # print json.dumps( switchesJson,
+ # sortKeys=True,
# indent=4,
# separators=( ',', ': ' ) )
@@ -1293,12 +1315,12 @@
mnDPIDs.sort()
# print "List of Mininet switch DPID's"
# print mnDPIDs
- if switches_json == "": # if rest call fails
+ if switchesJson == "": # if rest call fails
main.log.error(
self.name +
".compare_switches(): Empty JSON object given from ONOS" )
return main.FALSE
- onos = switches_json
+ onos = switchesJson
onosDPIDs = []
for switch in onos:
if switch[ 'available' ]:
@@ -1316,7 +1338,7 @@
# print onosDPIDs
if mnDPIDs != onosDPIDs:
- switch_results = main.FALSE
+ switchResults = main.FALSE
main.log.report( "Switches in MN but not in ONOS:" )
list1 = [ switch for switch in mnDPIDs if switch not in onosDPIDs ]
main.log.report( str( list1 ) )
@@ -1324,14 +1346,14 @@
list2 = [ switch for switch in onosDPIDs if switch not in mnDPIDs ]
main.log.report( str( list2 ) )
else: # list of dpid's match in onos and mn
- switch_results = main.TRUE
- return switch_results
+ switchResults = main.TRUE
+ return switchResults
- def compare_ports( self, topo, ports_json ):
+ def comparePorts( self, topo, portsJson ):
"""
Compare mn and onos ports
topo: sts TestONTopology object
- ports_json: parsed json object from the onos ports api
+ portsJson: parsed json object from the onos ports api
Dependencies:
1. This uses the sts TestONTopology object
@@ -1341,7 +1363,7 @@
# FIXME: this does not look for extra ports in ONOS, only checks that
# ONOS has what is in MN
from numpy import uint64
- ports_results = main.TRUE
+ portsResults = main.TRUE
output = { "switches": [] }
# iterate through the MN topology and pull out switches and and port
# info
@@ -1349,101 +1371,101 @@
ports = []
for port in switch.ports.values():
# print port.hw_addr.toStr( separator='' )
- tmp_port = {}
- tmp_port[ 'of_port' ] = port.port_no
- tmp_port[ 'mac' ] = str( port.hw_addr ).replace( '\'', '' )
- tmp_port[ 'name' ] = port.name
- tmp_port[ 'enabled' ] = port.enabled
+ tmpPort = {}
+ tmpPort[ 'of_port' ] = port.port_no
+ tmpPort[ 'mac' ] = str( port.hw_addr ).replace( '\'', '' )
+ tmpPort[ 'name' ] = port.name
+ tmpPort[ 'enabled' ] = port.enabled
- ports.append( tmp_port )
- tmp_switch = {}
- tmp_switch[ 'name' ] = switch.name
- tmp_switch[ 'dpid' ] = str( switch.dpid ).zfill( 16 )
- tmp_switch[ 'ports' ] = ports
+ ports.append( tmpPort )
+ tmpSwitch = {}
+ tmpSwitch[ 'name' ] = switch.name
+ tmpSwitch[ 'dpid' ] = str( switch.dpid ).zfill( 16 )
+ tmpSwitch[ 'ports' ] = ports
- output[ 'switches' ].append( tmp_switch )
+ output[ 'switches' ].append( tmpSwitch )
# PORTS
- for mn_switch in output[ 'switches' ]:
- mn_ports = []
- onos_ports = []
- switch_result = main.TRUE
- for port in mn_switch[ 'ports' ]:
+ for mnSwitch in output[ 'switches' ]:
+ mnPorts = []
+ onosPorts = []
+ switchResult = main.TRUE
+ for port in mnSwitch[ 'ports' ]:
if port[ 'enabled' ]:
- mn_ports.append( port[ 'of_port' ] )
- for onos_switch in ports_json:
+ mnPorts.append( port[ 'of_port' ] )
+ for onosSwitch in portsJson:
# print "Iterating through a new switch as seen by ONOS"
- # print onos_switch
- if onos_switch[ 'device' ][ 'available' ]:
- if onos_switch[ 'device' ][ 'id' ].replace(
+ # print onosSwitch
+ if onosSwitch[ 'device' ][ 'available' ]:
+ if onosSwitch[ 'device' ][ 'id' ].replace(
':',
'' ).replace(
"of",
- '' ) == mn_switch[ 'dpid' ]:
- for port in onos_switch[ 'ports' ]:
+ '' ) == mnSwitch[ 'dpid' ]:
+ for port in onosSwitch[ 'ports' ]:
if port[ 'isEnabled' ]:
if port[ 'port' ] == 'local':
- # onos_ports.append( 'local' )
- onos_ports.append( long( uint64( -2 ) ) )
+ # onosPorts.append( 'local' )
+ onosPorts.append( long( uint64( -2 ) ) )
else:
- onos_ports.append( int( port[ 'port' ] ) )
+ onosPorts.append( int( port[ 'port' ] ) )
break
- mn_ports.sort( key=float )
- onos_ports.sort( key=float )
- # print "\nPorts for Switch %s:" % ( mn_switch[ 'name' ] )
- # print "\tmn_ports[] = ", mn_ports
- # print "\tonos_ports[] = ", onos_ports
- mn_ports_log = mn_ports
- onos_ports_log = onos_ports
- mn_ports = [ x for x in mn_ports ]
- onos_ports = [ x for x in onos_ports ]
+ mnPorts.sort( key=float )
+ onosPorts.sort( key=float )
+ # print "\nPorts for Switch %s:" % ( mnSwitch[ 'name' ] )
+ # print "\tmn_ports[] = ", mnPorts
+ # print "\tonos_ports[] = ", onosPorts
+ mnPortsLog = mnPorts
+ onosPortsLog = onosPorts
+ mnPorts = [ x for x in mnPorts ]
+ onosPorts = [ x for x in onosPorts ]
# TODO: handle other reserved port numbers besides LOCAL
# NOTE: Reserved ports
# Local port: -2 in Openflow, ONOS shows 'local', we store as
# long( uint64( -2 ) )
- for mn_port in mn_ports_log:
- if mn_port in onos_ports:
+ for mnPort in mnPortsLog:
+ if mnPort in onosPorts:
# don't set results to true here as this is just one of
# many checks and it might override a failure
- mn_ports.remove( mn_port )
- onos_ports.remove( mn_port )
+ mnPorts.remove( mnPort )
+ onosPorts.remove( mnPort )
# NOTE: OVS reports this as down since there is no link
# So ignoring these for now
# TODO: Come up with a better way of handling these
- if 65534 in mn_ports:
- mn_ports.remove( 65534 )
- if long( uint64( -2 ) ) in onos_ports:
- onos_ports.remove( long( uint64( -2 ) ) )
- if len( mn_ports ): # the ports of this switch don't match
- switch_result = main.FALSE
- main.log.warn( "Ports in MN but not ONOS: " + str( mn_ports ) )
- if len( onos_ports ): # the ports of this switch don't match
- switch_result = main.FALSE
+ if 65534 in mnPorts:
+ mnPorts.remove( 65534 )
+ if long( uint64( -2 ) ) in onosPorts:
+ onosPorts.remove( long( uint64( -2 ) ) )
+ if len( mnPorts ): # the ports of this switch don't match
+ switchResult = main.FALSE
+ main.log.warn( "Ports in MN but not ONOS: " + str( mnPorts ) )
+ if len( onosPorts ): # the ports of this switch don't match
+ switchResult = main.FALSE
main.log.warn(
"Ports in ONOS but not MN: " +
- str( onos_ports ) )
- if switch_result == main.FALSE:
+ str( onosPorts ) )
+ if switchResult == main.FALSE:
main.log.report(
"The list of ports for switch %s(%s) does not match:" %
- ( mn_switch[ 'name' ], mn_switch[ 'dpid' ] ) )
- main.log.warn( "mn_ports[] = " + str( mn_ports_log ) )
- main.log.warn( "onos_ports[] = " + str( onos_ports_log ) )
- ports_results = ports_results and switch_result
- return ports_results
+ ( mnSwitch[ 'name' ], mnSwitch[ 'dpid' ] ) )
+ main.log.warn( "mn_ports[] = " + str( mnPortsLog ) )
+ main.log.warn( "onos_ports[] = " + str( onosPortsLog ) )
+ portsResults = portsResults and switchResult
+ return portsResults
- def compare_links( self, topo, links_json ):
+ def compareLinks( self, topo, linksJson ):
"""
Compare mn and onos links
topo: sts TestONTopology object
- links_json: parsed json object from the onos links api
+ linksJson: parsed json object from the onos links api
This uses the sts TestONTopology object"""
# FIXME: this does not look for extra links in ONOS, only checks that
# ONOS has what is in MN
- link_results = main.TRUE
+ linkResults = main.TRUE
output = { "switches": [] }
- onos = links_json
+ onos = linksJson
# iterate through the MN topology and pull out switches and and port
# info
for switch in topo.graph.switches:
@@ -1454,7 +1476,7 @@
# print port.hw_addr.toStr( separator='' )
ports.append( { 'of_port': port.port_no,
'mac': str( port.hw_addr ).replace( '\'',
- '' ),
+ '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1462,33 +1484,33 @@
"ports": ports } )
# LINKS
- mn_links = [
+ mnLinks = [
link for link in topo.patch_panel.network_links if (
link.port1.enabled and link.port2.enabled ) ]
- if 2 * len( mn_links ) == len( onos ):
- link_results = main.TRUE
+ if 2 * len( mnLinks ) == len( onos ):
+ linkResults = main.TRUE
else:
- link_results = main.FALSE
+ linkResults = main.FALSE
main.log.report(
"Mininet has %i bidirectional links and " +
"ONOS has %i unidirectional links" %
- ( len( mn_links ), len( onos ) ) )
+ ( len( mnLinks ), len( onos ) ) )
# iterate through MN links and check if an ONOS link exists in
# both directions
# NOTE: Will currently only show mn links as down if they are
# cut through STS. We can either do everything through STS or
- # wait for up_network_links and down_network_links to be
+ # wait for upNetworkLinks and downNetworkLinks to be
# fully implemented.
- for link in mn_links:
+ for link in mnLinks:
# print "Link: %s" % link
# TODO: Find a more efficient search method
node1 = None
port1 = None
node2 = None
port2 = None
- first_dir = main.FALSE
- second_dir = main.FALSE
+ firstDir = main.FALSE
+ secondDir = main.FALSE
for switch in output[ 'switches' ]:
# print "Switch: %s" % switch[ 'name' ]
if switch[ 'name' ] == link.node1.name:
@@ -1506,26 +1528,26 @@
if node1 is not None and node2 is not None:
break
- for onos_link in onos:
- onos_node1 = onos_link[ 'src' ][ 'device' ].replace(
+ for onosLink in onos:
+ onosNode1 = onosLink[ 'src' ][ 'device' ].replace(
":",
'' ).replace(
"of",
'' )
- onos_node2 = onos_link[ 'dst' ][ 'device' ].replace(
+ onosNode2 = onosLink[ 'dst' ][ 'device' ].replace(
":",
'' ).replace(
"of",
'' )
- onos_port1 = onos_link[ 'src' ][ 'port' ]
- onos_port2 = onos_link[ 'dst' ][ 'port' ]
+ onosPort1 = onosLink[ 'src' ][ 'port' ]
+ onosPort2 = onosLink[ 'dst' ][ 'port' ]
# check onos link from node1 to node2
- if str( onos_node1 ) == str( node1 ) and str(
- onos_node2 ) == str( node2 ):
- if int( onos_port1 ) == int( port1 ) and int(
- onos_port2 ) == int( port2 ):
- first_dir = main.TRUE
+ if str( onosNode1 ) == str( node1 ) and str(
+ onosNode2 ) == str( node2 ):
+ if int( onosPort1 ) == int( port1 ) and int(
+ onosPort2 ) == int( port2 ):
+ firstDir = main.TRUE
else:
main.log.warn(
'The port numbers do not match for ' +
@@ -1537,17 +1559,17 @@
node2,
port2 ) +
' ONOS has the values %s/%s -> %s/%s' %
- ( onos_node1,
- onos_port1,
- onos_node2,
- onos_port2 ) )
+ ( onosNode1,
+ onosPort1,
+ onosNode2,
+ onosPort2 ) )
# check onos link from node2 to node1
- elif ( str( onos_node1 ) == str( node2 ) and
- str( onos_node2 ) == str( node1 ) ):
- if ( int( onos_port1 ) == int( port2 )
- and int( onos_port2 ) == int( port1 ) ):
- second_dir = main.TRUE
+ elif ( str( onosNode1 ) == str( node2 ) and
+ str( onosNode2 ) == str( node1 ) ):
+ if ( int( onosPort1 ) == int( port2 )
+ and int( onosPort2 ) == int( port1 ) ):
+ secondDir = main.TRUE
else:
main.log.warn(
'The port numbers do not match for ' +
@@ -1559,24 +1581,24 @@
node1,
port1 ) +
' ONOS has the values %s/%s -> %s/%s' %
- ( onos_node2,
- onos_port2,
- onos_node1,
- onos_port1 ) )
+ ( onosNode2,
+ onosPort2,
+ onosNode1,
+ onosPort1 ) )
else: # this is not the link you're looking for
pass
- if not first_dir:
+ if not firstDir:
main.log.report(
'ONOS does not have the link %s/%s -> %s/%s' %
( node1, port1, node2, port2 ) )
- if not second_dir:
+ if not secondDir:
main.log.report(
'ONOS does not have the link %s/%s -> %s/%s' %
( node2, port2, node1, port1 ) )
- link_results = link_results and first_dir and second_dir
- return link_results
+ linkResults = linkResults and firstDir and secondDir
+ return linkResults
- def get_hosts( self ):
+ def getHosts( self ):
"""
Returns a list of all hosts
Don't ask questions just use it"""
@@ -1586,19 +1608,19 @@
self.handle.sendline( "py [ host.name for host in net.hosts ]" )
self.handle.expect( "mininet>" )
- handle_py = self.handle.before
- handle_py = handle_py.split( "]\r\n", 1 )[ 1 ]
- handle_py = handle_py.rstrip()
+ handlePy = self.handle.before
+ handlePy = handlePy.split( "]\r\n", 1 )[ 1 ]
+ handlePy = handlePy.rstrip()
self.handle.sendline( "" )
self.handle.expect( "mininet>" )
- host_str = handle_py.replace( "]", "" )
- host_str = host_str.replace( "'", "" )
- host_str = host_str.replace( "[", "" )
- host_list = host_str.split( "," )
+ hostStr = handlePy.replace( "]", "" )
+ hostStr = hostStr.replace( "'", "" )
+ hostStr = hostStr.replace( "[", "" )
+ hostList = hostStr.split( "," )
- return host_list
+ return hostList
def update( self ):
"""
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index a8aedea..e15e53c 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -32,9 +32,10 @@
class RemoteMininetDriver( Emulator ):
"""
- RemoteMininetCliDriver is the basic driver which will handle the Mininet functions
- The main different between this and the MininetCliDriver is that this one does not build the mininet.
- It assumes that there is already a mininet running on the target.
+ RemoteMininetCliDriver is the basic driver which will handle the Mininet
+ functions. The main different between this and the MininetCliDriver is that
+ this one does not build the mininet. It assumes that there is already a
+ mininet running on the target.
"""
def __init__( self ):
super( Emulator, self ).__init__()
@@ -43,9 +44,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.
+ """,user_name, ip_address, pwd,options ):
+ Here the main is the TestON instance after creating all the log
+ handles."""
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
@@ -58,7 +59,7 @@
port=None,
pwd=self.pwd )
- self.ssh_handle = self.handle
+ self.sshHandle = self.handle
# Copying the readme file to process the
if self.handle:
@@ -73,26 +74,14 @@
main.log.error( "Failed to connect to the Mininet" )
return main.FALSE
-#*************************************************************************
-#*************************************************************************
-# checkForLoss will determine if any of the pings had any packets lost during the course of
-# the pingLong.
-#*************************************************************************
-#*************************************************************************
-
def checkForLoss( self, pingList ):
"""
Returns main.FALSE for 0% packet loss and
Returns main.ERROR if "found multiple mininet" is found and
Returns main.TRUE else
"""
- # TODO: maybe we want to return the % loss instead? This way we can set an acceptible loss %.
- # EX: 393 packets transmitted, 380 received, 3% packet loss, time 78519ms
- # we may need to return a float to get around rounding errors
-
self.handle.sendline( "" )
self.handle.expect( "\$" )
- # Clear any output waiting in the bg from killing pings
self.handle.sendline( "" )
self.handle.expect( "\$" )
self.handle.sendline( "cat " + pingList )
@@ -110,7 +99,8 @@
def pingLong( self, **pingParams ):
"""
- Starts a continuous ping on the mininet host outputing to a file in the /tmp dir.
+ Starts a continuous ping on the mininet host outputing
+ to a file in the /tmp dir.
"""
self.handle.sendline( "" )
self.handle.expect( "\$" )
@@ -118,8 +108,9 @@
[ "SRC", "TARGET", "PINGTIME" ], **pingParams )
precmd = "sudo rm /tmp/ping." + args[ "SRC" ]
self.execute( cmd=precmd, prompt="(.*)", timeout=10 )
- command = "sudo mininet/util/m " + args[ "SRC" ] + " ping " + args[
- "TARGET" ] + " -i .2 -w " + str( args[ 'PINGTIME' ] ) + " -D > /tmp/ping." + args[ "SRC" ] + " &"
+ command = "sudo mininet/util/m " + args[ "SRC" ] + " ping " +\
+ args[ "TARGET" ] + " -i .2 -w " + str( args[ 'PINGTIME' ] ) +\
+ " -D > /tmp/ping." + args[ "SRC" ] + " &"
main.log.info( command )
self.execute( cmd=command, prompt="(.*)", timeout=10 )
self.handle.sendline( "" )
@@ -128,7 +119,8 @@
def pingstatus( self, **pingParams ):
"""
- Tails the respective ping output file and check that there is a moving "64 bytes"
+ Tails the respective ping output file and check that
+ there is a moving "64 bytes"
"""
self.handle.sendline( "" )
self.handle.expect( "\$" )
@@ -196,12 +188,10 @@
Currently the only supported Params: SRC and TARGET
"""
args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
- #command = args[ "SRC" ] + " ping -" + args[ "CONTROLLER" ] + " " +args [ "TARGET" ]
command = args[ "SRC" ] + " ping " + \
args[ "TARGET" ] + " -c 1 -i 1 -W 8"
try:
main.log.warn( "Sending: " + command )
- #response = self.execute( cmd=command,prompt="mininet",timeout=10 )
self.handle.sendline( command )
i = self.handle.expect( [ command, pexpect.TIMEOUT ] )
if i == 1:
@@ -222,18 +212,15 @@
main.cleanup()
main.exit()
main.log.info( self.name + ": Ping Response: " + response )
- # if utilities.assert_matches(
- # expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet
- # loss",onfail="Host is not reachable" ):
if re.search( ',\s0\%\spacket\sloss', response ):
main.log.info( self.name + ": no packets lost, host is reachable" )
- main.last_result = main.TRUE
+ main.lastResult = main.TRUE
return main.TRUE
else:
main.log.error(
self.name +
": PACKET LOST, HOST IS NOT REACHABLE" )
- main.last_result = main.FALSE
+ main.lastResult = main.FALSE
return main.FALSE
def pingHost( self, **pingParams ):
@@ -243,24 +230,21 @@
self.handle.sendline( "" )
self.handle.expect( "\$" )
args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
- #command = "mininet/util/m " + args[ "SRC" ] + " ping "+args [ "TARGET" ]+" -c 4 -W 1 -i .2"
command = "mininet/util/m " + \
args[ "SRC" ] + " ping " + args[ "TARGET" ] + " -c 4 -W 1 -i .2"
main.log.info( command )
response = self.execute( cmd=command, prompt="rtt", timeout=10 )
- # self.handle.sendline( "" )
- # self.handle.expect( "\$" )
if utilities.assert_matches(
expect=',\s0\%\spacket\sloss',
actual=response,
onpass="No Packet loss",
onfail="Host is not reachable" ):
main.log.info( "NO PACKET LOSS, HOST IS REACHABLE" )
- main.last_result = main.TRUE
+ main.lastResult = main.TRUE
return main.TRUE
else:
main.log.error( "PACKET LOST, HOST IS NOT REACHABLE" )
- main.last_result = main.FALSE
+ main.lastResult = main.FALSE
return main.FALSE
def checknum( self, num ):
@@ -290,7 +274,7 @@
else:
main.log.error( "Connection failed to the host" )
- def start_tcpdump(
+ def startTcpdump(
self,
filename,
intf="eth0",
@@ -314,23 +298,19 @@
" &" )
self.handle.sendline( "" )
self.handle.sendline( "" )
- i = self.handle.expect(
- [ 'No\ssuch\device', 'listening\son', pexpect.TIMEOUT, "\$" ], timeout=10 )
+ i = self.handle.expect( [ 'No\ssuch\device', 'listening\son',
+ pexpect.TIMEOUT, "\$" ], timeout=10 )
main.log.warn( self.handle.before + self.handle.after )
if i == 0:
- main.log.error(
- self.name +
- ": tcpdump - No such device exists. tcpdump attempted on: " +
- intf )
+ main.log.error( self.name + ": tcpdump - No such device exists.\
+ tcpdump attempted on: " + intf )
return main.FALSE
elif i == 1:
main.log.info( self.name + ": tcpdump started on " + intf )
return main.TRUE
elif i == 2:
- main.log.error(
- self.name +
- ": tcpdump command timed out! Check interface name, given interface was: " +
- intf )
+ main.log.error( self.name + ": tcpdump command timed out!\
+ Check interface name, given interface was: " + intf )
return main.FALSE
elif i == 3:
main.log.info( self.name + ": " + self.handle.before )
@@ -345,15 +325,13 @@
main.exit()
except:
main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ self.name + ":" * 60 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 80 )
main.cleanup()
main.exit()
- def stop_tcpdump( self ):
+ def stopTcpdump( self ):
"pkills tcpdump"
try:
self.handle.sendline( "sudo pkill tcpdump" )
@@ -367,19 +345,17 @@
main.exit()
except:
main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ self.name + ":" * 60 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 80 )
main.cleanup()
main.exit()
- def run_optical_mn_script( self ):
+ def runOpticalMnScript( self ):
"""
This function is only meant for Packet Optical.
- It runs the python script "optical.py" to create the packet layer( mn )
- topology
+ It runs the python script "optical.py" to create the
+ packet layer( mn ) topology
"""
try:
self.handle.sendline( "" )
@@ -411,17 +387,20 @@
response = main.FALSE
return response
- def get_flowTable( self, protoVersion, sw ):
- # TODO document usage
- # TODO add option to look at cookies. ignoreing them for now
+ def getFlowTable( self, protoVersion, sw ):
+ """
+ TODO document usage
+ TODO add option to look at cookies. ignoreing them for now
+
+ print "get_flowTable(" + str( protoVersion ) +" " + str( sw ) +")"
+ NOTE: Use format to force consistent flow table output across
+ versions"""
self.handle.sendline( "cd" )
self.handle.expect( [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
- # print "get_flowTable(" + str( protoVersion ) +" " + str( sw ) +")"
- # NOTE: Use format to force consistent flow table output across
- # versions
if protoVersion == 1.0:
command = "sudo ovs-ofctl dump-flows " + sw + \
- " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 $7 $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
+ " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 \
+ $7 $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
self.handle.sendline( command )
self.handle.expect( [ "k1 -r", pexpect.EOF, pexpect.TIMEOUT ] )
self.handle.expect(
@@ -431,7 +410,8 @@
return response
elif protoVersion == 1.3:
command = "sudo ovs-ofctl dump-flows " + sw + \
- " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}' | cut -d ',' -f 2- | sort -n -k1 -r"
+ " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}'\
+ | cut -d ',' -f 2- | sort -n -k1 -r"
self.handle.sendline( command )
self.handle.expect( [ "k1 -r", pexpect.EOF, pexpect.TIMEOUT ] )
self.handle.expect(
@@ -445,10 +425,10 @@
str(
type( protoVersion ) ) +
") '" +
- str(protoVersion) +
+ str( protoVersion ) +
"'" )
- def flow_comp( self, flow1, flow2 ):
+ def flowComp( self, flow1, flow2 ):
if flow1 == flow2:
return main.TRUE
else:
@@ -459,27 +439,23 @@
main.log.info( flow2 )
return main.FALSE
- def setIpTablesOUTPUT(
- self,
- dst_ip,
- dst_port,
- action='add',
- packet_type='tcp',
- rule='DROP' ):
+ def setIpTablesOUTPUT( self, dstIp, dstPort, action='add',
+ packetType='tcp', rule='DROP' ):
"""
Description:
- add or remove iptables rule to DROP ( default ) packets from specific IP and PORT
+ add or remove iptables rule to DROP ( default )
+ packets from specific IP and PORT
Usage:
* specify action ( 'add' or 'remove' )
when removing, pass in the same argument as you would add. It will
delete that specific rule.
- * specify the destination ip to block with dst_ip
- * specify destination port to block to dst_port
+ * specify the destination ip to block with dstIp
+ * specify destination port to block to dstPort
* optional packet type to block ( default tcp )
* optional iptables rule ( default DROP )
WARNING:
- * This function uses root privilege iptables command which may result in
- unwanted network errors. USE WITH CAUTION
+ * This function uses root privilege iptables command which may result
+ in unwanted network errors. USE WITH CAUTION
"""
import re
import time
@@ -488,14 +464,15 @@
# The strict checking methods of this driver function is intentional
# to discourage any misuse or error of iptables, which can cause
# severe network errors
- #*************
+ # *************
- # NOTE: Sleep needed to give some time for rule to be added and registered
+ # NOTE: Sleep needed to give some time
+ # for rule to be added and registered
# to the instance
time.sleep( 5 )
- action_type = action.lower()
- if action_type != 'add' and action_type != 'remove':
+ actionType = action.lower()
+ if actionType != 'add' and actionType != 'remove':
main.log.error(
"Invalid action type. 'add' or 'remove' table rule" )
if rule != 'DROP' and rule != 'ACCEPT' and rule != 'LOG':
@@ -507,27 +484,28 @@
else:
# If there is no existing rule in the iptables, we will see an
- #'iptables:'... message. We expect to see this message.
+ # 'iptables:'... message. We expect to see this message.
# Otherwise, if there IS an existing rule, we will get the prompt
# back, hence why we expect $ for remove type. We want to remove
# an already existing rule
- if action_type == 'add':
- # NOTE: "iptables:" expect is a result of return from the command
- # iptables -C ...
- # Any changes by the iptables command return string
- # will result in failure of the function. ( deemed unlikely
- # at the time of writing this function )
+ if actionType == 'add':
+ # NOTE: "iptables:" expect is a result of
+ # return from the command
+ # iptables -C ...
+ # Any changes by the iptables command return string
+ # will result in failure of the function. ( deemed unlikely
+ # at the time of writing this function )
# Check for existing rules on current input
self.handle.sendline( "" )
self.handle.expect( "\$" )
self.handle.sendline(
"sudo iptables -C OUTPUT -p " +
- str( packet_type ) +
+ str( packetType ) +
" -d " +
- str( dst_ip ) +
+ str( dstIp ) +
" --dport " +
- str( dst_port ) +
+ str( dstPort ) +
" -j " +
str( rule ) )
i = self.handle.expect( [ "iptables:", "\$" ] )
@@ -536,61 +514,61 @@
print "after: "
print self.handle.after
- elif action_type == 'remove':
+ elif actionType == 'remove':
# Check for existing rules on current input
self.handle.sendline( "" )
self.handle.expect( "\$" )
self.handle.sendline(
"sudo iptables -C OUTPUT -p " +
- str( packet_type ) +
+ str( packetType ) +
" -d " +
- str( dst_ip ) +
+ str( dstIp ) +
" --dport " +
- str( dst_port ) +
+ str( dstPort ) +
" -j " +
str( rule ) )
self.handle.expect( "\$" )
print "before: "
print self.handle.before
- actual_string = self.handle.after
- expect_string = "iptables:"
+ actualString = self.handle.after
+ expectString = "iptables:"
print "Actual String:"
- print actual_string
+ print actualString
- if re.search( expect_string, actual_string ):
- match_result = main.TRUE
+ if re.search( expectString, actualString ):
+ matchResult = main.TRUE
else:
- match_result = main.FALSE
- # If match_result is main.TRUE, it means there is no matching rule.
+ matchResult = main.FALSE
+ # If matchResult is main.TRUE, it means there is no matching rule.
- # If tables does not exist and expected prompt is returned, go ahead and
- # add iptables rule
- if match_result == main.TRUE:
+ # If tables does not exist and expected prompt is returned,
+ # go ahead and add iptables rule
+ if matchResult == main.TRUE:
# Ensure action type is add
- if action_type == 'add':
- #-A is the 'append' action of iptables
- action_add = '-A'
+ if actionType == 'add':
+ # -A is the 'append' action of iptables
+ actionAdd = '-A'
try:
self.handle.sendline( "" )
self.handle.sendline(
"sudo iptables " +
- action_add +
+ actionAdd +
" OUTPUT -p " +
- str( packet_type ) +
+ str( packetType ) +
" -d " +
- str( dst_ip ) +
+ str( dstIp ) +
" --dport " +
- str( dst_port ) +
+ str( dstPort ) +
" -j " +
str( rule ) )
- info_string = "Rules added to " + str( self.name )
- info_string += "iptable rule added to block IP: " + \
- str( dst_ip )
- info_string += "Port: " + \
- str( dst_port ) + " Rule: " + str( rule )
+ infoString = "Rules added to " + str( self.name )
+ infoString += "iptable rule added to block IP: " + \
+ str( dstIp )
+ infoString += "Port: " + \
+ str( dstPort ) + " Rule: " + str( rule )
- main.log.info( info_string )
+ main.log.info( infoString )
self.handle.expect(
[ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
@@ -605,34 +583,35 @@
else:
main.log.error(
"Given rule already exists, but attempted to add it" )
- # If match_result is 0, it means there IS a matching rule provided
- elif match_result == main.FALSE:
+ # If matchResult is 0, it means there IS a matching rule provided
+ elif matchResult == main.FALSE:
# Ensure action type is remove
- if action_type == 'remove':
- #-D is the 'delete' rule of iptables
- action_remove = '-D'
+ if actionType == 'remove':
+ # -D is the 'delete' rule of iptables
+ actionRemove = '-D'
try:
self.handle.sendline( "" )
# Delete a specific rule specified into the function
self.handle.sendline(
"sudo iptables " +
- action_remove +
+ actionRemove +
" OUTPUT -p " +
- str( packet_type ) +
+ str( packetType ) +
" -d " +
- str( dst_ip ) +
+ str( dstIp ) +
" --dport " +
- str( dst_port ) +
+ str( dstPort ) +
" -j " +
str( rule ) )
- info_string = "Rules removed from " + str( self.name )
- info_string += " iptables rule removed from blocking IP: " + \
- str( dst_ip )
- info_string += " Port: " + \
- str( dst_port ) + " Rule: " + str( rule )
+ infoString = "Rules removed from " + str( self.name )
+ infoString += " iptables rule removed \
+ from blocking IP: " + \
+ str( dstIp )
+ infoString += " Port: " + \
+ str( dstPort ) + " Rule: " + str( rule )
- main.log.info( info_string )
+ main.log.info( infoString )
self.handle.expect(
[ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
@@ -646,7 +625,8 @@
main.exit()
else:
main.log.error(
- "Given rule does not exist, but attempted to remove it" )
+ "Given rule does not exist,\
+ but attempted to remove it" )
else:
# NOTE: If a bad usage of this function occurs, exit the entire
# test
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index b8a2bd5..9f08e06 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -20,7 +20,6 @@
import pexpect
import re
import traceback
-#import os.path
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -127,7 +126,7 @@
main.cleanup()
main.exit()
- def set_cell( self, cellname ):
+ def setCell( self, cellname ):
"""
Calls 'cell <name>' to set the environment variables on ONOSbench
@@ -140,19 +139,19 @@
main.exit()
else:
self.handle.sendline( "cell " + str( cellname ) )
- # Expect the cellname in the ONOS_CELL variable.
+ # Expect the cellname in the ONOSCELL variable.
# Note that this variable name is subject to change
# and that this driver will have to change accordingly
self.handle.expect( "ONOS_CELL=" + str( cellname ) )
- handle_before = self.handle.before
- handle_after = self.handle.after
+ handleBefore = self.handle.before
+ handleAfter = self.handle.after
# Get the rest of the handle
self.handle.sendline( "" )
self.handle.expect( "\$" )
- handle_more = self.handle.before
+ handleMore = self.handle.before
- main.log.info( "Cell call returned: " + handle_before +
- handle_after + handle_more )
+ main.log.info( "Cell call returned: " + handleBefore +
+ handleAfter + handleMore )
return main.TRUE
@@ -168,17 +167,20 @@
main.cleanup()
main.exit()
- def start_onos_cli( self, ONOS_ip, karafTimeout="" ):
+ def startOnosCli( self, ONOSIp, karafTimeout="" ):
"""
- karafTimeout is an optional arugument. karafTimeout value passed by user would be used to set the
- current karaf shell idle timeout. Note that when ever this property is modified the shell will exit and
+ karafTimeout is an optional arugument. karafTimeout value passed
+ by user would be used to set the current karaf shell idle timeout.
+ Note that when ever this property is modified the shell will exit and
the subsequent login would reflect new idle timeout.
- Below is an example to start a session with 60 seconds idle timeout ( input value is in milliseconds ):
+ Below is an example to start a session with 60 seconds idle timeout
+ ( input value is in milliseconds ):
tValue = "60000"
- main.ONOScli1.start_onos_cli( ONOS_ip, karafTimeout=tValue )
+ main.ONOScli1.startOnosCli( ONOSIp, karafTimeout=tValue )
- Note: karafTimeout is left as str so that this could be read and passed to start_onos_cli from PARAMS file as str.
+ Note: karafTimeout is left as str so that this could be read
+ and passed to startOnosCli from PARAMS file as str.
"""
try:
self.handle.sendline( "" )
@@ -190,42 +192,44 @@
return main.TRUE
# Wait for onos start ( -w ) and enter onos cli
- self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ self.handle.sendline( "onos -w " + str( ONOSIp ) )
i = self.handle.expect( [
"onos>",
pexpect.TIMEOUT ], timeout=60 )
if i == 0:
- main.log.info( str( ONOS_ip ) + " CLI Started successfully" )
+ main.log.info( str( ONOSIp ) + " CLI Started successfully" )
if karafTimeout:
self.handle.sendline(
- "config:property-set -p org.apache.karaf.shell sshIdleTimeout " +
+ "config:property-set -p org.apache.karaf.shel\
+ l sshIdleTimeout " +
karafTimeout )
self.handle.expect( "\$" )
- self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ self.handle.sendline( "onos -w " + str( ONOSIp ) )
self.handle.expect( "onos>" )
return main.TRUE
else:
# If failed, send ctrl+c to process and try again
main.log.info( "Starting CLI failed. Retrying..." )
self.handle.send( "\x03" )
- self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ self.handle.sendline( "onos -w " + str( ONOSIp ) )
i = self.handle.expect( [ "onos>", pexpect.TIMEOUT ],
timeout=30 )
if i == 0:
- main.log.info( str( ONOS_ip ) + " CLI Started " +
+ main.log.info( str( ONOSIp ) + " CLI Started " +
"successfully after retry attempt" )
if karafTimeout:
self.handle.sendline(
- "config:property-set -p org.apache.karaf.shell sshIdleTimeout " +
+ "config:property-set -p org.apache.karaf.shell\
+ sshIdleTimeout " +
karafTimeout )
self.handle.expect( "\$" )
- self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+ self.handle.sendline( "onos -w " + str( ONOSIp ) )
self.handle.expect( "onos>" )
return main.TRUE
else:
main.log.error( "Connection to CLI " +
- str( ONOS_ip ) + " timeout" )
+ str( ONOSIp ) + " timeout" )
return main.FALSE
except pexpect.EOF:
@@ -240,7 +244,7 @@
main.cleanup()
main.exit()
- def sendline( self, cmd_str ):
+ def sendline( self, cmdStr ):
"""
Send a completely user specified string to
the onos> prompt. Use this function if you have
@@ -254,10 +258,10 @@
self.handle.expect( "onos>" )
self.handle.sendline( "log:log \"Sending CLI command: '"
- + cmd_str + "'\"" )
+ + cmdStr + "'\"" )
self.handle.expect( "onos>" )
- self.handle.sendline( cmd_str )
- self.handle.expect( cmd_str )
+ self.handle.sendline( cmdStr )
+ self.handle.expect( cmdStr )
self.handle.expect( "onos>" )
handle = self.handle.before
@@ -265,13 +269,10 @@
self.handle.sendline( "" )
self.handle.expect( "onos>" )
- #handle += self.handle.before
- #handle += self.handle.after
-
- main.log.info( "Command '" + str(cmd_str) + "' sent to "
+ main.log.info( "Command '" + str( cmdStr ) + "' sent to "
+ self.name + "." )
- ansi_escape = re.compile( r'\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handle )
return handle
except pexpect.EOF:
@@ -288,30 +289,30 @@
# IMPORTANT NOTE:
# For all cli commands, naming convention should match
- # the cli command replacing ':' with '_'.
- # Ex ) onos:topology > onos_topology
- # onos:links > onos_links
- # feature:list > feature_list
+ # the cli command changing 'a:b' with 'aB'.
+ # Ex ) onos:topology > onosTopology
+ # onos:links > onosLinks
+ # feature:list > featureList
- def add_node( self, node_id, ONOS_ip, tcp_port="" ):
+ def addNode( self, nodeId, ONOSIp, tcpPort="" ):
"""
Adds a new cluster node by ID and address information.
Required:
- * node_id
- * ONOS_ip
+ * nodeId
+ * ONOSIp
Optional:
- * tcp_port
+ * tcpPort
"""
try:
- cmd_str = "add-node " + str( node_id ) + " " +\
- str( ONOS_ip ) + " " + str( tcp_port )
- handle = self.sendline( cmd_str )
+ cmdStr = "add-node " + str( nodeId ) + " " +\
+ str( ONOSIp ) + " " + str( tcpPort )
+ handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
main.log.error( "Error in adding node" )
main.log.error( handle )
return main.FALSE
else:
- main.log.info( "Node " + str( ONOS_ip ) + " added" )
+ main.log.info( "Node " + str( ONOSIp ) + " added" )
return main.TRUE
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -325,17 +326,17 @@
main.cleanup()
main.exit()
- def remove_node( self, node_id ):
+ def removeNode( self, nodeId ):
"""
Removes a cluster by ID
Issues command: 'remove-node [<node-id>]'
Required:
- * node_id
+ * nodeId
"""
try:
- cmd_str = "remove-node " + str( node_id )
- self.sendline( cmd_str )
+ cmdStr = "remove-node " + str( nodeId )
+ self.sendline( cmdStr )
# TODO: add error checking. Does ONOS give any errors?
return main.TRUE
@@ -359,8 +360,8 @@
Returns: entire handle of list of nodes
"""
try:
- cmd_str = "nodes"
- handle = self.sendline( cmd_str )
+ cmdStr = "nodes"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -381,8 +382,8 @@
"""
try:
# either onos:topology or 'topology' will work in CLI
- cmd_str = "onos:topology"
- handle = self.sendline( cmd_str )
+ cmdStr = "onos:topology"
+ handle = self.sendline( cmdStr )
main.log.info( "onos:topology returned: " + str( handle ) )
return handle
except pexpect.EOF:
@@ -397,14 +398,14 @@
main.cleanup()
main.exit()
- def feature_install( self, feature_str ):
+ def featureInstall( self, featureStr ):
"""
Installs a specified feature
by issuing command: 'onos> feature:install <feature_str>'
"""
try:
- cmd_str = "feature:install " + str( feature_str )
- self.sendline( cmd_str )
+ cmdStr = "feature:install " + str( featureStr )
+ self.sendline( cmdStr )
# TODO: Check for possible error responses from karaf
return main.TRUE
except pexpect.EOF:
@@ -423,14 +424,14 @@
main.cleanup()
main.exit()
- def feature_uninstall( self, feature_str ):
+ def featureUninstall( self, featureStr ):
"""
Uninstalls a specified feature
by issuing command: 'onos> feature:uninstall <feature_str>'
"""
try:
- cmd_str = "feature:uninstall " + str( feature_str )
- self.sendline( cmd_str )
+ cmdStr = "feature:uninstall " + str( featureStr )
+ self.sendline( cmdStr )
# TODO: Check for possible error responses from karaf
return main.TRUE
except pexpect.EOF:
@@ -445,16 +446,16 @@
main.cleanup()
main.exit()
- def devices( self, json_format=True ):
+ def devices( self, jsonFormat=True ):
"""
Lists all infrastructure devices or switches
Optional argument:
- * json_format - boolean indicating if you want output in json
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
- if json_format:
- cmd_str = "devices -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "devices -j"
+ handle = self.sendline( cmdStr )
"""
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
@@ -465,15 +466,15 @@
json.loads would fail with the escape sequence. So we take off
that escape sequence using:
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
"""
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
return handle1
else:
- cmd_str = "devices"
- handle = self.sendline( cmd_str )
+ cmdStr = "devices"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -487,15 +488,15 @@
main.cleanup()
main.exit()
- def balance_masters( self ):
+ def balanceMasters( 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:
- cmd_str = "onos:balance-masters"
- self.sendline( cmd_str )
+ cmdStr = "onos:balance-masters"
+ self.sendline( cmdStr )
# TODO: Check for error responses from ONOS
return main.TRUE
except pexpect.EOF:
@@ -510,16 +511,16 @@
main.cleanup()
main.exit()
- def links( self, json_format=True ):
+ def links( self, jsonFormat=True ):
"""
Lists all core links
Optional argument:
- * json_format - boolean indicating if you want output in json
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
- if json_format:
- cmd_str = "links -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "links -j"
+ handle = self.sendline( cmdStr )
"""
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
@@ -530,15 +531,15 @@
fail with the escape sequence. So we take off that escape
sequence using:
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
"""
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
return handle1
else:
- cmd_str = "links"
- handle = self.sendline( cmd_str )
+ cmdStr = "links"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -552,16 +553,16 @@
main.cleanup()
main.exit()
- def ports( self, json_format=True ):
+ def ports( self, jsonFormat=True ):
"""
Lists all ports
Optional argument:
- * json_format - boolean indicating if you want output in json
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
- if json_format:
- cmd_str = "ports -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "ports -j"
+ handle = self.sendline( cmdStr )
"""
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
@@ -572,16 +573,16 @@
fail with the escape sequence. So we take off that escape
sequence using the following commads:
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
"""
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
return handle1
else:
- cmd_str = "ports"
- handle = self.sendline( cmd_str )
+ cmdStr = "ports"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -595,16 +596,16 @@
main.cleanup()
main.exit()
- def roles( self, json_format=True ):
+ def roles( self, jsonFormat=True ):
"""
Lists all devices and the controllers with roles assigned to them
Optional argument:
- * json_format - boolean indicating if you want output in json
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
- if json_format:
- cmd_str = "roles -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "roles -j"
+ handle = self.sendline( cmdStr )
"""
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
@@ -617,16 +618,16 @@
So we take off that escape sequence using the following
commads:
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
"""
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
return handle1
else:
- cmd_str = "roles"
- handle = self.sendline( cmd_str )
+ cmdStr = "roles"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -640,7 +641,7 @@
main.cleanup()
main.exit()
- def get_role( self, device_id ):
+ def getRole( self, deviceId ):
"""
Given the a string containing the json representation of the "roles"
cli command and a partial or whole device id, returns a json object
@@ -653,15 +654,15 @@
"""
try:
import json
- if device_id is None:
+ if deviceId is None:
return None
else:
- raw_roles = self.roles()
- roles_json = json.loads( raw_roles )
+ rawRoles = self.roles()
+ rolesJson = json.loads( rawRoles )
# search json for the device with id then return the device
- for device in roles_json:
+ for device in rolesJson:
# print device
- if str( device_id ) in device[ 'id' ]:
+ if str( deviceId ) in device[ 'id' ]:
return device
return None
@@ -677,7 +678,7 @@
main.cleanup()
main.exit()
- def roles_not_null( self ):
+ def rolesNotNull( self ):
"""
Iterates through each device and checks if there is a master assigned
Returns: main.TRUE if each device has a master
@@ -685,10 +686,10 @@
"""
try:
import json
- raw_roles = self.roles()
- roles_json = json.loads( raw_roles )
+ rawRoles = self.roles()
+ rolesJson = json.loads( rawRoles )
# search json for the device with id then return the device
- for device in roles_json:
+ for device in rolesJson:
# print device
if device[ 'master' ] == "none":
main.log.warn( "Device has no master: " + str( device ) )
@@ -707,14 +708,14 @@
main.cleanup()
main.exit()
- def paths( self, src_id, dst_id ):
+ def paths( self, srcId, dstId ):
"""
Returns string of paths, and the cost.
Issues command: onos:paths <src> <dst>
"""
try:
- cmd_str = "onos:paths " + str( src_id ) + " " + str( dst_id )
- handle = self.sendline( cmd_str )
+ cmdStr = "onos:paths " + str( srcId ) + " " + str( dstId )
+ handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
main.log.error( "Error in getting paths" )
return ( handle, "Error" )
@@ -734,16 +735,16 @@
main.cleanup()
main.exit()
- def hosts( self, json_format=True ):
+ def hosts( self, jsonFormat=True ):
"""
Lists all discovered hosts
Optional argument:
- * json_format - boolean indicating if you want output in json
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
- if json_format:
- cmd_str = "hosts -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "hosts -j"
+ handle = self.sendline( cmdStr )
"""
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
@@ -754,15 +755,15 @@
fail with the escape sequence. So we take off that escape
sequence using:
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
"""
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
return handle1
else:
- cmd_str = "hosts"
- handle = self.sendline( cmd_str )
+ cmdStr = "hosts"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -776,7 +777,7 @@
main.cleanup()
main.exit()
- def get_host( self, mac ):
+ def getHost( self, mac ):
"""
Return the first host from the hosts api whose 'id' contains 'mac'
@@ -791,10 +792,10 @@
return None
else:
mac = mac
- raw_hosts = self.hosts()
- hosts_json = json.loads( raw_hosts )
+ rawHosts = self.hosts()
+ hostsJson = json.loads( rawHosts )
# search json for the host with mac then return the device
- for host in hosts_json:
+ for host in hostsJson:
# print "%s in %s?" % ( mac, host[ 'id' ] )
if mac in host[ 'id' ]:
return host
@@ -811,13 +812,13 @@
main.cleanup()
main.exit()
- def get_hosts_id( self, host_list ):
+ def getHostsId( self, hostList ):
"""
Obtain list of hosts
Issues command: 'onos> hosts'
Required:
- * host_list: List of hosts obtained by Mininet
+ * hostList: List of hosts obtained by Mininet
IMPORTANT:
This function assumes that you started your
topology with the option '--mac'.
@@ -827,18 +828,18 @@
ONOS format ( 00:00:00:00:00:01/-1 , ... )
"""
try:
- onos_host_list = []
+ onosHostList = []
- for host in host_list:
+ for host in hostList:
host = host.replace( "h", "" )
- host_hex = hex( int( host ) ).zfill( 12 )
- host_hex = str( host_hex ).replace( 'x', '0' )
- i = iter( str( host_hex ) )
- host_hex = ":".join( a + b for a, b in zip( i, i ) )
- host_hex = host_hex + "/-1"
- onos_host_list.append( host_hex )
+ hostHex = hex( int( host ) ).zfill( 12 )
+ hostHex = str( hostHex ).replace( 'x', '0' )
+ i = iter( str( hostHex ) )
+ hostHex = ":".join( a + b for a, b in zip( i, i ) )
+ hostHex = hostHex + "/-1"
+ onosHostList.append( hostHex )
- return onos_host_list
+ return onosHostList
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -852,21 +853,21 @@
main.cleanup()
main.exit()
- def add_host_intent( self, host_id_one, host_id_two ):
+ def addHostIntent( self, hostIdOne, hostIdTwo ):
"""
Required:
- * host_id_one: ONOS host id for host1
- * host_id_two: ONOS host id for host2
+ * hostIdOne: ONOS host id for host1
+ * hostIdTwo: ONOS host id for host2
Description:
Adds a host-to-host intent ( bidrectional ) by
specifying the two hosts.
"""
try:
- cmd_str = "add-host-intent " + str( host_id_one ) +\
- " " + str( host_id_two )
- handle = self.sendline( cmd_str )
+ cmdStr = "add-host-intent " + str( hostIdOne ) +\
+ " " + str( hostIdTwo )
+ handle = self.sendline( cmdStr )
main.log.info( "Host intent installed between " +
- str( host_id_one ) + " and " + str( host_id_two ) )
+ str( hostIdOne ) + " and " + str( hostIdTwo ) )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -880,18 +881,18 @@
main.cleanup()
main.exit()
- def add_optical_intent( self, ingress_device, egress_device ):
+ def addOpticalIntent( self, ingressDevice, egressDevice ):
"""
Required:
- * ingress_device: device id of ingress device
- * egress_device: device id of egress device
+ * ingressDevice: device id of ingress device
+ * egressDevice: device id of egress device
Optional:
TODO: Still needs to be implemented via dev side
"""
try:
- cmd_str = "add-optical-intent " + str( ingress_device ) +\
- " " + str( egress_device )
- handle = self.sendline( cmd_str )
+ cmdStr = "add-optical-intent " + str( ingressDevice ) +\
+ " " + str( egressDevice )
+ handle = self.sendline( cmdStr )
# If error, return error message
if re.search( "Error", handle ):
return handle
@@ -909,17 +910,17 @@
main.cleanup()
main.exit()
- def add_point_intent(
+ def addPointIntent(
self,
- ingress_device,
- egress_device,
- port_ingress="",
- port_egress="",
+ ingressDevice,
+ egressDevice,
+ portIngress="",
+ portEgress="",
ethType="",
ethSrc="",
ethDst="",
bandwidth="",
- lambda_alloc=False,
+ lambdaAlloc=False,
ipProto="",
ipSrc="",
ipDst="",
@@ -927,14 +928,14 @@
tcpDst="" ):
"""
Required:
- * ingress_device: device id of ingress device
- * egress_device: device id of egress device
+ * ingressDevice: device id of ingress device
+ * egressDevice: device id of egress device
Optional:
* ethType: specify ethType
* ethSrc: specify ethSrc ( i.e. src mac addr )
* ethDst: specify ethDst ( i.e. dst mac addr )
* bandwidth: specify bandwidth capacity of link
- * lambda_alloc: if True, intent will allocate lambda
+ * lambdaAlloc: if True, intent will allocate lambda
for the specified intent
* ipProto: specify ip protocol
* ipSrc: specify ip source address
@@ -954,7 +955,7 @@
# If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
- and not bandwidth and not lambda_alloc \
+ and not bandwidth and not lambdaAlloc \
and not ipProto and not ipSrc and not ipDst \
and not tcpSrc and not tcpDst:
cmd = "add-point-intent"
@@ -970,7 +971,7 @@
cmd += " --ethDst " + str( ethDst )
if bandwidth:
cmd += " --bandwidth " + str( bandwidth )
- if lambda_alloc:
+ if lambdaAlloc:
cmd += " --lambda "
if ipProto:
cmd += " --ipProto " + str( ipProto )
@@ -985,30 +986,30 @@
# Check whether the user appended the port
# or provided it as an input
- if "/" in ingress_device:
- cmd += " " + str( ingress_device )
+ if "/" in ingressDevice:
+ cmd += " " + str( ingressDevice )
else:
- if not port_ingress:
+ if not portIngress:
main.log.error( "You must specify " +
"the ingress port" )
# TODO: perhaps more meaningful return
return main.FALSE
cmd += " " + \
- str( ingress_device ) + "/" +\
- str( port_ingress ) + " "
+ str( ingressDevice ) + "/" +\
+ str( portIngress ) + " "
- if "/" in egress_device:
- cmd += " " + str( egress_device )
+ if "/" in egressDevice:
+ cmd += " " + str( egressDevice )
else:
- if not port_egress:
+ if not portEgress:
main.log.error( "You must specify " +
"the egress port" )
return main.FALSE
cmd += " " +\
- str( egress_device ) + "/" +\
- str( port_egress )
+ str( egressDevice ) + "/" +\
+ str( portEgress )
handle = self.sendline( cmd )
if re.search( "Error", handle ):
@@ -1028,18 +1029,18 @@
main.cleanup()
main.exit()
- def add_multipoint_to_singlepoint_intent(
+ def addMultipointToSinglepointIntent(
self,
- ingress_device1,
- ingress_device2,
- egress_device,
- port_ingress="",
- port_egress="",
+ ingressDevice1,
+ ingressDevice2,
+ egressDevice,
+ portIngress="",
+ portEgress="",
ethType="",
ethSrc="",
ethDst="",
bandwidth="",
- lambda_alloc=False,
+ lambdaAlloc=False,
ipProto="",
ipSrc="",
ipDst="",
@@ -1053,15 +1054,15 @@
one egress device. For more number of ingress devices, this
function needs to be modified
Required:
- * ingress_device1: device id of ingress device1
- * ingress_device2: device id of ingress device2
- * egress_device: device id of egress device
+ * ingressDevice1: device id of ingress device1
+ * ingressDevice2: device id of ingress device2
+ * egressDevice: device id of egress device
Optional:
* ethType: specify ethType
* ethSrc: specify ethSrc ( i.e. src mac addr )
* ethDst: specify ethDst ( i.e. dst mac addr )
* bandwidth: specify bandwidth capacity of link
- * lambda_alloc: if True, intent will allocate lambda
+ * lambdaAlloc: if True, intent will allocate lambda
for the specified intent
* ipProto: specify ip protocol
* ipSrc: specify ip source address
@@ -1083,7 +1084,7 @@
# If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
- and not bandwidth and not lambda_alloc\
+ and not bandwidth and not lambdaAlloc\
and not ipProto and not ipSrc and not ipDst\
and not tcpSrc and not tcpDst and not setEthSrc\
and not setEthDst:
@@ -1100,7 +1101,7 @@
cmd += " --ethDst " + str( ethDst )
if bandwidth:
cmd += " --bandwidth " + str( bandwidth )
- if lambda_alloc:
+ if lambdaAlloc:
cmd += " --lambda "
if ipProto:
cmd += " --ipProto " + str( ipProto )
@@ -1119,43 +1120,43 @@
# Check whether the user appended the port
# or provided it as an input
- if "/" in ingress_device1:
- cmd += " " + str( ingress_device1 )
+ if "/" in ingressDevice1:
+ cmd += " " + str( ingressDevice1 )
else:
- if not port_ingress1:
+ if not portIngress1:
main.log.error( "You must specify " +
"the ingress port1" )
# TODO: perhaps more meaningful return
return main.FALSE
cmd += " " + \
- str( ingress_device1 ) + "/" +\
- str( port_ingress1 ) + " "
+ str( ingressDevice1 ) + "/" +\
+ str( portIngress1 ) + " "
- if "/" in ingress_device2:
- cmd += " " + str( ingress_device2 )
+ if "/" in ingressDevice2:
+ cmd += " " + str( ingressDevice2 )
else:
- if not port_ingress2:
+ if not portIngress2:
main.log.error( "You must specify " +
"the ingress port2" )
# TODO: perhaps more meaningful return
return main.FALSE
cmd += " " + \
- str( ingress_device2 ) + "/" +\
- str( port_ingress2 ) + " "
+ str( ingressDevice2 ) + "/" +\
+ str( portIngress2 ) + " "
- if "/" in egress_device:
- cmd += " " + str( egress_device )
+ if "/" in egressDevice:
+ cmd += " " + str( egressDevice )
else:
- if not port_egress:
+ if not portEgress:
main.log.error( "You must specify " +
"the egress port" )
return main.FALSE
cmd += " " +\
- str( egress_device ) + "/" +\
- str( port_egress )
+ str( egressDevice ) + "/" +\
+ str( portEgress )
print "cmd= ", cmd
handle = self.sendline( cmd )
if re.search( "Error", handle ):
@@ -1175,7 +1176,7 @@
main.cleanup()
main.exit()
- def remove_intent( self, intent_id ):
+ def removeIntent( self, intentId ):
"""
Remove intent for specified intent id
@@ -1184,8 +1185,8 @@
cli output otherwise
"""
try:
- cmd_str = "remove-intent " + str( intent_id )
- handle = self.sendline( cmd_str )
+ cmdStr = "remove-intent " + str( intentId )
+ handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
main.log.error( "Error in removing intent" )
return main.FALSE
@@ -1204,24 +1205,24 @@
main.cleanup()
main.exit()
- def routes( self, json_format=False ):
+ def routes( self, jsonFormat=False ):
"""
NOTE: This method should be used after installing application:
onos-app-sdnip
Optional:
- * json_format: enable output formatting in json
+ * jsonFormat: enable output formatting in json
Description:
Obtain all routes in the system
"""
try:
- if json_format:
- cmd_str = "routes -j"
- handle_tmp = self.sendline( cmd_str )
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle_tmp )
+ if jsonFormat:
+ cmdStr = "routes -j"
+ handleTmp = self.sendline( cmdStr )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handleTmp )
else:
- cmd_str = "routes"
- handle = self.sendline( cmd_str )
+ cmdStr = "routes"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1235,22 +1236,22 @@
main.cleanup()
main.exit()
- def intents( self, json_format=True ):
+ def intents( self, jsonFormat=True ):
"""
Optional:
- * json_format: enable output formatting in json
+ * jsonFormat: enable output formatting in json
Description:
Obtain intents currently installed
"""
try:
- if json_format:
- cmd_str = "intents -j"
- handle = self.sendline( cmd_str )
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle )
+ if jsonFormat:
+ cmdStr = "intents -j"
+ handle = self.sendline( cmdStr )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handle )
else:
- cmd_str = "intents"
- handle = self.sendline( cmd_str )
+ cmdStr = "intents"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1264,22 +1265,22 @@
main.cleanup()
main.exit()
- def flows( self, json_format=True ):
+ def flows( self, jsonFormat=True ):
"""
Optional:
- * json_format: enable output formatting in json
+ * jsonFormat: enable output formatting in json
Description:
Obtain flows currently installed
"""
try:
- if json_format:
- cmd_str = "flows -j"
- handle = self.sendline( cmd_str )
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle )
+ if jsonFormat:
+ cmdStr = "flows -j"
+ handle = self.sendline( cmdStr )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handle )
else:
- cmd_str = "flows"
- handle = self.sendline( cmd_str )
+ cmdStr = "flows"
+ handle = self.sendline( cmdStr )
if re.search( "Error\sexecuting\scommand:", handle ):
main.log.error( self.name + ".flows() response: " +
str( handle ) )
@@ -1296,40 +1297,38 @@
main.cleanup()
main.exit()
- def push_test_intents( self, dpid_src, dpid_dst, num_intents,
- num_mult="", app_id="", report=True ):
+ def pushTestIntents( self, dpidSrc, dpidDst, numIntents,
+ numMult="", appId="", report=True ):
"""
Description:
Push a number of intents in a batch format to
a specific point-to-point intent definition
Required:
- * dpid_src: specify source dpid
- * dpid_dst: specify destination dpid
- * num_intents: specify number of intents to push
+ * dpidSrc: specify source dpid
+ * dpidDst: specify destination dpid
+ * numIntents: specify number of intents to push
Optional:
- * num_mult: number multiplier for multiplying
+ * numMult: number multiplier for multiplying
the number of intents specified
- * app_id: specify the application id init to further
+ * appId: specify the application id init to further
modularize the intents
* report: default True, returns latency information
"""
try:
cmd = "push-test-intents " +\
- str( dpid_src ) + " " + str( dpid_dst ) + " " +\
- str( num_intents )
- if num_mult:
- cmd += " " + str( num_mult )
- # If app id is specified, then num_mult
+ str( dpidSrc ) + " " + str( dpidDst ) + " " +\
+ str( numIntents )
+ if numMult:
+ cmd += " " + str( numMult )
+ # If app id is specified, then numMult
# must exist because of the way this command
- #takes in arguments
- if app_id:
- cmd += " " + str( app_id )
+ if appId:
+ cmd += " " + str( appId )
handle = self.sendline( cmd )
- # Some color thing that we want to escape
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handle )
if report:
- lat_result = []
+ latResult = []
main.log.info( handle )
# Split result by newline
newline = handle.split( "\r\r\n" )
@@ -1339,9 +1338,9 @@
for result in newline:
result = result.split( ": " )
# Append the first result of second parse
- lat_result.append( result[ 1 ].split( " " )[ 0 ] )
- main.log.info( lat_result )
- return lat_result
+ latResult.append( result[ 1 ].split( " " )[ 0 ] )
+ main.log.info( latResult )
+ return latResult
else:
return main.TRUE
except pexpect.EOF:
@@ -1356,22 +1355,22 @@
main.cleanup()
main.exit()
- def intents_events_metrics( self, json_format=True ):
+ def intentsEventsMetrics( self, jsonFormat=True ):
"""
Description:Returns topology metrics
Optional:
- * json_format: enable json formatting of output
+ * jsonFormat: enable json formatting of output
"""
try:
- if json_format:
- cmd_str = "intents-events-metrics -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "intents-events-metrics -j"
+ handle = self.sendline( cmdStr )
# Some color thing that we want to escape
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handle )
else:
- cmd_str = "intents-events-metrics"
- handle = self.sendline( cmd_str )
+ cmdStr = "intents-events-metrics"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1385,22 +1384,22 @@
main.cleanup()
main.exit()
- def topology_events_metrics( self, json_format=True ):
+ def topologyEventsMetrics( self, jsonFormat=True ):
"""
Description:Returns topology metrics
Optional:
- * json_format: enable json formatting of output
+ * jsonFormat: enable json formatting of output
"""
try:
- if json_format:
- cmd_str = "topology-events-metrics -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "topology-events-metrics -j"
+ handle = self.sendline( cmdStr )
# Some color thing that we want to escape
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle = ansiEscape.sub( '', handle )
else:
- cmd_str = "topology-events-metrics"
- handle = self.sendline( cmd_str )
+ cmdStr = "topology-events-metrics"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1421,37 +1420,37 @@
# a normal driver function, and parse it
# using a wrapper function
- def get_all_intents_id( self ):
+ def getAllIntentsId( self ):
"""
Description:
Obtain all intent id's in a list
"""
try:
# Obtain output of intents function
- intents_str = self.intents()
- all_intent_list = []
- intent_id_list = []
+ intentsStr = self.intents()
+ allIntentList = []
+ intentIdList = []
# Parse the intents output for ID's
- intents_list = [ s.strip() for s in intents_str.splitlines() ]
- for intents in intents_list:
+ intentsList = [ s.strip() for s in intentsStr.splitlines() ]
+ for intents in intentsList:
if "onos>" in intents:
continue
elif "intents" in intents:
continue
else:
- line_list = intents.split( " " )
- all_intent_list.append( line_list[ 0 ] )
+ lineList = intents.split( " " )
+ allIntentList.append( lineList[ 0 ] )
- all_intent_list = all_intent_list[ 1:-2 ]
+ allIntentList = allIntentList[ 1:-2 ]
- for intents in all_intent_list:
+ for intents in allIntentList:
if not intents:
continue
else:
- intent_id_list.append( intents )
+ intentIdList.append( intents )
- return intent_id_list
+ return intentIdList
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1465,7 +1464,7 @@
main.cleanup()
main.exit()
- def get_all_devices_id( self ):
+ def getAllDevicesId( self ):
"""
Use 'devices' function to obtain list of all devices
and parse the result to obtain a list of all device
@@ -1480,23 +1479,23 @@
"""
try:
# Call devices and store result string
- devices_str = self.devices( json_format=False )
- id_list = []
+ devicesStr = self.devices( jsonFormat=False )
+ idList = []
- if not devices_str:
+ if not devicesStr:
main.log.info( "There are no devices to get id from" )
- return id_list
+ return idList
# Split the string into list by comma
- device_list = devices_str.split( "," )
+ deviceList = devicesStr.split( "," )
# Get temporary list of all arguments with string 'id='
- temp_list = [ dev for dev in device_list if "id=" in dev ]
+ tempList = [ dev for dev in deviceList if "id=" in dev ]
# Split list further into arguments before and after string
# 'id='. Get the latter portion ( the actual device id ) and
- # append to id_list
- for arg in temp_list:
- id_list.append( arg.split( "id=" )[ 1 ] )
- return id_list
+ # append to idList
+ for arg in tempList:
+ idList.append( arg.split( "id=" )[ 1 ] )
+ return idList
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1510,7 +1509,7 @@
main.cleanup()
main.exit()
- def get_all_nodes_id( self ):
+ def getAllNodesId( self ):
"""
Uses 'nodes' function to obtain list of all nodes
and parse the result of nodes to obtain just the
@@ -1519,23 +1518,23 @@
list of node id's
"""
try:
- nodes_str = self.nodes()
- id_list = []
+ nodesStr = self.nodes()
+ idList = []
- if not nodes_str:
+ if not nodesStr:
main.log.info( "There are no nodes to get id from" )
- return id_list
+ return idList
- # Sample nodes_str output
+ # Sample nodesStr output
# id=local, address=127.0.0.1:9876, state=ACTIVE *
# Split the string into list by comma
- nodes_list = nodes_str.split( "," )
- temp_list = [ node for node in nodes_list if "id=" in node ]
- for arg in temp_list:
- id_list.append( arg.split( "id=" )[ 1 ] )
+ nodesList = nodesStr.split( "," )
+ tempList = [ node for node in nodesList if "id=" in node ]
+ for arg in tempList:
+ idList.append( arg.split( "id=" )[ 1 ] )
- return id_list
+ return idList
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1549,7 +1548,7 @@
main.cleanup()
main.exit()
- def get_device( self, dpid=None ):
+ def getDevice( self, dpid=None ):
"""
Return the first device from the devices api whose 'id' contains 'dpid'
Return None if there is no match
@@ -1560,10 +1559,10 @@
return None
else:
dpid = dpid.replace( ':', '' )
- raw_devices = self.devices()
- devices_json = json.loads( raw_devices )
+ rawDevices = self.devices()
+ devicesJson = json.loads( rawDevices )
# search json for the device with dpid then return the device
- for device in devices_json:
+ for device in devicesJson:
# print "%s in %s?" % ( dpid, device[ 'id' ] )
if dpid in device[ 'id' ]:
return device
@@ -1580,7 +1579,7 @@
main.cleanup()
main.exit()
- def check_status( self, ip, numoswitch, numolink, log_level="info" ):
+ def checkStatus( self, ip, numoswitch, numolink, logLevel="info" ):
"""
Checks the number of swithes & links that ONOS sees against the
supplied values. By default this will report to main.log, but the
@@ -1589,17 +1588,18 @@
Params: ip = ip used for the onos cli
numoswitch = expected number of switches
numlink = expected number of links
- log_level = level to log to. Currently accepts 'info', 'warn' and 'report'
+ logLevel = level to log to. Currently accepts
+ 'info', 'warn' and 'report'
- log_level can
+ logLevel can
Returns: main.TRUE if the number of switchs and links are correct,
main.FALSE if the numer of switches and links is incorrect,
and main.ERROR otherwise
"""
try:
- topology = self.get_topology( ip )
+ topology = self.getTopology( ip )
if topology == {}:
return main.ERROR
output = ""
@@ -1608,23 +1608,26 @@
links = topology.get( 'links', False )
if devices == False or links == False:
return main.ERROR
- switch_check = ( int( devices ) == int( numoswitch ) )
+ switchCheck = ( int( devices ) == int( numoswitch ) )
# Is the number of links is what we expected
- link_check = ( int( links ) == int( numolink ) )
- if ( switch_check and link_check ):
+ linkCheck = ( int( links ) == int( numolink ) )
+ if ( switchCheck and linkCheck ):
# We expected the correct numbers
output = output + "The number of links and switches match "\
+ "what was expected"
result = main.TRUE
else:
output = output + \
- "The number of links and switches does not match what was expected"
+ "The number of links and switches does not matc\
+ h what was expected"
result = main.FALSE
- output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)" % (
- int( devices ), int( numoswitch ), int( links ), int( numolink ) )
- if log_level == "report":
+ output = output + "\n ONOS sees %i devices (%i expected) \
+ and %i links (%i expected)" % (
+ int( devices ), int( numoswitch ), int( links ),
+ int( numolink ) )
+ if logLevel == "report":
main.log.report( output )
- elif log_level == "warn":
+ elif logLevel == "warn":
main.log.warn( output )
else:
main.log.info( output )
@@ -1641,11 +1644,11 @@
main.cleanup()
main.exit()
- def device_role( self, device_id, onos_node, role="master" ):
+ def deviceRole( self, deviceId, onosNode, role="master" ):
"""
Calls the device-role cli command.
- device_id must be the id of a device as seen in the onos devices command
- onos_node is the ip of one of the onos nodes in the cluster
+ deviceId must be the id of a device as seen in the onos devices command
+ onosNode is the ip of one of the onos nodes in the cluster
role must be either master, standby, or none
Returns:
@@ -1655,11 +1658,11 @@
try:
if role.lower() == "master" or role.lower() == "standby" or\
role.lower() == "none":
- cmd_str = "device-role " +\
- str( device_id ) + " " +\
- str( onos_node ) + " " +\
+ cmdStr = "device-role " +\
+ str( deviceId ) + " " +\
+ str( onosNode ) + " " +\
str( role )
- handle = self.sendline( cmd_str )
+ handle = self.sendline( cmdStr )
if re.search( "Error", handle ):
# end color output to escape any colours
# from the cli
@@ -1683,35 +1686,35 @@
main.cleanup()
main.exit()
- def clusters( self, json_format=True ):
+ def clusters( self, jsonFormat=True ):
"""
Lists all clusters
Optional argument:
- * json_format - boolean indicating if you want output in json
+ * jsonFormat - boolean indicating if you want output in json
"""
try:
- if json_format:
- cmd_str = "clusters -j"
- handle = self.sendline( cmd_str )
+ if jsonFormat:
+ cmdStr = "clusters -j"
+ handle = self.sendline( cmdStr )
"""
handle variable here contains some ANSI escape color code
sequences at the end which are invisible in the print command
output. To make that escape sequence visible, use repr()
function. The repr( handle ) output when printed shows the ANSI
escape sequences. In json.loads( somestring ), this somestring
- variable is actually repr( somestring ) and json.loads would fail
- with the escape sequence. So we take off that escape sequence
- using:
+ variable is actually repr( somestring ) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using:
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
"""
- ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
- handle1 = ansi_escape.sub( '', handle )
+ ansiEscape = re.compile( r'\r\r\n\x1b[^m]*m' )
+ handle1 = ansiEscape.sub( '', handle )
return handle1
else:
- cmd_str = "clusters"
- handle = self.sendline( cmd_str )
+ cmdStr = "clusters"
+ handle = self.sendline( cmdStr )
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1725,7 +1728,7 @@
main.cleanup()
main.exit()
- def election_test_leader( self ):
+ def electionTestLeader( self ):
"""
CLI command to get the current leader for the Election test application
NOTE: Requires installation of the onos-app-election feature
@@ -1734,22 +1737,22 @@
Main.FALSE on error
"""
try:
- cmd_str = "election-test-leader"
- response = self.sendline( cmd_str )
+ cmdStr = "election-test-leader"
+ response = self.sendline( cmdStr )
# Leader
leaderPattern = "The\scurrent\sleader\sfor\sthe\sElection\s" +\
"app\sis\s(?P<node>.+)\."
- node_search = re.search( leaderPattern, response )
- if node_search:
- node = node_search.group( 'node' )
+ nodeSearch = re.search( leaderPattern, response )
+ if nodeSearch:
+ node = nodeSearch.group( 'node' )
main.log.info( "Election-test-leader on " + str( self.name ) +
" found " + node + " as the leader" )
return node
# no leader
nullPattern = "There\sis\scurrently\sno\sleader\selected\sfor\s" +\
"the\sElection\sapp"
- null_search = re.search( nullPattern, response )
- if null_search:
+ nullSearch = re.search( nullPattern, response )
+ if nullSearch:
main.log.info( "Election-test-leader found no leader on " +
self.name )
return None
@@ -1776,7 +1779,7 @@
main.cleanup()
main.exit()
- def election_test_run( self ):
+ def electionTestRun( self ):
"""
CLI command to run for leadership of the Election test application.
NOTE: Requires installation of the onos-app-election feature
@@ -1784,8 +1787,8 @@
Main.FALSE on error
"""
try:
- cmd_str = "election-test-run"
- response = self.sendline( cmd_str )
+ cmdStr = "election-test-run"
+ response = self.sendline( cmdStr )
# success
successPattern = "Entering\sleadership\selections\sfor\sthe\s" +\
"Election\sapp."
@@ -1816,7 +1819,7 @@
main.cleanup()
main.exit()
- def election_test_withdraw( self ):
+ def electionTestWithdraw( self ):
"""
* CLI command to withdraw the local node from leadership election for
* the Election test application.
@@ -1825,8 +1828,8 @@
Main.FALSE on error
"""
try:
- cmd_str = "election-test-withdraw"
- response = self.sendline( cmd_str )
+ cmdStr = "election-test-withdraw"
+ response = self.sendline( cmdStr )
# success
successPattern = "Withdrawing\sfrom\sleadership\selections\sfor" +\
"\sthe\sElection\sapp."
@@ -1856,15 +1859,14 @@
main.cleanup()
main.exit()
- #***********************************
def getDevicePortsEnabledCount( self, dpid ):
"""
Get the count of all enabled ports on a particular device/switch
"""
try:
dpid = str( dpid )
- cmd_str = "onos:ports -e " + dpid + " | wc -l"
- output = self.sendline( cmd_str )
+ cmdStr = "onos:ports -e " + dpid + " | wc -l"
+ output = self.sendline( cmdStr )
if re.search( "No such device", output ):
main.log.error( "Error in getting ports" )
return ( output, "Error" )
@@ -1888,8 +1890,8 @@
"""
try:
dpid = str( dpid )
- cmd_str = "onos:links " + dpid + " | grep ACTIVE | wc -l"
- output = self.sendline( cmd_str )
+ cmdStr = "onos:links " + dpid + " | grep ACTIVE | wc -l"
+ output = self.sendline( cmdStr )
if re.search( "No such device", output ):
main.log.error( "Error in getting ports " )
return ( output, "Error " )
@@ -1912,8 +1914,8 @@
Return a list of all Intent IDs
"""
try:
- cmd_str = "onos:intents | grep id="
- output = self.sendline( cmd_str )
+ cmdStr = "onos:intents | grep id="
+ output = self.sendline( cmdStr )
if re.search( "Error", output ):
main.log.error( "Error in getting ports" )
return ( output, "Error" )
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 58ba929..a9a5a03 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -49,10 +49,10 @@
self.name = self.options[ 'name' ]
self.handle = super( OnosDriver, self ).connect(
user_name=self.user_name,
- ip_address=self.ip_address,
- port=self.port,
- pwd=self.pwd,
- home=self.home )
+ ip_address=self.ip_address,
+ port=self.port,
+ pwd=self.pwd,
+ home=self.home )
self.handle.sendline( "cd " + self.home )
self.handle.expect( "\$" )
@@ -67,12 +67,9 @@
main.cleanup()
main.exit()
except:
- main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 30 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 30 )
main.cleanup()
main.exit()
@@ -94,7 +91,7 @@
response = main.FALSE
return response
- def onos_package( self ):
+ def onosPackage( self ):
"""
Produce a self-contained tar.gz file that can be deployed
and executed on any platform with Java 7 JRE.
@@ -119,7 +116,7 @@
main.cleanup()
main.exit()
- def onos_build( self ):
+ def onosBuild( self ):
"""
Use the pre defined script to build onos via mvn
"""
@@ -127,10 +124,10 @@
self.handle.sendline( "onos-build" )
self.handle.expect( "onos-build" )
i = self.handle.expect( [
- "BUILD SUCCESS",
- "ERROR",
- "BUILD FAILED" ],
- timeout=120 )
+ "BUILD SUCCESS",
+ "ERROR",
+ "BUILD FAILED" ],
+ timeout=120 )
handle = str( self.handle.before )
main.log.info( "onos-build command returned: " +
@@ -149,7 +146,7 @@
main.cleanup()
main.exit()
- def clean_install( self ):
+ def cleanInstall( self ):
"""
Runs mvn clean install in the root of the ONOS directory.
This will clean all ONOS artifacts then compile each module
@@ -158,7 +155,8 @@
On Failure, exits the test
"""
try:
- main.log.info( "Running 'mvn clean install' on " + str( self.name ) +
+ main.log.info( "Running 'mvn clean install' on " +
+ str( self.name ) +
". This may take some time." )
self.handle.sendline( "cd " + self.home )
self.handle.expect( "\$" )
@@ -216,26 +214,23 @@
main.cleanup()
main.exit()
except:
- main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 60 )
main.cleanup()
main.exit()
- def git_pull( self, comp1="" ):
+ def gitPull( self, comp1="" ):
"""
Assumes that "git pull" works without login
This function will perform a git pull on the ONOS instance.
- If used as git_pull( "NODE" ) it will do git pull + NODE. This is
+ If used as gitPull( "NODE" ) it will do git pull + NODE. This is
for the purpose of pulling from other nodes if necessary.
Otherwise, this function will perform a git pull in the
ONOS repository. If it has any problems, it will return main.ERROR
- If it successfully does a git_pull, it will return a 1 ( main.TRUE )
+ If it successfully does a gitPull, it will return a 1 ( main.TRUE )
If it has no updates, it will return 3.
"""
@@ -249,19 +244,24 @@
else:
self.handle.sendline( "git pull " + comp1 )
- i = self.handle.expect( [ 'fatal',
- 'Username\sfor\s(.*):\s',
- '\sfile(s*) changed,\s',
- 'Already up-to-date',
- 'Aborting',
- 'You\sare\snot\scurrently\son\sa\sbranch',
- 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou',
- 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles',
- pexpect.TIMEOUT ],
- timeout=300 )
+ i = self.handle.expect(
+ [
+ 'fatal',
+ 'Username\sfor\s(.*):\s',
+ '\sfile(s*) changed,\s',
+ 'Already up-to-date',
+ 'Aborting',
+ 'You\sare\snot\scurrently\son\sa\sbranch',
+ 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\
+ \sbranch\syou',
+ 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\
+ \sfiles',
+ pexpect.TIMEOUT ],
+ timeout=300 )
# debug
- # main.log.report( self.name +": DEBUG: \n"+"git pull response: " +
- # str( self.handle.before ) + str( self.handle.after ) )
+ # main.log.report( self.name +": DEBUG: \n"+
+ # "git pull response: " +
+ # str( self.handle.before ) + str( self.handle.after ) )
if i == 0:
main.log.error( self.name + ": Git pull had some issue..." )
return main.ERROR
@@ -275,29 +275,35 @@
self.name +
": Git Pull - pulling repository now" )
self.handle.expect( "ONOS\$", 120 )
- return main.TRUE # So that only when git pull is done, we do mvn clean compile
+ # So that only when git pull is done, we do mvn clean compile
+ return main.TRUE
elif i == 3:
main.log.info( self.name + ": Git Pull - Already up to date" )
return i
elif i == 4:
main.log.info(
self.name +
- ": Git Pull - Aborting... Are there conflicting git files?" )
+ ": Git Pull - Aborting...\
+ Are there conflicting git files?" )
return main.ERROR
elif i == 5:
main.log.info(
self.name +
- ": Git Pull - You are not currently on a branch so git pull failed!" )
+ ": Git Pull - You are not currently\
+ on a branch so git pull failed!" )
return main.ERROR
elif i == 6:
main.log.info(
self.name +
- ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!" )
+ ": Git Pull - You have not configured\
+ an upstream branch to pull from\
+ . Git pull failed!" )
return main.ERROR
elif i == 7:
main.log.info(
self.name +
- ": Git Pull - Pull is not possible because you have unmerged files." )
+ ": Git Pull - Pull is not possible\
+ because you have unmerged files." )
return main.ERROR
elif i == 8:
main.log.error( self.name + ": Git Pull - TIMEOUT" )
@@ -316,21 +322,19 @@
main.cleanup()
main.exit()
except:
- main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 80 )
main.cleanup()
main.exit()
- def git_checkout( self, branch="master" ):
+ def gitCheckout( self, branch="master" ):
"""
Assumes that "git pull" works without login
This function will perform a git git checkout on the ONOS instance.
- If used as git_checkout( "branch" ) it will do git checkout of the "branch".
+ If used as gitCheckout( "branch" ) it will do git checkout
+ of the "branch".
Otherwise, this function will perform a git checkout of the master
branch of the ONOS repository. If it has any problems, it will return
@@ -350,14 +354,18 @@
cmd = "git checkout " + branch
self.handle.sendline( cmd )
self.handle.expect( cmd )
- i = self.handle.expect( [ 'fatal',
- 'Username\sfor\s(.*):\s',
- 'Already\son\s\'',
- 'Switched\sto\sbranch\s\'' +
- str( branch ),
- pexpect.TIMEOUT,
- 'error: Your local changes to the following files would be overwritten by checkout:',
- 'error: you need to resolve your current index first' ], timeout=60 )
+ i = self.handle.expect(
+ [
+ 'fatal',
+ 'Username\sfor\s(.*):\s',
+ 'Already\son\s\'',
+ 'Switched\sto\sbranch\s\'' +
+ str( branch ),
+ pexpect.TIMEOUT,
+ 'error: Your local changes to the following files\
+ would be overwritten by checkout:',
+ 'error: you need to resolve your current index first' ],
+ timeout=60 )
if i == 0:
main.log.error(
@@ -366,9 +374,11 @@
main.log.error( self.name + ": " + self.handle.before )
return main.ERROR
elif i == 1:
- main.log.error( self.name + ": Git checkout asking for username."
- + " Please configure your local git repository to be able "
- + "to access your remote repository passwordlessly" )
+ main.log.error(
+ self.name +
+ ": Git checkout asking for username." +
+ " Please configure your local git repository to be able " +
+ "to access your remote repository passwordlessly" )
return main.ERROR
elif i == 2:
main.log.info(
@@ -396,21 +406,28 @@
return main.ERROR
elif i == 5:
self.handle.expect( "Aborting" )
- main.log.error( self.name + ": Git checkout error: \n" +
- "Your local changes to the following files would be overwritten by checkout:" +
- str( self.handle.before ) )
+ main.log.error(
+ self.name +
+ ": Git checkout error: \n" +
+ "Your local changes to the following\
+ files would be overwritten by checkout:" +
+ str(
+ self.handle.before ) )
self.handle.expect( "ONOS\$" )
return main.ERROR
elif i == 6:
- main.log.error( self.name + ": Git checkout error: \n" +
- "You need to resolve your current index first:" +
+ main.log.error( self.name +
+ ": Git checkout error: \n" +
+ "You need to resolve your\
+ current index first:" +
str( self.handle.before ) )
self.handle.expect( "ONOS\$" )
return main.ERROR
else:
main.log.error(
self.name +
- ": Git Checkout - Unexpected response, check for pull errors" )
+ ": Git Checkout - Unexpected response,\
+ check for pull errors" )
main.log.error( self.name + ": " + self.handle.before )
return main.ERROR
@@ -420,18 +437,16 @@
main.cleanup()
main.exit()
except:
- main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 80 )
main.cleanup()
main.exit()
- def get_version( self, report=False ):
+ def getVersion( self, report=False ):
"""
- 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( "" )
@@ -439,7 +454,8 @@
self.handle.sendline(
"cd " +
self.home +
- "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never" )
+ "; git log -1 --pretty=fuller --decorate=short | grep -A 6\
+ \"commit\" --color=never" )
# NOTE: for some reason there are backspaces inserted in this
# phrase when run from Jenkins on some tests
self.handle.expect( "never" )
@@ -471,76 +487,73 @@
main.cleanup()
main.exit()
except:
- main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( ":" * 80 )
main.cleanup()
main.exit()
- def create_cell_file( self, bench_ip, file_name, mn_ip_addrs,
- extra_feature_string, *onos_ip_addrs ):
+ def createCellFile( self, benchIp, fileName, mnIpAddrs,
+ extraFeatureString, *onosIpAddrs ):
"""
Creates a cell file based on arguments
Required:
- * Bench IP address ( bench_ip )
+ * Bench IP address ( benchIp )
- Needed to copy the cell file over
- * File name of the cell file ( file_name )
- * Mininet IP address ( mn_ip_addrs )
+ * File name of the cell file ( fileName )
+ * Mininet IP address ( mnIpAddrs )
- Note that only 1 ip address is
supported currently
- * ONOS IP addresses ( onos_ip_addrs )
+ * ONOS IP addresses ( onosIpAddrs )
- Must be passed in as last arguments
NOTE: Assumes cells are located at:
~/<self.home>/tools/test/cells/
"""
# Variable initialization
- cell_directory = self.home + "/tools/test/cells/"
+ cellDirectory = self.home + "/tools/test/cells/"
# We want to create the cell file in the dependencies directory
# of TestON first, then copy over to ONOS bench
- temp_directory = "/tmp/"
+ tempDirectory = "/tmp/"
# Create the cell file in the directory for writing ( w+ )
- cell_file = open( temp_directory + file_name, 'w+' )
+ cellFile = open( tempDirectory + fileName, 'w+' )
# Feature string is hardcoded environment variables
# That you may wish to use by default on startup.
# Note that you may not want certain features listed
# on here.
- core_feature_string = "export ONOS_FEATURES=webconsole,onos-api," +\
- "onos-cli,onos-openflow," + extra_feature_string
- mn_string = "export OCN="
- onos_string = "export OC"
- temp_count = 1
+ coreFeatureString = "export ONOS_FEATURES=webconsole,onos-api," +\
+ "onos-cli,onos-openflow," + extraFeatureString
+ mnString = "export OCN="
+ onosString = "export OC"
+ tempCount = 1
- # Create ONOS_NIC ip address prefix
- temp_onos_ip = onos_ip_addrs[ 0 ]
- temp_list = []
- temp_list = temp_onos_ip.split( "." )
+ # Create ONOSNIC ip address prefix
+ tempOnosIp = onosIpAddrs[ 0 ]
+ tempList = []
+ tempList = tempOnosIp.split( "." )
# Omit last element of list to format for NIC
- temp_list = temp_list[ :-1 ]
+ tempList = tempList[ :-1 ]
# Structure the nic string ip
- nic_addr = ".".join( temp_list ) + ".*"
- onos_nic_string = "export ONOS_NIC=" + nic_addr
+ nicAddr = ".".join( tempList ) + ".*"
+ onosNicString = "export ONOS_NIC=" + nicAddr
try:
# Start writing to file
- cell_file.write( onos_nic_string + "\n" )
+ cellFile.write( onosNicString + "\n" )
- for arg in onos_ip_addrs:
- # For each argument in onos_ip_addrs, write to file
+ for arg in onosIpAddrs:
+ # For each argument in onosIpAddrs, write to file
# Output should look like the following:
# export OC1="10.128.20.11"
# export OC2="10.128.20.12"
- cell_file.write( onos_string + str( temp_count ) +
- "=" + "\"" + arg + "\"" + "\n" )
- temp_count = temp_count + 1
+ cellFile.write( onosString + str( tempCount ) +
+ "=" + "\"" + arg + "\"" + "\n" )
+ tempCount = tempCount + 1
- cell_file.write( mn_string + "\"" + mn_ip_addrs + "\"" + "\n" )
- cell_file.write( core_feature_string + "\n" )
- cell_file.close()
+ cellFile.write( mnString + "\"" + mnIpAddrs + "\"" + "\n" )
+ cellFile.write( coreFeatureString + "\n" )
+ cellFile.close()
# We use os.system to send the command to TestON cluster
# to account for the case in which TestON is not located
@@ -548,8 +561,8 @@
# Note that even if TestON is located on the same cluster
# as ONOS bench, you must setup passwordless ssh
# between TestON and ONOS bench in order to automate the test.
- os.system( "scp " + temp_directory + file_name +
- " admin@" + bench_ip + ":" + cell_directory )
+ os.system( "scp " + tempDirectory + fileName +
+ " admin@" + benchIp + ":" + cellDirectory )
return main.TRUE
@@ -565,7 +578,7 @@
main.cleanup()
main.exit()
- def set_cell( self, cellname ):
+ def setCell( self, cellname ):
"""
Calls 'cell <name>' to set the environment variables on ONOSbench
"""
@@ -576,19 +589,19 @@
main.exit()
else:
self.handle.sendline( "cell " + str( cellname ) )
- # Expect the cellname in the ONOS_CELL variable.
+ # Expect the cellname in the ONOSCELL variable.
# Note that this variable name is subject to change
# and that this driver will have to change accordingly
self.handle.expect( "ONOS_CELL=" + str( cellname ) )
- handle_before = self.handle.before
- handle_after = self.handle.after
+ handleBefore = self.handle.before
+ handleAfter = self.handle.after
# Get the rest of the handle
self.handle.sendline( "" )
self.handle.expect( "\$" )
- handle_more = self.handle.before
+ handleMore = self.handle.before
- main.log.info( "Cell call returned: " + handle_before +
- handle_after + handle_more )
+ main.log.info( "Cell call returned: " + handleBefore +
+ handleAfter + handleMore )
return main.TRUE
@@ -604,7 +617,7 @@
main.cleanup()
main.exit()
- def verify_cell( self ):
+ def verifyCell( self ):
"""
Calls 'onos-verify-cell' to check for cell installation
"""
@@ -616,15 +629,15 @@
self.handle.expect( "\$" )
self.handle.sendline( "onos-verify-cell" )
self.handle.expect( "\$" )
- handle_before = self.handle.before
- handle_after = self.handle.after
+ handleBefore = self.handle.before
+ handleAfter = self.handle.after
# Get the rest of the handle
self.handle.sendline( "" )
self.handle.expect( "\$" )
- handle_more = self.handle.before
+ handleMore = self.handle.before
- main.log.info( "Verify cell returned: " + handle_before +
- handle_after + handle_more )
+ main.log.info( "Verify cell returned: " + handleBefore +
+ handleAfter + handleMore )
return main.TRUE
except pexpect.EOF:
@@ -639,11 +652,11 @@
main.cleanup()
main.exit()
- def onos_cli( self, ONOS_ip, cmdstr ):
+ def onosCli( self, ONOSIp, cmdstr ):
"""
Uses 'onos' command to send various ONOS CLI arguments.
Required:
- * ONOS_ip: specify the ip of the cell machine
+ * ONOSIp: specify the ip of the cell machine
* cmdstr: specify the command string to send
This function is intended to expose the entire karaf
@@ -656,7 +669,7 @@
available commands.
"""
try:
- if not ONOS_ip:
+ if not ONOSIp:
main.log.error( "You must specify the IP address" )
return main.FALSE
if not cmdstr:
@@ -667,26 +680,26 @@
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "onos -w " + ONOS_ip + " " + cmdstr )
+ self.handle.sendline( "onos -w " + ONOSIp + " " + cmdstr )
self.handle.expect( "\$" )
- handle_before = self.handle.before
+ handleBefore = self.handle.before
print "handle_before = ", self.handle.before
- # handle_after = str( self.handle.after )
+ # handleAfter = str( self.handle.after )
# self.handle.sendline( "" )
# self.handle.expect( "\$" )
- # handle_more = str( self.handle.before )
+ # handleMore = str( self.handle.before )
main.log.info( "Command sent successfully" )
# Obtain return handle that consists of result from
# the onos command. The string may need to be
# configured further.
- # return_string = handle_before + handle_after
- return_string = handle_before
- print "return_string = ", return_string
- return return_string
+ # returnString = handleBefore + handleAfter
+ returnString = handleBefore
+ print "return_string = ", returnString
+ return returnString
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -700,7 +713,7 @@
main.cleanup()
main.exit()
- def onos_install( self, options="-f", node="" ):
+ def onosInstall( self, options="-f", node="" ):
"""
Installs ONOS bits on the designated cell machine.
If -f option is provided, it also forces an uninstall.
@@ -720,7 +733,7 @@
# NOTE: this timeout may need to change depending on the network
# and size of ONOS
i = self.handle.expect( [ "Network\sis\sunreachable",
- "onos\sstart/running,\sprocess",
+ "onos\sstart/running,\sprocess",
"ONOS\sis\salready\sinstalled",
pexpect.TIMEOUT ], timeout=60 )
@@ -755,7 +768,7 @@
main.cleanup()
main.exit()
- def onos_start( self, node_ip ):
+ def onosStart( self, nodeIp ):
"""
Calls onos command: 'onos-service [<node-ip>] start'
This command is a remote management of the ONOS upstart daemon
@@ -763,7 +776,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "onos-service " + str( node_ip ) +
+ self.handle.sendline( "onos-service " + str( nodeIp ) +
" start" )
i = self.handle.expect( [
"Job\sis\salready\srunning",
@@ -793,7 +806,7 @@
main.cleanup()
main.exit()
- def onos_stop( self, node_ip ):
+ def onosStop( self, nodeIp ):
"""
Calls onos command: 'onos-service [<node-ip>] stop'
This command is a remote management of the ONOS upstart daemon
@@ -801,7 +814,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "onos-service " + str( node_ip ) +
+ self.handle.sendline( "onos-service " + str( nodeIp ) +
" stop" )
i = self.handle.expect( [
"stop/waiting",
@@ -813,7 +826,7 @@
return main.TRUE
elif i == 1:
main.log.info( "Unknown ONOS instance specified: " +
- str( node_ip ) )
+ str( nodeIp ) )
return main.FALSE
else:
main.log.error( "ONOS service failed to stop" )
@@ -831,7 +844,7 @@
main.cleanup()
main.exit()
- def onos_uninstall( self, node_ip="" ):
+ def onosUninstall( self, nodeIp="" ):
"""
Calls the command: 'onos-uninstall'
Uninstalls ONOS from the designated cell machine, stopping
@@ -840,10 +853,10 @@
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "onos-uninstall " + str( node_ip ) )
+ self.handle.sendline( "onos-uninstall " + str( nodeIp ) )
self.handle.expect( "\$" )
- main.log.info( "ONOS " + node_ip + " was uninstalled" )
+ main.log.info( "ONOS " + nodeIp + " was uninstalled" )
# onos-uninstall command does not return any text
return main.TRUE
@@ -860,7 +873,7 @@
main.cleanup()
main.exit()
- def onos_die( self, node_ip ):
+ def onosDie( self, nodeIp ):
"""
Issues the command 'onos-die <node-ip>'
This command calls onos-kill and also stops the node
@@ -868,14 +881,14 @@
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- cmd_str = "onos-kill " + str( node_ip )
- self.handle.sendline( cmd_str )
+ cmdStr = "onos-kill " + str( nodeIp )
+ self.handle.sendline( cmdStr )
i = self.handle.expect( [
"Killing\sONOS",
"ONOS\sprocess\sis\snot\srunning",
pexpect.TIMEOUT ], timeout=20 )
if i == 0:
- main.log.info( "ONOS instance " + str( node_ip ) +
+ main.log.info( "ONOS instance " + str( nodeIp ) +
" was killed and stopped" )
return main.TRUE
elif i == 1:
@@ -893,7 +906,7 @@
main.cleanup()
main.exit()
- def onos_kill( self, node_ip ):
+ def onosKill( self, nodeIp ):
"""
Calls the command: 'onos-kill [<node-ip>]'
"Remotely, and unceremoniously kills the ONOS instance running on
@@ -902,7 +915,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "onos-kill " + str( node_ip ) )
+ self.handle.sendline( "onos-kill " + str( nodeIp ) )
i = self.handle.expect( [
"\$",
"No\sroute\sto\shost",
@@ -912,14 +925,16 @@
if i == 0:
main.log.info(
"ONOS instance " + str(
- node_ip ) + " was killed" )
+ nodeIp ) + " was killed" )
return main.TRUE
elif i == 1:
main.log.info( "No route to host" )
return main.FALSE
elif i == 2:
- main.log.info( "Passwordless login for host: " + str( node_ip ) +
- " not configured" )
+ main.log.info(
+ "Passwordless login for host: " +
+ str( nodeIp ) +
+ " not configured" )
return main.FALSE
else:
main.log.info( "ONOS instasnce was not killed" )
@@ -937,7 +952,7 @@
main.cleanup()
main.exit()
- def onos_remove_raft_logs( self ):
+ def onosRemoveRaftLogs( self ):
"""
Removes Raft / Copy cat files from ONOS to ensure
a cleaner environment.
@@ -974,7 +989,7 @@
main.cleanup()
main.exit()
- def onos_start_network( self, mntopo ):
+ def onosStartNetwork( self, mntopo ):
"""
Calls the command 'onos-start-network [ <mininet-topo> ]
"remotely starts the specified topology on the cell's
@@ -1047,49 +1062,57 @@
main.cleanup()
main.exit()
- def push_test_intents_shell( self, dpid_src, dpid_dst, num_intents,
- dir_file, onos_ip, num_mult="", app_id="", report=True,
- options="" ):
+ def pushTestIntentsShell(
+ self,
+ dpidSrc,
+ dpidDst,
+ numIntents,
+ dirFile,
+ onosIp,
+ numMult="",
+ appId="",
+ report=True,
+ options="" ):
"""
Description:
Use the linux prompt to push test intents to
better parallelize the results than the CLI
Required:
- * dpid_src: specify source dpid
- * dpid_dst: specify destination dpid
- * num_intents: specify number of intents to push
- * dir_file: specify directory and file name to save
+ * dpidSrc: specify source dpid
+ * dpidDst: specify destination dpid
+ * numIntents: specify number of intents to push
+ * dirFile: specify directory and file name to save
results
- * onos_ip: specify the IP of ONOS to install on
+ * onosIp: specify the IP of ONOS to install on
NOTE:
You must invoke this command at linux shell prompt
"""
try:
# Create the string to sendline
if options:
- base_cmd = "onos " + str( onos_ip ) + " push-test-intents " +\
+ baseCmd = "onos " + str( onosIp ) + " push-test-intents " +\
options + " "
else:
- base_cmd = "onos " + str( onos_ip ) + " push-test-intents "
+ baseCmd = "onos " + str( onosIp ) + " push-test-intents "
- add_dpid = base_cmd + str( dpid_src ) + " " + str( dpid_dst )
- if not num_mult:
- add_intents = add_dpid + " " + str( num_intents )
- elif num_mult:
- add_intents = add_dpid + " " + str( num_intents ) + " " +\
- str( num_mult )
- if app_id:
- add_app = add_intents + " " + str( app_id )
+ addDpid = baseCmd + str( dpidSrc ) + " " + str( dpidDst )
+ if not numMult:
+ addIntents = addDpid + " " + str( numIntents )
+ elif numMult:
+ addIntents = addDpid + " " + str( numIntents ) + " " +\
+ str( numMult )
+ if appId:
+ addApp = addIntents + " " + str( appId )
else:
- add_app = add_intents
+ addApp = addIntents
if report:
- send_cmd = add_app + " > " + str( dir_file ) + " &"
+ sendCmd = addApp + " > " + str( dirFile ) + " &"
else:
- send_cmd = add_app + " &"
- main.log.info( "Send cmd: " + send_cmd )
+ sendCmd = addApp + " &"
+ main.log.info( "Send cmd: " + sendCmd )
- self.handle.sendline( send_cmd )
+ self.handle.sendline( sendCmd )
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1103,7 +1126,7 @@
main.cleanup()
main.exit()
- def get_topology( self, topology_output ):
+ def getTopology( self, topologyOutput ):
"""
parses the onos:topology output
Returns: a topology dict populated by the key values found in
@@ -1112,13 +1135,13 @@
try:
# call the cli to get the topology summary
# cmdstr = "onos:topology"
- # cli_result = self.onos_cli( ip, cmdstr )
- # print "cli_result = ", cli_result
+ # cliResult = self.onosCli( ip, cmdstr )
+ # print "cli_result = ", cliResult
# Parse the output
topology = {}
- # for line in cli_result.split( "\n" ):
- for line in topology_output.splitlines():
+ # for line in cliResult.split( "\n" ):
+ for line in topologyOutput.splitlines():
if not line.startswith( "time=" ):
continue
# else
@@ -1151,12 +1174,12 @@
main.cleanup()
main.exit()
- def check_status(
- self,
- topology_result,
- numoswitch,
- numolink,
- log_level="info" ):
+ def checkStatus(
+ self,
+ topologyResult,
+ numoswitch,
+ numolink,
+ logLevel="info" ):
"""
Checks the number of swithes & links that ONOS sees against the
supplied values. By default this will report to main.log, but the
@@ -1165,42 +1188,46 @@
Params: ip = ip used for the onos cli
numoswitch = expected number of switches
numlink = expected number of links
- log_level = level to log to. Currently accepts 'info', 'warn' and 'report'
+ logLevel = level to log to.
+ Currently accepts 'info', 'warn' and 'report'
- log_level can
+ logLevel can
Returns: main.TRUE if the number of switchs and links are correct,
main.FALSE if the numer of switches and links is incorrect,
and main.ERROR otherwise
"""
try:
- topology = self.get_topology( topology_result )
+ topology = self.getTopology( topologyResult )
if topology == {}:
return main.ERROR
output = ""
# Is the number of switches is what we expected
devices = topology.get( 'devices', False )
links = topology.get( 'links', False )
- if devices == False or links == False:
+ if not devices or not links:
return main.ERROR
- switch_check = ( int( devices ) == int( numoswitch ) )
+ switchCheck = ( int( devices ) == int( numoswitch ) )
# Is the number of links is what we expected
- link_check = ( int( links ) == int( numolink ) )
- if ( switch_check and link_check ):
+ linkCheck = ( int( links ) == int( numolink ) )
+ if ( switchCheck and linkCheck ):
# We expected the correct numbers
output = output + "The number of links and switches match "\
+ "what was expected"
result = main.TRUE
else:
output = output + \
- "The number of links and switches does not match what was expected"
+ "The number of links and switches does not match\
+ what was expected"
result = main.FALSE
- output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)"\
- % ( int( devices ), int( numoswitch ), int( links ), int( numolink ) )
- if log_level == "report":
+ output = output + "\n ONOS sees %i devices (%i expected)\
+ and %i links (%i expected)" %\
+ ( int( devices ), int( numoswitch ),
+ int( links ), int( numolink ) )
+ if logLevel == "report":
main.log.report( output )
- elif log_level == "warn":
+ elif logLevel == "warn":
main.log.warn( output )
else:
main.log.info( output )
@@ -1217,7 +1244,7 @@
main.cleanup()
main.exit()
- def tshark_pcap( self, interface, dir_file ):
+ def tsharkPcap( self, interface, dirFile ):
"""
Capture all packet activity and store in specified
directory/file
@@ -1230,7 +1257,7 @@
self.handle.expect( "\$" )
self.handle.sendline( "tshark -i " + str( interface ) +
- " -t e -w " + str( dir_file ) + " &" )
+ " -t e -w " + str( dirFile ) + " &" )
self.handle.sendline( "\r" )
self.handle.expect( "Capturing on" )
self.handle.sendline( "\r" )
@@ -1238,19 +1265,21 @@
main.log.info( "Tshark started capturing files on " +
str( interface ) + " and saving to directory: " +
- str( dir_file ) )
+ str( dirFile ) )
- def run_onos_topo_cfg( self, instance_name, json_file ):
+ def runOnosTopoCfg( self, instanceName, jsonFile ):
"""
- On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
- which starts the rest and copies the json file to the onos instance
+ On ONOS bench, run this command:
+ ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
+ which starts the rest and copies
+ the json file to the onos instance
"""
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )
self.handle.sendline( "cd ~/ONOS/tools/test/bin" )
self.handle.expect( "/bin$" )
- cmd = "./onos-topo-cfg " + instance_name + " " + json_file
+ cmd = "./onos-topo-cfg " + instanceName + " " + jsonFile
print "cmd = ", cmd
self.handle.sendline( cmd )
self.handle.expect( "\$" )
@@ -1260,7 +1289,7 @@
except:
return main.FALSE
- def tshark_grep( self, grep, directory, interface='eth0' ):
+ def tsharkGrep( self, grep, directory, interface='eth0' ):
"""
Required:
* grep string
@@ -1275,14 +1304,20 @@
self.handle.sendline( "" )
self.handle.expect( "\$" )
self.handle.sendline( "" )
- self.handle.sendline( "tshark -i " + str( interface ) +
- " -t e | grep --line-buffered \"" + str(grep) + "\" >" + directory + " &" )
+ self.handle.sendline(
+ "tshark -i " +
+ str( interface ) +
+ " -t e | grep --line-buffered \"" +
+ str(grep) +
+ "\" >" +
+ directory +
+ " &" )
self.handle.sendline( "\r" )
self.handle.expect( "Capturing on" )
self.handle.sendline( "\r" )
self.handle.expect( "\$" )
- def tshark_stop( self ):
+ def tsharkStop( self ):
"""
Removes wireshark files from /tmp and kills all tshark processes
"""
@@ -1334,8 +1369,8 @@
main.cleanup()
main.exit()
- def cp_logs_to_dir( self, log_to_copy,
- dest_dir, copy_file_name="" ):
+ def cpLogsToDir( self, logToCopy,
+ destDir, copyFileName="" ):
"""
Copies logs to a desired directory.
Current implementation of ONOS deletes its karaf
@@ -1345,17 +1380,17 @@
Localtime will be attached to the filename
Required:
- * log_to_copy: specify directory and log name to
+ * logToCopy: specify directory and log name to
copy.
ex ) /opt/onos/log/karaf.log.1
- For copying multiple files, leave copy_file_name
- empty and only specify dest_dir -
+ For copying multiple files, leave copyFileName
+ empty and only specify destDir -
ex ) /opt/onos/log/karaf*
- * dest_dir: specify directory to copy to.
+ * destDir: specify directory to copy to.
ex ) /tmp/
Optional:
- * copy_file_name: If you want to rename the log
- file, specify copy_file_name. This will not work
+ * copyFileName: If you want to rename the log
+ file, specify copyFileName. This will not work
with multiple file copying
"""
try:
@@ -1363,18 +1398,22 @@
localtime = localtime.replace( "/", "" )
localtime = localtime.replace( " ", "_" )
localtime = localtime.replace( ":", "" )
- if dest_dir[ -1: ] != "/":
- dest_dir += "/"
+ if destDir[ -1: ] != "/":
+ destDir += "/"
- if copy_file_name:
- self.handle.sendline( "cp " + str( log_to_copy ) +
- " " + str( dest_dir ) + str( copy_file_name ) +
- localtime )
+ if copyFileName:
+ self.handle.sendline(
+ "cp " +
+ str( logToCopy ) +
+ " " +
+ str( destDir ) +
+ str( copyFileName ) +
+ localtime )
self.handle.expect( "cp" )
self.handle.expect( "\$" )
else:
- self.handle.sendline( "cp " + str( log_to_copy ) +
- " " + str( dest_dir ) )
+ self.handle.sendline( "cp " + str( logToCopy ) +
+ " " + str( destDir ) )
self.handle.expect( "cp" )
self.handle.expect( "\$" )
@@ -1390,13 +1429,13 @@
main.log.error( traceback.print_exc() )
main.log.info( self.name + " ::::::" )
- def check_logs( self, onos_ip ):
+ def checkLogs( self, onosIp ):
"""
runs onos-check-logs on the given onos node
returns the response
"""
try:
- cmd = "onos-check-logs " + str( onos_ip )
+ cmd = "onos-check-logs " + str( onosIp )
self.handle.sendline( cmd )
self.handle.expect( cmd )
self.handle.expect( "\$" )
@@ -1412,7 +1451,7 @@
main.log.error( traceback.print_exc() )
main.log.info( self.name + " ::::::" )
- def onos_status( self, node="" ):
+ def onosStatus( self, node="" ):
"""
Calls onos command: 'onos-service [<node-ip>] status'
"""
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 28f95af..8724454 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -32,15 +32,15 @@
QuaggaCliDriver,
self ).connect(
user_name=self.user_name,
- ip_address="1.1.1.1",
- port=self.port,
- pwd=self.pwd )
+ ip_address="1.1.1.1",
+ port=self.port,
+ pwd=self.pwd )
main.log.info(
"connect parameters:" + str(
self.user_name ) + ";" + str(
self.ip_address ) + ";" + str(
- self.port ) + ";" + str(
- self.pwd ) )
+ self.port ) + ";" + str(
+ self.pwd ) )
if self.handle:
# self.handle.expect( "",timeout=10 )
@@ -64,8 +64,14 @@
self.handle = super( QuaggaCliDriver, self ).connect(
user_name=self.user_name, ip_address=ip_address,
port=self.port, pwd=self.pwd )
- main.log.info( "connect parameters:" + str( self.user_name ) + ";"
- + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
+ main.log.info( "connect parameters:" +
+ str( self.user_name ) +
+ ";" +
+ str( self.ip_address ) +
+ ";" +
+ str( self.port ) +
+ ";" +
+ str( self.pwd ) )
if self.handle:
# self.handle.expect( "" )
@@ -86,7 +92,7 @@
main.log.info( "NO HANDLE" )
return main.FALSE
- def enter_config( self, asn ):
+ def enterConfig( self, asn ):
main.log.info( "I am in enter_config method!" )
try:
self.handle.sendline( "" )
@@ -105,13 +111,14 @@
except:
return main.FALSE
- def generate_prefixes( self, net, numRoutes ):
+ def generatePrefixes( self, net, numRoutes ):
main.log.info( "I am in generate_prefixes method!" )
- # each IP prefix will be composed by "net" + "." + m + "." + n + "." + x
+ # each IP prefix will be composed by
+ #"net" + "." + m + "." + n + "." + x
# the length of each IP prefix is 24
routes = []
- routes_gen = 0
+ routesGen = 0
m = numRoutes / 256
n = numRoutes % 256
@@ -122,14 +129,14 @@
i ) + "." + str(
j ) + ".0/24"
routes.append( network )
- routes_gen = routes_gen + 1
+ routesGen = routesGen + 1
for j in range( 0, n ):
network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
routes.append( network )
- routes_gen = routes_gen + 1
+ routesGen = routesGen + 1
- if routes_gen == numRoutes:
+ if routesGen == numRoutes:
main.log.info( "Successfully generated " + str( numRoutes )
+ " prefixes!" )
return routes
@@ -137,17 +144,25 @@
# This method generates a multiple to single point intent(
# MultiPointToSinglePointIntent ) for a given route
- def generate_expected_singleRouteIntent( self, prefix, nextHop, nextHopMac, sdnip_data ):
+ def generateExpectedSingleRouteIntent(
+ self,
+ prefix,
+ nextHop,
+ nextHopMac,
+ sdnipData ):
ingress = []
egress = ""
- for peer in sdnip_data[ 'bgpPeers' ]:
- if peer[ 'ipAddress' ] == nextHop:
- egress = "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
+ for peer in sdnipData[ 'bgpPeers' ]:
+ if peer[ 'ip_address' ] == nextHop:
+ egress = "of:" + \
+ str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" +\
+ str( peer[ 'attachmentPort' ] )
else:
- ingress.append( "of:" + \
- str( peer[ 'attachmentDpid' ] ).replace( ":",
- "" ) + ":" + str( peer[ 'attachmentPort' ] ) )
+ ingress.append( "of:" +
+ str( peer[ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" +
+ str( peer[ 'attachmentPort' ] ) )
selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
@@ -156,57 +171,63 @@
str( sorted( ingress ) ) + "/" + selector + "/" + treatment
return intent
- def generate_expected_onePeerRouteIntents( self, prefixes, nextHop, nextHopMac, sdnip_json_file_path ):
+ def generateExpectedOnePeerRouteIntents(
+ self,
+ prefixes,
+ nextHop,
+ nextHopMac,
+ sdnipJsonFilePath ):
intents = []
- sdnip_json_file = open( sdnip_json_file_path ).read()
+ sdnipJsonFile = open( sdnipJsonFilePath ).read()
- sdnip_data = json.loads( sdnip_json_file )
+ sdnipData = json.loads( sdnipJsonFile )
for prefix in prefixes:
intents.append(
- self.generate_expected_singleRouteIntent(
+ self.generateExpectedSingleRouteIntent(
prefix,
nextHop,
nextHopMac,
- sdnip_data ) )
+ sdnipData ) )
return sorted( intents )
# TODO
# This method generates all expected route intents for all BGP peers
- def generate_expected_routeIntents( self ):
+ def generateExpectedRouteIntents( self ):
intents = []
return intents
# This method extracts all actual routes from ONOS CLI
- def extract_actual_routes( self, get_routes_result ):
- routes_json_obj = json.loads( get_routes_result )
+ def extractActualRoutes( self, getRoutesResult ):
+ routesJsonObj = json.loads( getRoutesResult )
- allRoutes_actual = []
- for route in routes_json_obj:
+ allRoutesActual = []
+ for route in routesJsonObj:
if route[ 'prefix' ] == '172.16.10.0/24':
continue
- allRoutes_actual.append(
+ allRoutesActual.append(
route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
- return sorted( allRoutes_actual )
+ return sorted( allRoutesActual )
# This method extracts all actual route intents from ONOS CLI
- def extract_actual_routeIntents( self, get_intents_result ):
+ def extractActualRouteIntents( self, getIntentsResult ):
intents = []
# TODO: delete the line below when change to Mininet demo script
- # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
- intents_json_obj = json.loads( get_intents_result )
+ # getIntentsResult=open( "../tests/SdnIpTest/intents.json" ).read()
+ intentsJsonObj = json.loads( getIntentsResult )
- for intent in intents_json_obj:
+ for intent in intentsJsonObj:
if intent[ 'appId' ] != "org.onosproject.sdnip":
continue
- if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[ 'state' ] == 'INSTALLED':
+ if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[
+ 'state' ] == 'INSTALLED':
egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
intent[ 'egress' ][ 'port' ] )
ingress = []
for attachmentPoint in intent[ 'ingress' ]:
- ingress.append(
- str( attachmentPoint[ 'device' ] ) + ":" + str( attachmentPoint[ 'port' ] ) )
+ ingress.append( str( attachmentPoint[ 'device' ] ) +
+ ":" + str( attachmentPoint[ 'port' ] ) )
selector = intent[ 'selector' ].replace(
"[", "" ).replace( "]", "" ).replace( " ", "" )
@@ -216,27 +237,34 @@
intent = egress + "/" + \
str( sorted( ingress ) ) + "/" + \
- selector + "/" + intent[ 'treatment' ]
+ selector + "/" + intent[ 'treatment' ]
intents.append( intent )
return sorted( intents )
# This method extracts all actual BGP intents from ONOS CLI
- def extract_actual_bgpIntents( self, get_intents_result ):
+ def extractActualBgpIntents( self, getIntentsResult ):
intents = []
# TODO: delete the line below when change to Mininet demo script
- # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
- intents_json_obj = json.loads( get_intents_result )
+ # getIntentsResult=open( "../tests/SdnIpTest/intents.json" ).read()
+ intentsJsonObj = json.loads( getIntentsResult )
- for intent in intents_json_obj:
+ for intent in intentsJsonObj:
if intent[ 'appId' ] != "org.onosproject.sdnip":
continue
- if intent[ 'type' ] == "PointToPointIntent" and "protocol=6" in str( intent[ 'selector' ] ):
+ if intent[ 'type' ] == "PointToPointIntent" and "protocol=6"\
+ in str( intent[ 'selector' ] ):
ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" + str(
intent[ 'ingress' ][ 'port' ] )
egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
intent[ 'egress' ][ 'port' ] )
selector = str(
- intent[ 'selector' ] ).replace( " ", "" ).replace( "[", "" ).replace( "]", "" ).split( "," )
+ intent[ 'selector' ] ).replace(
+ " ",
+ "" ).replace(
+ "[",
+ "" ).replace(
+ "]",
+ "" ).split( "," )
intent = ingress + "/" + egress + \
"/" + str( sorted( selector ) )
intents.append( intent )
@@ -245,46 +273,57 @@
# This method generates a single point to single point intent(
# PointToPointIntent ) for BGP path
- def generate_expected_bgpIntents( self, sdnip_json_file_path ):
+ def generateExpectedBgpIntents( self, sdnipJsonFilePath ):
from operator import eq
- sdnip_json_file = open( sdnip_json_file_path ).read()
- sdnip_data = json.loads( sdnip_json_file )
+ sdnipJsonFile = open( sdnipJsonFilePath ).read()
+ sdnipData = json.loads( sdnipJsonFile )
intents = []
bgpPeerAttachmentPoint = ""
bgpSpeakerAttachmentPoint = "of:" + str(
- sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
- "" ) + ":" + str( sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
- for peer in sdnip_data[ 'bgpPeers' ]:
- bgpPeerAttachmentPoint = "of:" + str(
- peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
+ sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
+ "" ) + ":" +\
+ str( sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
+ for peer in sdnipData[ 'bgpPeers' ]:
+ bgpPeerAttachmentPoint = "of:" + \
+ str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) +\
+ ":" + str( peer[ 'attachmentPort' ] )
# find out the BGP speaker IP address for this BGP peer
bgpSpeakerIpAddress = ""
- for interfaceAddress in sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
- # if eq( interfaceAddress[ 'interfaceDpid' ],sdnip_data[
+ for interfaceAddress in sdnipData[
+ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
+ # if eq( interfaceAddress[ 'interfaceDpid' ],sdnipData[
# 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
- # interfaceAddress[ 'interfacePort' ], sdnip_data[
+ # interfaceAddress[ 'interfacePort' ], sdnipData[
# 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
- if eq( interfaceAddress[ 'interfaceDpid' ], peer[ 'attachmentDpid' ] ) and eq( interfaceAddress[ 'interfacePort' ], peer[ 'attachmentPort' ] ):
- bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
+ if eq(
+ interfaceAddress[ 'interfaceDpid' ],
+ peer[ 'attachmentDpid' ] ) and eq(
+ interfaceAddress[ 'interfacePort' ],
+ peer[ 'attachmentPort' ] ):
+ bgpSpeakerIpAddress = interfaceAddress[ 'ip_address' ]
break
else:
continue
# from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
# direction
- selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
- 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
+ selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress +\
+ "/32}," + "IPV4_DST{ip=" + peer[ 'ip_address' ] + "/32}," +\
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
+ TCP_DST{tcpPort=179}"
+ selector = selectorStr.replace( " ", "" ).replace(
"[", "" ).replace( "]", "" ).split( "," )
intent = bgpSpeakerAttachmentPoint + "/" + \
bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
intents.append( intent )
- selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
- 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
+ selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," +\
+ "IPV4_DST{ip=" + peer[ 'ip_address' ] + "/32}," +\
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
+ TCP_SRC{tcpPort=179}"
+ selector = selectorStr.replace( " ", "" ).replace(
"[", "" ).replace( "]", "" ).split( "," )
intent = bgpSpeakerAttachmentPoint + "/" + \
bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
@@ -292,17 +331,21 @@
# from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
# direction
- selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
- "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
+ selectorStr = "IPV4_SRC{ip=" + peer[ 'ip_address' ] + "/32}," +\
+ "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
+ TCP_DST{tcpPort=179}"
+ selector = selectorStr.replace( " ", "" ).replace(
"[", "" ).replace( "]", "" ).split( "," )
intent = bgpPeerAttachmentPoint + "/" + \
bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
intents.append( intent )
- selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
- "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
+ selectorStr = "IPV4_SRC{ip=" + peer[ 'ip_address' ] + "/32}," +\
+ "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," +\
+ "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
+ TCP_SRC{tcpPort=179}"
+ selector = selectorStr.replace( " ", "" ).replace(
"[", "" ).replace( "]", "" ).split( "," )
intent = bgpPeerAttachmentPoint + "/" + \
bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
@@ -310,10 +353,10 @@
return sorted( intents )
- def add_routes( self, routes, routeRate ):
+ def addRoutes( self, routes, routeRate ):
main.log.info( "I am in add_routes method!" )
- routes_added = 0
+ routesAdded = 0
try:
self.handle.sendline( "" )
# self.handle.expect( "config-router" )
@@ -333,15 +376,15 @@
self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
- if routes_added == len( routes ):
+ if routesAdded == len( routes ):
main.log.info( "Finished adding routes" )
return main.TRUE
return main.FALSE
- def delete_routes( self, routes, routeRate ):
+ def deleteRoutes( self, routes, routeRate ):
main.log.info( "I am in delete_routes method!" )
- routes_added = 0
+ routesAdded = 0
try:
self.handle.sendline( "" )
# self.handle.expect( "config-router" )
@@ -361,34 +404,40 @@
self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
- if routes_added == len( routes ):
+ if routesAdded == len( routes ):
main.log.info( "Finished deleting routes" )
return main.TRUE
return main.FALSE
- def ping_test( self, ip_address, ping_test_file, ping_test_result_file ):
+ def pingTest( self, ip_address, pingTestFile, pingTestResultFile ):
main.log.info( "Start the ping test on host:" + str( ip_address ) )
self.name = self.options[ 'name' ]
self.handle = super( QuaggaCliDriver, self ).connect(
user_name=self.user_name, ip_address=ip_address,
port=self.port, pwd=self.pwd )
- main.log.info( "connect parameters:" + str( self.user_name ) + ";"
- + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
+ main.log.info( "connect parameters:" +
+ str( self.user_name ) +
+ ";" +
+ str( self.ip_address ) +
+ ";" +
+ str( self.port ) +
+ ";" +
+ str( self.pwd ) )
if self.handle:
# self.handle.expect( "" )
# self.handle.expect( "\$" )
main.log.info( "I in host " + str( ip_address ) )
main.log.info(
- ping_test_file +
+ pingTestFile +
" > " +
- ping_test_result_file +
+ pingTestResultFile +
" &" )
self.handle.sendline(
- ping_test_file +
+ pingTestFile +
" > " +
- ping_test_result_file +
+ pingTestResultFile +
" &" )
self.handle.expect( "\$", timeout=60 )
handle = self.handle.before
@@ -398,8 +447,8 @@
main.log.info( "NO HANDLE" )
return main.FALSE
- # Please use the generate_routes plus add_routes instead of this one
- def add_route( self, net, numRoutes, routeRate ):
+ # Please use the generateRoutes plus addRoutes instead of this one
+ def addRoute( self, net, numRoutes, routeRate ):
try:
self.handle.sendline( "" )
self.handle.expect( "config-router" )
@@ -413,12 +462,13 @@
numRoutes = numRoutes - 255
j = j + 1
k = numRoutes % 254
- routes_added = 0
+ routesAdded = 0
if numRoutes > 255:
numRoutes = 255
for m in range( 1, j + 1 ):
for n in range( 1, numRoutes + 1 ):
- network = str( net ) + "." + str( m ) + "." + str( n ) + ".0/24"
+ network = str( net ) + "." + str( m ) + \
+ "." + str( n ) + ".0/24"
routeCmd = "network " + network
try:
self.handle.sendline( routeCmd )
@@ -428,7 +478,7 @@
self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
- routes_added = routes_added + 1
+ routesAdded = routesAdded + 1
for d in range( j + 1, j + 2 ):
for e in range( 1, k + 1 ):
network = str(
@@ -444,12 +494,12 @@
self.disconnect
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
- routes_added = routes_added + 1
- if routes_added == numRoutes:
+ routesAdded = routesAdded + 1
+ if routesAdded == numRoutes:
return main.TRUE
return main.FALSE
- def del_route( self, net, numRoutes, routeRate ):
+ def delRoute( self, net, numRoutes, routeRate ):
try:
self.handle.sendline( "" )
self.handle.expect( "config-router" )
@@ -463,12 +513,13 @@
numRoutes = numRoutes - 255
j = j + 1
k = numRoutes % 254
- routes_deleted = 0
+ routesDeleted = 0
if numRoutes > 255:
numRoutes = 255
for m in range( 1, j + 1 ):
for n in range( 1, numRoutes + 1 ):
- network = str( net ) + "." + str( m ) + "." + str( n ) + ".0/24"
+ network = str( net ) + "." + str( m ) + \
+ "." + str( n ) + ".0/24"
routeCmd = "no network " + network
try:
self.handle.sendline( routeCmd )
@@ -478,10 +529,11 @@
self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
- routes_deleted = routes_deleted + 1
+ routesDeleted = routesDeleted + 1
for d in range( j + 1, j + 2 ):
for e in range( 1, k + 1 ):
- network = str( net ) + "." + str( d ) + "." + str( e ) + ".0/24"
+ network = str( net ) + "." + str( d ) + \
+ "." + str( e ) + ".0/24"
routeCmd = "no network " + network
try:
self.handle.sendline( routeCmd )
@@ -491,12 +543,12 @@
self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
- routes_deleted = routes_deleted + 1
- if routes_deleted == numRoutes:
+ routesDeleted = routesDeleted + 1
+ if routesDeleted == numRoutes:
return main.TRUE
return main.FALSE
- def check_routes( self, brand, ip, user, pw ):
+ def checkRoutes( self, brand, ip, user, pw ):
def pronto( ip, user, passwd ):
print "Connecting to Pronto switch"
child = pexpect.spawn( "telnet " + ip )
@@ -520,8 +572,8 @@
while True:
i = child.expect(
[ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
- 'CLI#',
- pexpect.TIMEOUT ] )
+ 'CLI#',
+ pexpect.TIMEOUT ] )
if i == 0:
count = count + 1
elif i == 1:
@@ -568,4 +620,3 @@
main.log.error( "Connection failed to the host" )
response = main.FALSE
return response
-
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py.fixed b/TestON/drivers/common/cli/quaggaclidriver.py.fixed
deleted file mode 100644
index 09b7614..0000000
--- a/TestON/drivers/common/cli/quaggaclidriver.py.fixed
+++ /dev/null
@@ -1,596 +0,0 @@
-#!/usr/bin/env python
-
-import time
-import pexpect
-import struct
-import fcntl
-import os
-import sys
-import signal
-import sys
-import re
-import json
-sys.path.append( "../" )
-from drivers.common.clidriver import CLI
-
-
-class QuaggaCliDriver( CLI ):
-
- def __init__( self ):
- super( CLI, self ).__init__()
-
- # TODO: simplify this method
- def connect( self, **connectargs ):
- for key in connectargs:
- vars( self )[ key ] = connectargs[ key ]
-
- self.name = self.options[ 'name' ]
- # self.handle = super( QuaggaCliDriver,self ).connect(
- # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
- # pwd=self.pwd )
- self.handle = super(
- QuaggaCliDriver,
- self ).connect(
- user_name=self.user_name,
- ip_address="1.1.1.1",
- port=self.port,
- pwd=self.pwd )
- main.log.info(
- "connect parameters:" + str(
- self.user_name ) + ";" + str(
- self.ip_address ) + ";" + str(
- self.port ) + ";" + str(
- self.pwd ) )
-
- if self.handle:
- # self.handle.expect( "",timeout=10 )
- # self.handle.expect( "\$",timeout=10 )
- self.handle.sendline( "telnet localhost 2605" )
- # self.handle.expect( "Password:", timeout=5 )
- self.handle.expect( "Password:" )
- self.handle.sendline( "hello" )
- # self.handle.expect( "bgpd", timeout=5 )
- self.handle.expect( "bgpd" )
- self.handle.sendline( "enable" )
- # self.handle.expect( "bgpd#", timeout=5 )
- self.handle.expect( "bgpd#" )
- return self.handle
- else:
- main.log.info( "NO HANDLE" )
- return main.FALSE
-
- def loginQuagga( self, ip_address ):
- self.name = self.options[ 'name' ]
- self.handle = super( QuaggaCliDriver, self ).connect(
- user_name=self.user_name, ip_address=ip_address,
- port=self.port, pwd=self.pwd )
- main.log.info( "connect parameters:" + str( self.user_name ) + ";"
- + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
-
- if self.handle:
- # self.handle.expect( "" )
- # self.handle.expect( "\$" )
- self.handle.sendline( "telnet localhost 2605" )
- # self.handle.expect( "Password:", timeout=5 )
- self.handle.expect( "Password:" )
- self.handle.sendline( "hello" )
- # self.handle.expect( "bgpd", timeout=5 )
- self.handle.expect( "bgpd" )
- self.handle.sendline( "enable" )
- # self.handle.expect( "bgpd#", timeout=5 )
- self.handle.expect( "bgpd#" )
- main.log.info( "I in quagga on host " + str( ip_address ) )
-
- return self.handle
- else:
- main.log.info( "NO HANDLE" )
- return main.FALSE
-
- def enter_config( self, asn ):
- main.log.info( "I am in enter_config method!" )
- try:
- self.handle.sendline( "" )
- self.handle.expect( "bgpd#" )
- except:
- main.log.warn( "Probably not currently in enable mode!" )
- self.disconnect()
- return main.FALSE
- self.handle.sendline( "configure terminal" )
- self.handle.expect( "config", timeout=5 )
- routerAS = "router bgp " + str( asn )
- try:
- self.handle.sendline( routerAS )
- self.handle.expect( "config-router", timeout=5 )
- return main.TRUE
- except:
- return main.FALSE
-
- def generate_prefixes( self, net, numRoutes ):
- main.log.info( "I am in generate_prefixes method!" )
-
- # each IP prefix will be composed by "net" + "." + m + "." + n + "." + x
- # the length of each IP prefix is 24
- routes = []
- routes_gen = 0
- m = numRoutes / 256
- n = numRoutes % 256
-
- for i in range( 0, m ):
- for j in range( 0, 256 ):
- network = str(
- net ) + "." + str(
- i ) + "." + str(
- j ) + ".0/24"
- routes.append( network )
- routes_gen = routes_gen + 1
-
- for j in range( 0, n ):
- network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
- routes.append( network )
- routes_gen = routes_gen + 1
-
- if routes_gen == numRoutes:
- main.log.info( "Successfully generated " + str( numRoutes )
- + " prefixes!" )
- return routes
- return main.FALSE
-
- # This method generates a multiple to single point intent(
- # MultiPointToSinglePointIntent ) for a given route
- def generate_expected_singleRouteIntent(
- self,
- prefix,
- nextHop,
- nextHopMac,
- sdnip_data ):
-
- ingress = []
- egress = ""
- for peer in sdnip_data[ 'bgpPeers' ]:
- if peer[ 'ipAddress' ] == nextHop:
- egress = "of:" + str(
- peer[ 'attachmentDpid' ] ).replace( ":",
- "" ) + ":" + str( peer[ 'attachmentPort' ] )
- else:
- ingress.append(
- "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":",
- "" ) + ":" + str( peer[ 'attachmentPort' ] ) )
-
- selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
- treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
-
- intent = egress + "/" + \
- str( sorted( ingress ) ) + "/" + selector + "/" + treatment
- return intent
-
- def generate_expected_onePeerRouteIntents(
- self,
- prefixes,
- nextHop,
- nextHopMac,
- sdnip_json_file_path ):
- intents = []
- sdnip_json_file = open( sdnip_json_file_path ).read()
-
- sdnip_data = json.loads( sdnip_json_file )
-
- for prefix in prefixes:
- intents.append(
- self.generate_expected_singleRouteIntent(
- prefix,
- nextHop,
- nextHopMac,
- sdnip_data ) )
- return sorted( intents )
-
- # TODO
- # This method generates all expected route intents for all BGP peers
- def generate_expected_routeIntents( self ):
- intents = []
- return intents
-
- # This method extracts all actual routes from ONOS CLI
- def extract_actual_routes( self, get_routes_result ):
- routes_json_obj = json.loads( get_routes_result )
-
- allRoutes_actual = []
- for route in routes_json_obj:
- if route[ 'prefix' ] == '172.16.10.0/24':
- continue
- allRoutes_actual.append(
- route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
-
- return sorted( allRoutes_actual )
-
- # This method extracts all actual route intents from ONOS CLI
- def extract_actual_routeIntents( self, get_intents_result ):
- intents = []
- # TODO: delete the line below when change to Mininet demo script
- # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
- intents_json_obj = json.loads( get_intents_result )
-
- for intent in intents_json_obj:
- if intent[ 'appId' ] != "org.onosproject.sdnip":
- continue
- if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[ 'state' ] == 'INSTALLED':
- egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
- intent[ 'egress' ][ 'port' ] )
- ingress = []
- for attachmentPoint in intent[ 'ingress' ]:
- ingress.append(
- str( attachmentPoint[ 'device' ] ) + ":" + str( attachmentPoint[ 'port' ] ) )
-
- selector = intent[ 'selector' ].replace(
- "[", "" ).replace( "]", "" ).replace( " ", "" )
- if str( selector ).startswith( "IPV4" ):
- str1, str2 = str( selector ).split( "," )
- selector = str2 + "," + str1
-
- intent = egress + "/" + \
- str( sorted( ingress ) ) + "/" + \
- selector + "/" + intent[ 'treatment' ]
- intents.append( intent )
- return sorted( intents )
-
- # This method extracts all actual BGP intents from ONOS CLI
- def extract_actual_bgpIntents( self, get_intents_result ):
- intents = []
- # TODO: delete the line below when change to Mininet demo script
- # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
- intents_json_obj = json.loads( get_intents_result )
-
- for intent in intents_json_obj:
- if intent[ 'appId' ] != "org.onosproject.sdnip":
- continue
- if intent[ 'type' ] == "PointToPointIntent" and "protocol=6" in str( intent[ 'selector' ] ):
- ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" + str(
- intent[ 'ingress' ][ 'port' ] )
- egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
- intent[ 'egress' ][ 'port' ] )
- selector = str(
- intent[ 'selector' ] ).replace( " ",
- "" ).replace( "[",
- "" ).replace( "]",
- "" ).split( "," )
- intent = ingress + "/" + egress + \
- "/" + str( sorted( selector ) )
- intents.append( intent )
-
- return sorted( intents )
-
- # This method generates a single point to single point intent(
- # PointToPointIntent ) for BGP path
- def generate_expected_bgpIntents( self, sdnip_json_file_path ):
- from operator import eq
-
- sdnip_json_file = open( sdnip_json_file_path ).read()
- sdnip_data = json.loads( sdnip_json_file )
-
- intents = []
- bgpPeerAttachmentPoint = ""
- bgpSpeakerAttachmentPoint = "of:" + str(
- sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
- "" ) + ":" + str( sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
- for peer in sdnip_data[ 'bgpPeers' ]:
- bgpPeerAttachmentPoint = "of:" + str(
- peer[ 'attachmentDpid' ] ).replace( ":",
- "" ) + ":" + str( peer[ 'attachmentPort' ] )
- # find out the BGP speaker IP address for this BGP peer
- bgpSpeakerIpAddress = ""
- for interfaceAddress in sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
- # if eq( interfaceAddress[ 'interfaceDpid' ],sdnip_data[
- # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
- # interfaceAddress[ 'interfacePort' ], sdnip_data[
- # 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
- if eq( interfaceAddress[ 'interfaceDpid' ], peer[ 'attachmentDpid' ] ) and eq( interfaceAddress[ 'interfacePort' ], peer[ 'attachmentPort' ] ):
- bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
- break
- else:
- continue
-
- # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
- # direction
- selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
- 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
- "[", "" ).replace( "]", "" ).split( "," )
- intent = bgpSpeakerAttachmentPoint + "/" + \
- bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
- intents.append( intent )
-
- selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
- 'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
- "[", "" ).replace( "]", "" ).split( "," )
- intent = bgpSpeakerAttachmentPoint + "/" + \
- bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
- intents.append( intent )
-
- # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
- # direction
- selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
- "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
- "[", "" ).replace( "]", "" ).split( "," )
- intent = bgpPeerAttachmentPoint + "/" + \
- bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
- intents.append( intent )
-
- selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
- "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
- selector = selector_str.replace( " ", "" ).replace(
- "[", "" ).replace( "]", "" ).split( "," )
- intent = bgpPeerAttachmentPoint + "/" + \
- bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
- intents.append( intent )
-
- return sorted( intents )
-
- def add_routes( self, routes, routeRate ):
- main.log.info( "I am in add_routes method!" )
-
- routes_added = 0
- try:
- self.handle.sendline( "" )
- # self.handle.expect( "config-router" )
- self.handle.expect( "config-router", timeout=5 )
- except:
- main.log.warn( "Probably not in config-router mode!" )
- self.disconnect()
- main.log.info( "Start to add routes" )
-
- for i in range( 0, len( routes ) ):
- routeCmd = "network " + routes[ i ]
- try:
- self.handle.sendline( routeCmd )
- self.handle.expect( "bgpd", timeout=5 )
- except:
- main.log.warn( "Failed to add route" )
- self.disconnect()
- waitTimer = 1.00 / routeRate
- time.sleep( waitTimer )
- if routes_added == len( routes ):
- main.log.info( "Finished adding routes" )
- return main.TRUE
- return main.FALSE
-
- def delete_routes( self, routes, routeRate ):
- main.log.info( "I am in delete_routes method!" )
-
- routes_added = 0
- try:
- self.handle.sendline( "" )
- # self.handle.expect( "config-router" )
- self.handle.expect( "config-router", timeout=5 )
- except:
- main.log.warn( "Probably not in config-router mode!" )
- self.disconnect()
- main.log.info( "Start to delete routes" )
-
- for i in range( 0, len( routes ) ):
- routeCmd = "no network " + routes[ i ]
- try:
- self.handle.sendline( routeCmd )
- self.handle.expect( "bgpd", timeout=5 )
- except:
- main.log.warn( "Failed to add route" )
- self.disconnect()
- waitTimer = 1.00 / routeRate
- time.sleep( waitTimer )
- if routes_added == len( routes ):
- main.log.info( "Finished deleting routes" )
- return main.TRUE
- return main.FALSE
-
- def ping_test( self, ip_address, ping_test_file, ping_test_result_file ):
- main.log.info( "Start the ping test on host:" + str( ip_address ) )
-
- self.name = self.options[ 'name' ]
- self.handle = super( QuaggaCliDriver, self ).connect(
- user_name=self.user_name, ip_address=ip_address,
- port=self.port, pwd=self.pwd )
- main.log.info( "connect parameters:" + str( self.user_name ) + ";"
- + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
-
- if self.handle:
- # self.handle.expect( "" )
- # self.handle.expect( "\$" )
- main.log.info( "I in host " + str( ip_address ) )
- main.log.info(
- ping_test_file +
- " > " +
- ping_test_result_file +
- " &" )
- self.handle.sendline(
- ping_test_file +
- " > " +
- ping_test_result_file +
- " &" )
- self.handle.expect( "\$", timeout=60 )
- handle = self.handle.before
-
- return handle
- else:
- main.log.info( "NO HANDLE" )
- return main.FALSE
-
- # Please use the generate_routes plus add_routes instead of this one
- def add_route( self, net, numRoutes, routeRate ):
- try:
- self.handle.sendline( "" )
- self.handle.expect( "config-router" )
- except:
- main.log.warn( "Probably not in config-router mode!" )
- self.disconnect()
- main.log.info( "Adding Routes" )
- j = 0
- k = 0
- while numRoutes > 255:
- numRoutes = numRoutes - 255
- j = j + 1
- k = numRoutes % 254
- routes_added = 0
- if numRoutes > 255:
- numRoutes = 255
- for m in range( 1, j + 1 ):
- for n in range( 1, numRoutes + 1 ):
- network = str(
- net ) + "." + str(
- m ) + "." + str(
- n ) + ".0/24"
- routeCmd = "network " + network
- try:
- self.handle.sendline( routeCmd )
- self.handle.expect( "bgpd" )
- except:
- main.log.warn( "failed to add route" )
- self.disconnect()
- waitTimer = 1.00 / routeRate
- time.sleep( waitTimer )
- routes_added = routes_added + 1
- for d in range( j + 1, j + 2 ):
- for e in range( 1, k + 1 ):
- network = str(
- net ) + "." + str(
- d ) + "." + str(
- e ) + ".0/24"
- routeCmd = "network " + network
- try:
- self.handle.sendline( routeCmd )
- self.handle.expect( "bgpd" )
- except:
- main.log.warn( "failed to add route" )
- self.disconnect
- waitTimer = 1.00 / routeRate
- time.sleep( waitTimer )
- routes_added = routes_added + 1
- if routes_added == numRoutes:
- return main.TRUE
- return main.FALSE
-
- def del_route( self, net, numRoutes, routeRate ):
- try:
- self.handle.sendline( "" )
- self.handle.expect( "config-router" )
- except:
- main.log.warn( "Probably not in config-router mode!" )
- self.disconnect()
- main.log.info( "Deleting Routes" )
- j = 0
- k = 0
- while numRoutes > 255:
- numRoutes = numRoutes - 255
- j = j + 1
- k = numRoutes % 254
- routes_deleted = 0
- if numRoutes > 255:
- numRoutes = 255
- for m in range( 1, j + 1 ):
- for n in range( 1, numRoutes + 1 ):
- network = str(
- net ) + "." + str(
- m ) + "." + str(
- n ) + ".0/24"
- routeCmd = "no network " + network
- try:
- self.handle.sendline( routeCmd )
- self.handle.expect( "bgpd" )
- except:
- main.log.warn( "Failed to delete route" )
- self.disconnect()
- waitTimer = 1.00 / routeRate
- time.sleep( waitTimer )
- routes_deleted = routes_deleted + 1
- for d in range( j + 1, j + 2 ):
- for e in range( 1, k + 1 ):
- network = str(
- net ) + "." + str(
- d ) + "." + str(
- e ) + ".0/24"
- routeCmd = "no network " + network
- try:
- self.handle.sendline( routeCmd )
- self.handle.expect( "bgpd" )
- except:
- main.log.warn( "Failed to delete route" )
- self.disconnect()
- waitTimer = 1.00 / routeRate
- time.sleep( waitTimer )
- routes_deleted = routes_deleted + 1
- if routes_deleted == numRoutes:
- return main.TRUE
- return main.FALSE
-
- def check_routes( self, brand, ip, user, pw ):
- def pronto( ip, user, passwd ):
- print "Connecting to Pronto switch"
- child = pexpect.spawn( "telnet " + ip )
- i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
- if i == 0:
- print "Username and password required. Passing login info."
- child.sendline( user )
- child.expect( "Password:" )
- child.sendline( passwd )
- child.expect( "CLI#" )
- print "Logged in, getting flowtable."
- child.sendline( "flowtable brief" )
- for t in range( 9 ):
- t2 = 9 - t
- print "\r" + str( t2 )
- sys.stdout.write( "\033[F" )
- time.sleep( 1 )
- print "Scanning flowtable"
- child.expect( "Flow table show" )
- count = 0
- while True:
- i = child.expect(
- [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
- 'CLI#',
- pexpect.TIMEOUT ] )
- if i == 0:
- count = count + 1
- elif i == 1:
- print "Pronto flows: " + str( count ) + "\nDone\n"
- break
- else:
- break
-
- def cisco( ip, user, passwd ):
- print "Establishing Cisco switch connection"
- child = pexpect.spawn( "ssh " + user + "@" + ip )
- i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
- if i == 0:
- print "Password required. Passing now."
- child.sendline( passwd )
- child.expect( "#" )
- print "Logged in. Retrieving flow table then counting flows."
- child.sendline( "show openflow switch all flows all" )
- child.expect( "Logical Openflow Switch" )
- print "Flow table retrieved. Counting flows"
- count = 0
- while True:
- i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
- if i == 0:
- count = count + 1
- elif i == 1:
- print "Cisco flows: " + str( count ) + "\nDone\n"
- break
- else:
- break
- if brand == "pronto" or brand == "PRONTO":
- pronto( ip, user, passwd )
- # elif brand == "cisco" or brand == "CISCO":
- # cisco( ip,user,passwd )
-
- def disconnect( self ):
- """
- Called when Test is complete to disconnect the Quagga handle.
- """
- response = ''
- try:
- self.handle.close()
- except:
- main.log.error( "Connection failed to the host" )
- response = main.FALSE
- return response
-
diff --git a/TestON/drivers/common/cli/remotetestbed/hpswitchclidriver.py b/TestON/drivers/common/cli/remotetestbed/hpswitchclidriver.py
deleted file mode 100644
index 24d9696..0000000
--- a/TestON/drivers/common/cli/remotetestbed/hpswitchclidriver.py
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/usr/bin/env python
-'''
-Created on 24-June-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/>.
-
-
-'''
-import time
-import pexpect
-import struct, fcntl, os, sys, signal
-import sys
-import re
-sys.path.append("../")
-from drivers.common.clidriver import CLI
-
-class HPSwitch(CLI):
-
- def __init__(self):
- super(CLI, self).__init__()
-
- def connect(self,**connectargs):
- for key in connectargs:
- vars(self)[key] = connectargs[key]
-
- self.name = self.options['name']
- self.handle = super(HPSwitch,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
-
- return main.TRUE
-
- def configure(self):
- self.execute(cmd='configure', prompt = '\(config\)',timeout = 3)
- if re.search('\(config\)', main.last_response):
- main.log.info("Configure mode enabled"+main.last_response)
- else :
- main.log.warn("Fail to enable configure mode"+main.last_response)
-
-
- def set_up_vlan(self,**vlanargs):
- '''
- Configure vlan.
- '''
- for key in vlanargs:
- vars(self)[key] = vlanargs[key]
-
- self.execute(cmd='vlan '+self.vlan_id, prompt = '\(vlan-'+self.vlan_id+'\)',timeout = 3)
- if re.search('\(vlan-'+self.vlan_id+'\)', main.last_response):
- main.log.info("Configuring VLAN "+self.vlan_id)
- else :
- main.log.warn("Fail to configure Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
-
- if self.vlan_name :
- self.execute(cmd='name '+self.vlan_name, prompt = '\(vlan-'+self.vlan_id+'\)',timeout = 3)
- if re.search('\(vlan-'+self.vlan_id+'\)', main.last_response):
- main.log.info("Configuring "+self.vlan_id)
- return main.TRUE
- else :
- main.log.warn("Fail to configure Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
- else :
- main.log.error("Vlan Name not specified")
- return main.FALSE
-
- def vlan_tagged(self, **taggedargs):
- for key in taggedargs:
- vars(self)[key] = taggedargs[key]
- if self.vlan_id :
- self.execute(cmd='vlan '+self.vlan_id, prompt = '\(vlan-'+self.vlan_id+'\)',timeout = 3)
-
- if re.search('\(vlan-'+self.vlan_id+'\)', main.last_response):
- main.log.info("Configuring "+self.vlan_id)
- else :
- main.log.warn("Fail to configure Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
- if self.tagged :
- self.execute(cmd='tagged '+self.vlan_id, prompt = '\(vlan-'+self.vlan_id+'\)',timeout = 3)
- if re.search('\(vlan-'+self.vlan_id+'\)', main.last_response):
- main.log.info("VLAN tagged done "+self.tagged)
- return main.TRUE
- else :
- main.log.warn("Fail to tagged Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
-
- def vlan_untagged(self, **untaggedargs):
- for key in untaggedargs:
- vars(self)[key] = untaggedargs[key]
- if self.vlan_id :
- self.execute(cmd='vlan '+self.vlan_id, prompt = '\(vlan-'+self.vlan_id+'\)',timeout = 3)
-
- if re.search('\(vlan-'+self.vlan_id+'\)', main.last_response):
- main.log.info("Configuring "+self.vlan_id)
- else :
- main.log.warn("Fail to configure Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
- if self.tagged :
- self.execute(cmd='untagged '+self.vlan_id, prompt = '\(vlan-'+self.vlan_id+'\)',timeout = 3)
- if re.search('\(vlan-'+self.vlan_id+'\)', main.last_response):
- main.log.info("VLAN untagged done "+self.tagged)
- return main.TRUE
- else :
- main.log.warn("Fail to untagged Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
-
- def openflow_mode(self):
- self.configure()
- self.execute(cmd='openflow', prompt = '\(openflow\)',timeout = 3)
- if re.search('\(openflow\)', main.last_response):
- main.log.info("Openflow mode enabled"+main.last_response)
- return main.TRUE
- else :
- main.log.warn("Fail to enable Openflow mode"+main.last_response)
- return main.FALSE
-
-
- def add_openflow_controller(self,**controllerargs):
- for key in controllerargs:
- vars(self)[key] = controllerargs[key]
-
- if not self.openflow_mode():
- return main.FALSE
-
- contoller_details = 'controller-id '+ self.controller_id+'ip '+self.controller_ip + 'controller-interface vlan '+self.interface_vlan_id
- self.execute(cmd=contoller_details, prompt = '\(openflow\)',timeout = 3)
-
- if re.search('already\sconfigured', main.last_response):
- main.log.warn("A controller is already configured with this ID."+main.last_response)
- return main.FALSE
- elif re.search('Incomplete\sinput',main.last_response ) :
- main.log.warn("Incomplete\sinput"+main.last_response)
- return main.FALSE
- else:
- main.log.info("Successfully added Openflow Controller")
- return main.TRUE
-
-
- def create_openflow_instance(self,**instanceargs):
- for key in instanceargs:
- vars(self)[key] = instanceargs[key]
-
- if not self.openflow_mode():
- return main.FALSE
-
- if self.instance_name :
- self.execute(cmd='instance '+self.instance_name, prompt = '\(of-inst-'+self.instance_name+'\)',timeout = 3)
-
- if re.search('\(of-inst-'+self.instance_name+'\)', main.last_response):
- main.log.info("Configuring Openflow instance "+self.instance_name)
- else :
- main.log.warn("Fail to configure Openflow instance"+self.instance_name+"\n\n"+main.last_response)
- return main.FALSE
- if self.controller_id :
- self.execute(cmd='controller-id '+self.controller_id, prompt = '\(of-inst-'+self.instance_name+'\)',timeout = 3)
- main.log.info(main.last_response)
-
- if self.member :
- self.execute(cmd='member vlan '+self.member_vlan_id, prompt = '\(of-inst-'+self.instance_name+'\)',timeout = 3)
- main.log.info(main.last_response)
-
- if self.execute(cmd='enable', prompt = '\(of-inst-'+self.instance_name+'\)',timeout = 3):
- return main.TRUE
- else :
- return main.FALSE
-
- def pair_vlan_with_openflow_instance(self,vlan_id):
- self.configure()
- self.execute(cmd='vlan '+vlan_id, prompt = '\(vlan-'+vlan_id+'\)',timeout = 3)
- if re.search('\(vlan-'+vlan_id+'\)', main.last_response):
- main.log.info("Configuring VLAN "+vlan_id)
- else :
- main.log.warn("Fail to configure Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
-
- self.execute(cmd='openflow enable', prompt = '\(vlan-'+vlan_id+'\)',timeout = 3)
- if re.search('\(vlan-'+vlan_id+'\)', main.last_response):
- main.log.info("Configuring VLAN "+vlan_id)
- else :
- main.log.warn("Fail to configure Vlan"+self.vlan_id+main.last_response)
- return main.FALSE
-
- def show_openflow_instance(self,instance_name):
-
- self.execute(cmd='show openflow instance '+instance_name, prompt = '#',timeout = 3)
- return main.TRUE
-
- def show(self, command):
- self.execute(cmd=command, prompt = '#',timeout = 3)
- return main.TRUE
-
-
- def openflow_enable(self):
- self.configure()
- self.execute(cmd='openflow enable', prompt = '#',timeout = 3)
- return main.TRUE
-
- def openflow_disable(self):
- self.configure()
- self.execute(cmd='openflow enable', prompt = '#',timeout = 3)
- return main.TRUE
-
- def remove_controller(self,controller_id):
- self.configure()
- self.execute(cmd='no controller-id '+controller_id, prompt = '#',timeout = 3)
- return main.TRUE
-
- def remove_vlan(self,vlan_id):
- self.configure()
- if self.execute(cmd='no vlan '+vlan_id, prompt = '#',timeout = 3):
- return main.TRUE
- else :
- self.execute(cmd=' '+vlan_id, prompt = '#',timeout = 3)
- return main.TRUE
-
- def remove_openflow_instance(self,instance_name):
- self.configure()
- self.execute(cmd='no openflow instance '+instance_name, prompt = '#',timeout = 3)
- return main.TRUE
diff --git a/TestON/scripts/get_reroute_times.py b/TestON/scripts/get_reroute_times.py
deleted file mode 100755
index 4e1f6b8..0000000
--- a/TestON/scripts/get_reroute_times.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#! /usr/bin/env python
-import sys
-import time
-import os
-import re
-import json
-
-
-CONFIG_FILE="/home/admin/ping.h10"
-
-
-
-def get_times(pingfile):
- icmp_reqs = []
- times = []
- f = open(pingfile)
- for line in f.readlines():
- if re.search('64\sbytes', line):
- icmp_reqs.append( (line.split()[4]).split('=')[1] )
- f.close()
- #print icmp_reqs
- lastnum = int(icmp_reqs[0]) - 1
- for num in icmp_reqs:
- if int(num) != (lastnum + 1):
- times.append(int(num) - lastnum)
- lastnum = int(num)
-
- return times
-
-if __name__ == "__main__":
- total = 0
- count = 0
- flow = 1
- for i in os.popen("ls /tmp/ping.*"):
- print "Flow %d " % flow
- for time in get_times(i.strip("\n")):
- total = total + time
- count = count + 1
- print " %d" % time
- flow = flow + 1
- print "Average: %d" % (total / count )
-
diff --git a/TestON/tests/ClassTest/ClassTest.topo b/TestON/tests/ClassTest/ClassTest.topo
index 4ecb7ed..1c8bc4f 100644
--- a/TestON/tests/ClassTest/ClassTest.topo
+++ b/TestON/tests/ClassTest/ClassTest.topo
@@ -1,18 +1,18 @@
<TOPOLOGY>
<COMPONENT>
<ONOSbench>
- <host>10.128.174.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOSbench>
<Mininet1>
- <host>10.128.10.90</host>
+ <host>10.128.10.24</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>MininetCliDriver</type>
<connect_order>2</connect_order>
<COMPONENTS>
diff --git a/TestON/tests/IntentsLoad/IntentsLoad.params b/TestON/tests/IntentsLoad/IntentsLoad.params
new file mode 100644
index 0000000..b60621c
--- /dev/null
+++ b/TestON/tests/IntentsLoad/IntentsLoad.params
@@ -0,0 +1,49 @@
+<PARAMS>
+
+ <testcases>1,2,4</testcases>
+
+ <ENV>
+ <cellName>cam_cells</cellName>
+ </ENV>
+
+ <SCALE>1</SCALE>
+
+ <GIT>
+ <autopull>off</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+ <ip1>10.128.5.51</ip1>
+ <port1>6633</port1>
+ <ip2>10.128.5.52</ip2>
+ <port2>6633</port2>
+ <ip3>10.128.5.53</ip3>
+ <port3>6633</port3>
+ </CTRL>
+
+ <MN>
+ <ip1>10.128.5.59</ip1>
+ <ip2>10.128.5.59</ip2>
+ </MN>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.128.5.55</ip1>
+ </BENCH>
+
+ <TEST>
+ <loadstart>curl --fail http://localhost:8181/onos/demo/intents/setup -H "Content-Type:application/json" -d '{"type" : "random"}'</loadstart>
+ <loadstop>curl --fail http://localhost:8181/onos/demo/intents/teardown</loadstop>
+ <arping>py [h.cmd("arping -c 1 -w 1 10.0.0.225") for h in net.hosts]</arping>
+ <metric1>intents-events-metrics|grep "Intent Installed Events"</metric1>
+ <duration>90</duration>
+ <log_interval>5</log_interval>
+ </TEST>
+
+ <JSON>
+ <intents_rate>intentInstalledRate</intents_rate>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/IntentsLoad/IntentsLoad.py b/TestON/tests/IntentsLoad/IntentsLoad.py
new file mode 100644
index 0000000..f13e60d
--- /dev/null
+++ b/TestON/tests/IntentsLoad/IntentsLoad.py
@@ -0,0 +1,263 @@
+# ScaleOutTemplate --> IntentsLoad
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os
+
+
+class IntentsLoad:
+ def __init__(self):
+ self.default = ''
+
+ def CASE1(self, main):
+
+ global cluster_count
+ cluster_count = 1
+
+ checkout_branch = main.params['GIT']['checkout']
+ git_pull = main.params['GIT']['autopull']
+ cell_name = main.params['ENV']['cellName']
+ BENCH_ip = main.params['BENCH']['ip1']
+ BENCH_user = main.params['BENCH']['user']
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ MN1_ip = main.params['MN']['ip1']
+
+ main.log.step("Cleaning Enviornment...")
+ main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.ONOSbench.onos_uninstall(ONOS2_ip)
+ main.ONOSbench.onos_uninstall(ONOS3_ip)
+
+ main.step("Git checkout and pull "+checkout_branch)
+ if git_pull == 'on':
+ checkout_result = main.ONOSbench.git_checkout(checkout_branch)
+ pull_result = main.ONOSbench.git_pull()
+
+ else:
+ checkout_result = main.TRUE
+ pull_result = main.TRUE
+ main.log.info("Skipped git checkout and pull")
+
+ #mvn_result = main.ONOSbench.clean_install()
+
+ main.step("Set cell for ONOS cli env")
+ main.ONOS1cli.set_cell(cell_name)
+ main.ONOS2cli.set_cell(cell_name)
+ main.ONOS3cli.set_cell(cell_name)
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package() #no file or directory
+
+ main.step("Installing ONOS package")
+ install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
+
+ cell_name = main.params['ENV']['cellName']
+ main.step("Applying cell file to environment")
+ cell_apply_result = main.ONOSbench.set_cell(cell_name)
+ main.step("verify cells")
+ verify_cell_result = main.ONOSbench.verify_cell()
+
+ main.step("Set cell for ONOS cli env")
+ main.ONOS1cli.set_cell(cell_name)
+
+ cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+
+ def CASE2(self, main):
+
+ '''
+ Increase number of nodes and initiate CLI
+ '''
+ import time
+
+ global cluster_count
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ #ONOS4_ip = main.params['CTRL']['ip4']
+ #ONOS5_ip = main.params['CTRL']['ip5']
+ #ONOS6_ip = main.params['CTRL']['ip6']
+ #ONOS7_ip = main.params['CTRL']['ip7']
+ cell_name = main.params['ENV']['cellName']
+ scale = int(main.params['SCALE'])
+
+
+ #Cluster size increased everytime the case is defined
+ cluster_count += scale
+
+ main.log.report("Increasing cluster size to "+
+ str(cluster_count))
+ install_result = main.FALSE
+
+ if scale == 2:
+ if cluster_count == 3:
+ main.log.info("Installing nodes 2 and 3")
+ install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
+ install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
+ cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+ '''
+ elif cluster_count == 5:
+
+ main.log.info("Installing nodes 4 and 5")
+ node4_result = main.ONOSbench.onos_install(node=ONOS4_ip)
+ node5_result = main.ONOSbench.onos_install(node=ONOS5_ip)
+ install_result = node4_result and node5_result
+ time.sleep(5)
+
+ main.ONOS4cli.start_onos_cli(ONOS4_ip)
+ main.ONOS5cli.start_onos_cli(ONOS5_ip)
+
+ elif cluster_count == 7:
+
+ main.log.info("Installing nodes 4 and 5")
+ node6_result = main.ONOSbench.onos_install(node=ONOS6_ip)
+ node7_result = main.ONOSbench.onos_install(node=ONOS7_ip)
+ install_result = node6_result and node7_result
+ time.sleep(5)
+
+ main.ONOS6cli.start_onos_cli(ONOS6_ip)
+ main.ONOS7cli.start_onos_cli(ONOS7_ip)
+ '''
+ if scale == 1:
+ if cluster_count == 2:
+ main.log.info("Installing node 2")
+ install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
+ cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
+
+ if cluster_count == 3:
+ main.log.info("Installing node 3")
+ install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+
+
+
+ def CASE3(self,main):
+ import time
+ import json
+ import string
+
+ intents_rate = main.params['JSON']['intents_rate']
+
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ main.Mininet1.assign_sw_controller(sw="1", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="2", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="3", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="4", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="5", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="6", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="7", ip1=ONOS1_ip, port1=default_sw_port )
+
+ mn_arp = main.params['TEST']['arping']
+ main.Mininet1.handle.sendline(mn_arp)
+
+ generate_load = main.params['TEST']['loadstart']
+
+ main.ONOS1.handle.sendline(generate_load)
+ main.ONOS1.handle.expect("sdn")
+ print("before: ", main.ONOS1.handle.before)
+ print("after: ",main.ONOS1.handle.after)
+
+ load_confirm = main.ONOS1.handle.after
+ if load_confirm == "{}":
+ main.log.info("Load started")
+
+ else:
+ main.log.error("Load start failure")
+ main.log.error("expected '{}', got: " + str(load_confirm))
+
+ devices_json_str = main.ONOS1cli.devices()
+ devices_json_obj = json.loads(devices_json_str)
+
+ get_metric = main.params['TEST']['metric1']
+ test_duration = main.params['TEST']['duration']
+ stop = time.time() + float(test_duration)
+
+
+ main.log.info("Starting test loop...")
+ log_interval = main.params['TEST']['log_interval']
+
+ while time.time() < stop:
+ time.sleep(float(log_interval))
+
+ intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
+ intents_json_obj_1 = json.loads(intents_json_str_1)
+ main.log.info("Node 1 rate: " + str(intents_json_obj_1[intents_rate]['m1_rate']))
+ last_rate_1 = intents_json_obj_1[intents_rate]['m1_rate']
+
+ stop_load = main.params['TEST']['loadstop']
+ main.ONOS1.handle.sendline(stop_load)
+
+
+ msg = ("Final rate on node 1: " + str(last_rate_1))
+ main.log.report(msg)
+
+ def CASE4(self, main): #2 node scale
+ import time
+ import json
+ import string
+
+ intents_rate = main.params['JSON']['intents_rate']
+
+ default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+ main.Mininet1.assign_sw_controller(sw="1", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="2", ip1=ONOS2_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="3", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="4", ip1=ONOS2_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="5", ip1=ONOS1_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="6", ip1=ONOS2_ip, port1=default_sw_port )
+ main.Mininet1.assign_sw_controller(sw="7", ip1=ONOS1_ip, port1=default_sw_port )
+
+ mn_arp = main.params['TEST']['arping']
+ main.Mininet1.handle.sendline(mn_arp)
+
+ generate_load = main.params['TEST']['loadstart']
+
+ main.ONOS1.handle.sendline(generate_load)
+ main.ONOS2.handle.sendline(generate_load)
+
+ devices_json_str_1 = main.ONOS1cli.devices()
+ devices_json_obj_1 = json.loads(devices_json_str_1)
+ devices_json_str_2 = main.ONOS2cli.devices()
+ devices_json_obj_2 = json.loads(devices_json_str_2)
+
+ get_metric = main.params['TEST']['metric1']
+ test_duration = main.params['TEST']['duration']
+ stop = time.time() + float(test_duration)
+
+
+ main.log.info("Starting test loop...")
+ log_interval = main.params['TEST']['log_interval']
+
+ while time.time() < stop:
+ time.sleep(float(log_interval))
+
+ intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
+ intents_json_obj_1 = json.loads(intents_json_str_1)
+ main.log.info("Node 1 rate: " + str(intents_json_obj_1[intents_rate]['m1_rate']))
+ last_rate_1 = intents_json_obj_1[intents_rate]['m1_rate']
+
+ intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
+ intents_json_obj_2 = json.loads(intents_json_str_2)
+ main.log.info("Node 2 rate: " + str(intents_json_obj_2[intents_rate]['m1_rate']))
+ last_rate_2 = intents_json_obj_2[intents_rate]['m1_rate']
+
+ stop_load = main.params['TEST']['loadstop']
+ main.ONOS1.handle.sendline(stop_load)
+ main.ONOS2.handle.sendline(stop_load)
+
+
+ msg = ("Final rate on node 1: " + str(last_rate_1))
+ main.log.report(msg)
+
+ msg = ("Final rate on node 2: " + str(last_rate_2))
+ main.log.report(msg)
+
+
+
diff --git a/TestON/tests/IntentsLoad/IntentsLoad.topo b/TestON/tests/IntentsLoad/IntentsLoad.topo
new file mode 100644
index 0000000..985baf9
--- /dev/null
+++ b/TestON/tests/IntentsLoad/IntentsLoad.topo
@@ -0,0 +1,94 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS1>
+ <host>10.128.5.51</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.5.52</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.5.53</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <Mininet1>
+ <host>10.128.5.59</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ <arg1> --custom ~/topo-intentTPtest.py </arg1>
+ <arg2> --mac --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.5.59</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+
+</TOPOLOGY>
+
diff --git a/TestON/tests/IntentsLoad/__init__.py b/TestON/tests/IntentsLoad/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/IntentsLoad/__init__.py
diff --git a/TestON/tests/LincOETest/LincOETest.topo b/TestON/tests/LincOETest/LincOETest.topo
index 9881845..5d572ca 100755
--- a/TestON/tests/LincOETest/LincOETest.topo
+++ b/TestON/tests/LincOETest/LincOETest.topo
@@ -20,7 +20,7 @@
</ONOScli>
<ONOS1>
- <host>10.128.174.1<</host>
+ <host>10.128.174.1</host>
<user>sdn</user>
<password>rocks</password>
<type>OnosDriver</type>
diff --git a/TestON/tests/PingallExample/PingallExample.params b/TestON/tests/PingallExample/PingallExample.params
index 8d0d10b..aecaab6 100644
--- a/TestON/tests/PingallExample/PingallExample.params
+++ b/TestON/tests/PingallExample/PingallExample.params
@@ -1,12 +1,12 @@
<PARAMS>
<testcases>1,2,3</testcases>
<ENV>
- <cellName>kelvin</cellName>
+ <cellName>HA</cellName>
</ENV>
<Git>True</Git>
<CTRL>
- <ip1>10.128.10.21</ip1>
+ <ip1>10.128.30.11</ip1>
<port1>6633</port1>
</CTRL>
</PARAMS>
diff --git a/TestON/tests/PingallExample/PingallExample.py b/TestON/tests/PingallExample/PingallExample.py
index faf374f..bb2b1cf 100644
--- a/TestON/tests/PingallExample/PingallExample.py
+++ b/TestON/tests/PingallExample/PingallExample.py
@@ -8,10 +8,10 @@
"""
class PingallExample:
- def __init__( self ) :
+ def __init__( self ):
self.default = ''
- def CASE1( self, main ) :
+ def CASE1( self, main ):
"""
CASE1 is to compile ONOS and push it to the test machines
@@ -29,73 +29,73 @@
main.case( "Setting up test environment" )
# load some vairables from the params file
- PULL_CODE = False
+ PULLCODE = False
if main.params[ 'Git' ] == 'True':
- PULL_CODE = True
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
+ PULLCODE = True
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.step( "Applying cell variable to environment" )
- cell_result = main.ONOSbench.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onos_uninstall( ONOS1_ip )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
- clean_install_result = main.TRUE
- git_pull_result = main.TRUE
+ cleanInstallResult = main.TRUE
+ gitPullResult = main.TRUE
main.step( "Compiling the latest version of ONOS" )
- if PULL_CODE:
+ if PULLCODE:
main.step( "Git checkout and pull master" )
- main.ONOSbench.git_checkout( "master" )
- git_pull_result = main.ONOSbench.git_pull()
+ main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
main.step( "Using mvn clean & install" )
- clean_install_result = main.TRUE
- if git_pull_result == main.TRUE:
- clean_install_result = main.ONOSbench.clean_install()
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.ONOSbench.get_version( report=True )
+ main.ONOSbench.getVersion( report=True )
- cell_result = main.ONOSbench.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
main.step( "Creating ONOS package" )
- package_result = main.ONOSbench.onos_package()
+ packageResult = main.ONOSbench.onosPackage()
main.step( "Installing ONOS package" )
- onos1_install_result = main.ONOSbench.onos_install( options="-f",
- node=ONOS1_ip )
+ onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS1Ip )
main.step( "Checking if ONOS is up yet" )
for i in range( 2 ):
- onos1_isup = main.ONOSbench.isup( ONOS1_ip )
- if onos1_isup:
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if onos1Isup:
break
- if not onos1_isup:
+ if not onos1Isup:
main.log.report( "ONOS1 didn't start!" )
# TODO: if it becomes an issue, we can retry this step a few times
- cli_result = main.ONOScli1.start_onos_cli( ONOS1_ip )
+ cliResult = main.ONOScli1.startOnosCli( ONOS1Ip )
- case1_result = ( clean_install_result and package_result and
- cell_result and verify_result and
- onos1_install_result and
- onos1_isup and cli_result )
+ case1Result = ( cleanInstallResult and packageResult and
+ cellResult and verifyResult and
+ onos1InstallResult and
+ onos1Isup and cliResult )
- utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
onpass="Test startup successful",
onfail="Test startup NOT successful" )
- if case1_result == main.FALSE:
+ if case1Result == main.FALSE:
main.cleanup()
main.exit()
- def CASE2( self, main ) :
+ def CASE2( self, main ):
"""
Assign mastership to controller
"""
@@ -105,35 +105,35 @@
main.case( "Assigning Controller" )
main.step( "Assign switches to controller" )
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
for i in range( 1, 14 ):
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
- mastership_check = main.TRUE
+ mastershipCheck = main.TRUE
for i in range( 1, 14 ):
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
except:
main.log.info( repr( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- mastership_check = mastership_check and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
else:
- mastership_check = main.FALSE
- if mastership_check == main.TRUE:
+ mastershipCheck = main.FALSE
+ if mastershipCheck == main.TRUE:
main.log.report( "Switch mastership assigned correctly" )
utilities.assert_equals(
expect=main.TRUE,
- actual=mastership_check,
+ actual=mastershipCheck,
onpass="Switch mastership assigned correctly",
onfail="Switches not assigned correctly to controllers" )
- def CASE3( self, main ) :
+ def CASE3( self, main ):
"""
Assign intents
"""
@@ -144,19 +144,19 @@
# install onos-app-fwd
main.log.info( "Install reactive forwarding app" )
- main.ONOScli1.feature_install( "onos-app-fwd" )
+ main.ONOScli1.featureInstall( "onos-app-fwd" )
# REACTIVE FWD test
- ping_result = main.FALSE
+ pingResult = main.FALSE
time1 = time.time()
- ping_result = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall()
time2 = time.time()
main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
# uninstall onos-app-fwd
main.log.info( "Uninstall reactive forwarding app" )
- main.ONOScli1.feature_uninstall( "onos-app-fwd" )
+ main.ONOScli1.featureUninstall( "onos-app-fwd" )
- utilities.assert_equals( expect=main.TRUE, actual=ping_result,
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
onpass="All hosts are reachable",
onfail="Some pings failed" )
diff --git a/TestON/tests/PingallExample/PingallExample.topo b/TestON/tests/PingallExample/PingallExample.topo
index dba7a5d..1712756 100644
--- a/TestON/tests/PingallExample/PingallExample.topo
+++ b/TestON/tests/PingallExample/PingallExample.topo
@@ -2,7 +2,7 @@
<COMPONENT>
<ONOSbench>
- <host>10.128.10.20</host>
+ <host>10.128.30.10</host>
<user>admin</user>
<password></password>
<type>OnosDriver</type>
@@ -11,7 +11,7 @@
</ONOSbench>
<ONOScli1>
- <host>10.128.10.20</host>
+ <host>10.128.30.10</host>
<user>admin</user>
<password></password>
<type>OnosCliDriver</type>
@@ -20,16 +20,16 @@
</ONOScli1>
<ONOS1>
- <host>10.128.10.21</host>
- <user>admin</user>
- <password></password>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
<Mininet1>
- <host>10.128.10.20</host>
+ <host>10.128.30.9</host>
<user>admin</user>
<password></password>
<type>MininetCliDriver</type>
diff --git a/TestON/tests/ProdFunc/ProdFunc.params b/TestON/tests/ProdFunc/ProdFunc.params
index 5de8118..1189301 100755
--- a/TestON/tests/ProdFunc/ProdFunc.params
+++ b/TestON/tests/ProdFunc/ProdFunc.params
@@ -1,7 +1,6 @@
<PARAMS>
<testcases>1,4,10,5,6,7,8,9,2,8,20,21,22,10,23,24</testcases>
-
#Environment variables
<ENV>
<cellName>driver_test</cellName>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
old mode 100644
new mode 100755
index 62d1ec8..40d43ae
--- a/TestON/tests/ProdFunc/ProdFunc.py
+++ b/TestON/tests/ProdFunc/ProdFunc.py
@@ -3,9 +3,9 @@
# For sanity and driver functionality excercises only.
import time
-import sys
-import os
-import re
+# import sys
+# import os
+# import re
import json
time.sleep( 1 )
@@ -28,9 +28,8 @@
onos-install -f
onos-wait-for-start
"""
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.case( "Setting up test environment" )
main.log.report(
@@ -38,53 +37,53 @@
main.log.report( "__________________________________" )
main.step( "Applying cell variable to environment" )
- cell_result = main.ONOSbench.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onos_remove_raft_logs()
+ main.ONOSbench.onosRemoveRaftLogs()
main.step( "Git checkout and pull master and get version" )
- main.ONOSbench.git_checkout( "master" )
- git_pull_result = main.ONOSbench.git_pull()
- main.log.info( "git_pull_result = " + git_pull_result )
- version_result = main.ONOSbench.get_version( report=True )
+ main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + gitPullResult )
+ main.ONOSbench.getVersion( report=True )
- if git_pull_result == 1:
+ if gitPullResult == 1:
main.step( "Using mvn clean & install" )
- clean_install_result = main.ONOSbench.clean_install()
- #clean_install_result = main.TRUE
- elif git_pull_result == 0:
+ main.ONOSbench.cleanInstall()
+ elif gitPullResult == 0:
main.log.report(
"Git Pull Failed, look into logs for detailed reason" )
main.cleanup()
main.exit()
main.step( "Creating ONOS package" )
- package_result = main.ONOSbench.onos_package()
+ packageResult = main.ONOSbench.onosPackage()
main.step( "Installing ONOS package" )
- onos_install_result = main.ONOSbench.onos_install()
- if onos_install_result == main.TRUE:
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
main.log.report( "Installing ONOS package successful" )
else:
main.log.report( "Installing ONOS package failed" )
- onos1_isup = main.ONOSbench.isup()
- if onos1_isup == main.TRUE:
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up" )
main.step( "Starting ONOS service" )
- start_result = main.ONOSbench.onos_start( ONOS1_ip )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
- main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case1_result = ( package_result and
- cell_result and verify_result and onos_install_result and
- onos1_isup and start_result )
- utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ case1Result = ( packageResult and
+ cellResult and verifyResult
+ and onosInstallResult and
+ onos1Isup and startResult )
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
onpass="Test startup successful",
onfail="Test startup NOT successful" )
@@ -94,13 +93,12 @@
"""
# NOTE: You should probably run a topology check after this
import time
- import json
main.case( "Switch down discovery" )
main.log.report( "This testcase is testing a switch down discovery" )
main.log.report( "__________________________________" )
- switch_sleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+ switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
main.log.report( description )
@@ -110,120 +108,125 @@
main.step( "Kill s28 " )
main.log.report( "Deleting s28" )
# FIXME: use new dynamic topo functions
- main.Mininet1.del_switch( "s28" )
+ main.Mininet1.delSwitch( "s28" )
main.log.info(
"Waiting " +
- str( switch_sleep ) +
+ str( switchSleep ) +
" seconds for switch down to be discovered" )
- time.sleep( switch_sleep )
+ time.sleep( switchSleep )
# Peek at the deleted switch
- device = main.ONOS2.get_device( dpid="0028" )
+ device = main.ONOS2.getDevice( dpid="0028" )
print "device = ", device
if device[ u'available' ] == 'False':
- case2_result = main.FALSE
+ case2Result = main.FALSE
else:
- case2_result = main.TRUE
- utilities.assert_equals( expect=main.TRUE, actual=case2_result,
+ case2Result = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=case2Result,
onpass="Switch down discovery successful",
onfail="Switch down discovery failed" )
def CASE11( self, main ):
"""
Cleanup sequence:
- onos-service <node_ip> stop
+ onos-service <nodeIp> stop
onos-uninstall
TODO: Define rest of cleanup
"""
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.case( "Cleaning up test environment" )
main.step( "Testing ONOS kill function" )
- kill_result = main.ONOSbench.onos_kill( ONOS1_ip )
+ killResult = main.ONOSbench.onosKill( ONOS1Ip )
main.step( "Stopping ONOS service" )
- stop_result = main.ONOSbench.onos_stop( ONOS1_ip )
+ stopResult = main.ONOSbench.onosStop( ONOS1Ip )
main.step( "Uninstalling ONOS service" )
- uninstall_result = main.ONOSbench.onos_uninstall()
+ uninstallResult = main.ONOSbench.onosUninstall()
+
+ case11Result = killResult and stopResult and uninstallResult
+ utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+ onpass="Cleanup successful",
+ onfail="Cleanup failed" )
def CASE3( self, main ):
"""
Test 'onos' command and its functionality in driver
"""
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.case( "Testing 'onos' command" )
main.step( "Sending command 'onos -w <onos-ip> system:name'" )
cmdstr1 = "system:name"
- cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmd_result1 )
+ cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmdResult1 )
main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
cmdstr2 = "onos:topology"
- cmd_result2 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result2 )
+ cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmdResult2 )
def CASE20( self ):
"""
Exit from mininet cli
reinstall ONOS
"""
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.log.report(
- "This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology" )
+ main.log.report( "This testcase exits the mininet cli and reinstalls\
+ ONOS to switch over to Packet Optical topology" )
main.log.report( "_____________________________________________" )
main.case( "Disconnecting mininet and restarting ONOS" )
main.step( "Disconnecting mininet and restarting ONOS" )
- mininet_disconnect = main.Mininet1.disconnect()
+ mininetDisconnect = main.Mininet1.disconnect()
main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onos_remove_raft_logs()
+ main.ONOSbench.onosRemoveRaftLogs()
main.step( "Applying cell variable to environment" )
- cell_result = main.ONOSbench.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
- onos_install_result = main.ONOSbench.onos_install()
- if onos_install_result == main.TRUE:
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
main.log.report( "Installing ONOS package successful" )
else:
main.log.report( "Installing ONOS package failed" )
- onos1_isup = main.ONOSbench.isup()
- if onos1_isup == main.TRUE:
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up" )
main.step( "Starting ONOS service" )
- start_result = main.ONOSbench.onos_start( ONOS1_ip )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
- main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
- print "mininet_disconnect =", mininet_disconnect
- print "onos_install_result =", onos_install_result
- print "onos1_isup =", onos1_isup
- print "start_result =", start_result
-
- case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onos1Isup and \
+ startResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case20_result,
- onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
- onfail="Exiting functionality mininet topology and reinstalling ONOS failed" )
+ actual=case20Result,
+ onpass="Exiting functionality mininet topology and reinstalling \
+ ONOS successful",
+ onfail="Exiting functionality mininet topology and reinstalling \
+ ONOS failed" )
def CASE21( self, main ):
- import time
"""
- On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
- which starts the rest and copies the links json file to the onos instance
- Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
+ On ONOS bench, run this command:
+ ./~/ONOS/tools/test/bin/onos-topo-cfg
+ which starts the rest and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
from the json config file
"""
main.log.report(
@@ -231,42 +234,47 @@
main.log.report( "_____________________________________________" )
main.case( "Starting LINC-OE and other components" )
main.step( "Starting LINC-OE and other components" )
- start_console_result = main.LincOE1.start_console()
- optical_mn_script = main.LincOE2.run_optical_mn_script()
- onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(
- instance_name=main.params[ 'CTRL' ][ 'ip1' ],
- json_file=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+ startConsoleResult = main.LincOE1.startConsole()
+ opticalMnScript = main.LincOE2.runOpticalMnScript()
+ onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
+ instanceName=main.params[ 'CTRL' ][ 'ip1' ],
+ jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
- print "start_console_result =", start_console_result
- print "optical_mn_script = ", optical_mn_script
- print "onos_topo_cfg_result =", onos_topo_cfg_result
+ print "start_console_result =", startConsoleResult
+ print "optical_mn_script = ", opticalMnScript
+ print "onos_topo_cfg_result =", onosTopoCfgResult
- case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
+ case21Result = startConsoleResult and opticalMnScript and \
+ onosTopoCfgResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case21_result,
+ actual=case21Result,
onpass="Packet optical topology spawned successsfully",
onfail="Packet optical topology spawning failed" )
def CASE22( self, main ):
"""
- Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
- Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
- and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
+ Curretly we use, 4 linear switch optical topology and
+ 2 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 4,
+ packetLayerSWCount variable = 2 and hostCount = 2
+ and this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
"""
main.log.report(
- "This testcase compares the optical+packet topology against what is expected" )
+ "This testcase compares the optical+packet topology against what\
+ is expected" )
main.case( "Topology comparision" )
main.step( "Topology comparision" )
- main.ONOS3.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
- devices_result = main.ONOS3.devices( json_format=False )
+ main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
- print "devices_result = ", devices_result
- devices_linewise = devices_result.split( "\n" )
- devices_linewise = devices_linewise[ 1:-1 ]
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ devicesLinewise = devicesLinewise[ 1:-1 ]
roadmCount = 0
packetLayerSWCount = 0
- for line in devices_linewise:
+ for line in devicesLinewise:
components = line.split( "," )
availability = components[ 1 ].split( "=" )[ 1 ]
type = components[ 3 ].split( "=" )[ 1 ]
@@ -275,93 +283,101 @@
elif availability == 'true' and type == 'SWITCH':
packetLayerSWCount += 1
if roadmCount == 4:
- print "Number of Optical Switches = %d and is correctly detected" % roadmCount
+ print "Number of Optical Switches = %d and is \
+ correctly detected" % roadmCount
main.log.info(
"Number of Optical Switches = " +
str( roadmCount ) +
" and is correctly detected" )
- opticalSW_result = main.TRUE
+ opticalSWResult = main.TRUE
else:
- print "Number of Optical Switches = %d and is wrong" % roadCount
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
main.log.info(
"Number of Optical Switches = " +
str( roadmCount ) +
" and is wrong" )
- opticalSW_result = main.FALSE
+ opticalSWResult = main.FALSE
if packetLayerSWCount == 2:
- print "Number of Packet layer or mininet Switches = %d and is correctly detected" % packetLayerSWCount
+ print "Number of Packet layer or mininet Switches = %d and \
+ is correctly detected" % packetLayerSWCount
main.log.info(
"Number of Packet layer or mininet Switches = " +
str( packetLayerSWCount ) +
" and is correctly detected" )
- packetSW_result = main.TRUE
+ packetSWResult = main.TRUE
else:
- print "Number of Packet layer or mininet Switches = %d and is wrong" % packetLayerSWCount
+ print "Number of Packet layer or mininet Switches = %d and \
+ is wrong" % packetLayerSWCount
main.log.info(
"Number of Packet layer or mininet Switches = " +
str( packetLayerSWCount ) +
" and is wrong" )
- packetSW_result = main.FALSE
+ packetSWResult = main.FALSE
print "_________________________________"
- links_result = main.ONOS3.links( json_format=False )
- print "links_result = ", links_result
+ linksResult = main.ONOS3.links( jsonFormat=False )
+ print "links_result = ", linksResult
print "_________________________________"
- # NOTE:Since only point intents are added, there is no requirement to discover the hosts
+ # NOTE:Since only point intents are added, there is no
+ # requirement to discover the hosts
# Therfore, the below portion of the code is commented.
"""
#Discover hosts using pingall
- pingall_result = main.LincOE2.pingall()
+ pingallResult = main.LincOE2.pingall()
- hosts_result = main.ONOS3.hosts( json_format=False )
- main.log.info( "hosts_result = "+hosts_result )
+ hostsResult = main.ONOS3.hosts( jsonFormat=False )
+ main.log.info( "hosts_result = "+hostsResult )
main.log.info( "_________________________________" )
- hosts_linewise = hosts_result.split( "\n" )
- hosts_linewise = hosts_linewise[ 1:-1 ]
+ hostsLinewise = hostsResult.split( "\n" )
+ hostsLinewise = hostsLinewise[ 1:-1 ]
hostCount = 0
- for line in hosts_linewise:
+ for line in hostsLinewise:
hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
hostCount +=1
if hostCount ==2:
print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and is correctly detected" )
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is correctly detected" )
hostDiscovery = main.TRUE
else:
print "Number of hosts = %d and is wrong" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and is wrong" )
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is wrong" )
hostDiscovery = main.FALSE
"""
- case22_result = opticalSW_result and packetSW_result
+ case22Result = opticalSWResult and packetSWResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case22_result,
+ actual=case22Result,
onpass="Packet optical topology discovery successful",
onfail="Packet optical topology discovery failed" )
def CASE23( self, main ):
import time
"""
- Add bidirectional point intents between 2 packet layer( mininet ) devices and
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
ping mininet hosts
"""
main.log.report(
- "This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts" )
+ "This testcase adds bidirectional point intents between 2 \
+ packet layer( mininet ) devices and ping mininet hosts" )
main.case( "Topology comparision" )
main.step( "Adding point intents" )
- ptp_intent_result = main.ONOS3.add_point_intent(
+ ptpIntentResult = main.ONOS3.addPointIntent(
"of:0000ffffffff0001/1",
"of:0000ffffffff0002/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents( json_format=False )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
- ptp_intent_result = main.ONOS3.add_point_intent(
+ ptpIntentResult = main.ONOS3.addPointIntent(
"of:0000ffffffff0002/1",
"of:0000ffffffff0001/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents( json_format=False )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
time.sleep( 10 )
@@ -370,17 +386,17 @@
# Sleep for 30 seconds to provide time for the intent state to change
time.sleep( 30 )
- intentHandle = main.ONOS3.intents( json_format=False )
+ intentHandle = main.ONOS3.intents( jsonFormat=False )
main.log.info( "intents :" + intentHandle )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
count = 1
main.log.info( "\n\nh1 is Pinging h2" )
ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
- #ping = main.LincOE2.pinghost()
+ # ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
main.log.info(
"Ping between h1 and h2 failed. Making attempt number " +
str( count ) +
@@ -388,82 +404,91 @@
time.sleep( 2 )
elif ping == main.FALSE:
main.log.info( "All ping attempts between h1 and h2 have failed" )
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h1 and h2 passed!" )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report(
- "Point intents for packet optical have not ben installed correctly. Cleaning up" )
- if Ping_Result == main.TRUE:
+ "Point intents for packet optical have not ben installed\
+ correctly. Cleaning up" )
+ if PingResult == main.TRUE:
main.log.report(
- "Point Intents for packet optical have been installed correctly" )
+ "Point Intents for packet optical have been\
+ installed correctly" )
- case23_result = Ping_Result
+ case23Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case23_result,
- onpass="Point intents addition for packet optical and Pingall Test successful",
- onfail="Point intents addition for packet optical and Pingall Test NOT successful" )
+ actual=case23Result,
+ onpass="Point intents addition for packet optical and\
+ Pingall Test successful",
+ onfail="Point intents addition for packet optical and\
+ Pingall Test NOT successful" )
def CASE24( self, main ):
import time
import json
"""
- Test Rerouting of Packet Optical by bringing a port down ( port 22 ) of a switch( switchID=1 ), so that link ( between switch1 port22 - switch4-port30 ) is inactive
- and do a ping test. If rerouting is successful, ping should pass. also check the flows
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 22 ) of a switch( switchID=1 ), so that link
+ ( between switch1 port22 - switch4-port30 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
"""
main.log.report(
"This testcase tests rerouting and pings mininet hosts" )
main.case( "Test rerouting and pings mininet hosts" )
main.step( "Bring a port down and verify the link state" )
- main.LincOE1.port_down( sw_id="1", pt_id="22" )
- links_nonjson = main.ONOS3.links( json_format=False )
- main.log.info( "links = " + links_nonjson )
+ main.LincOE1.portDown( swId="1", ptId="22" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
links = main.ONOS3.links()
main.log.info( "links = " + links )
- links_result = json.loads( links )
- links_state_result = main.FALSE
- for item in links_result:
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
'src' ][ 'port' ] == "22":
if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
'dst' ][ 'port' ] == "30":
- links_state = item[ 'state' ]
- if links_state == "INACTIVE":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
main.log.info(
- "Links state is inactive as expected due to one of the ports being down" )
+ "Links state is inactive as expected due to one \
+ of the ports being down" )
main.log.report(
- "Links state is inactive as expected due to one of the ports being down" )
- links_state_result = main.TRUE
+ "Links state is inactive as expected due to one \
+ of the ports being down" )
+ linksStateResult = main.TRUE
break
else:
main.log.info(
"Links state is not inactive as expected" )
main.log.report(
"Links state is not inactive as expected" )
- links_state_result = main.FALSE
+ linksStateResult = main.FALSE
- print "links_state_result = ", links_state_result
+ print "links_state_result = ", linksStateResult
time.sleep( 10 )
flowHandle = main.ONOS3.flows()
main.log.info( "flows :" + flowHandle )
main.step( "Verify Rerouting by a ping test" )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
count = 1
main.log.info( "\n\nh1 is Pinging h2" )
ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
- #ping = main.LincOE2.pinghost()
+ # ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
main.log.info(
"Ping between h1 and h2 failed. Making attempt number " +
str( count ) +
@@ -471,159 +496,163 @@
time.sleep( 2 )
elif ping == main.FALSE:
main.log.info( "All ping attempts between h1 and h2 have failed" )
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h1 and h2 passed!" )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report( "Ping test successful " )
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report( "Ping test failed" )
- case24_result = Ping_Result and links_state_result
- utilities.assert_equals( expect=main.TRUE, actual=case24_result,
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
onpass="Packet optical rerouting successful",
onfail="Packet optical rerouting failed" )
def CASE4( self, main ):
import re
import time
- main.log.report(
- "This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode" )
+ main.log.report( "This testcase is testing the assignment of \
+ all the switches to all the controllers and \
+ discovering the hists in reactive mode" )
main.log.report( "__________________________________" )
main.case( "Pingall Test" )
main.step( "Assigning switches to controllers" )
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
for i in range( 1, 29 ):
if i == 1:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 2 and i < 5:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 5 and i < 8:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 8 and i < 18:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 18 and i < 28:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
else:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
- Switch_Mastership = main.TRUE
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ SwitchMastership = main.TRUE
for i in range( 1, 29 ):
if i == 1:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 2 and i < 5:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 5 and i < 8:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 8 and i < 18:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 18 and i < 28:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
else:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is" + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
- if Switch_Mastership == main.TRUE:
+ if SwitchMastership == main.TRUE:
main.log.report( "Controller assignmnet successful" )
else:
main.log.report( "Controller assignmnet failed" )
utilities.assert_equals(
expect=main.TRUE,
- actual=Switch_Mastership,
+ actual=SwitchMastership,
onpass="MasterControllers assigned correctly" )
"""
for i in range ( 1,29 ):
- main.Mininet1.assign_sw_controller( sw=str( i ),count=5,
- ip1=ONOS1_ip,port1=ONOS1_port,
- ip2=ONOS2_ip,port2=ONOS2_port,
- ip3=ONOS3_ip,port3=ONOS3_port,
- ip4=ONOS4_ip,port4=ONOS4_port,
- ip5=ONOS5_ip,port5=ONOS5_port )
+ main.Mininet1.assignSwController( sw=str( i ),count=5,
+ ip1=ONOS1Ip,port1=ONOS1Port,
+ ip2=ONOS2Ip,port2=ONOS2Port,
+ ip3=ONOS3Ip,port3=ONOS3Port,
+ ip4=ONOS4Ip,port4=ONOS4Port,
+ ip5=ONOS5Ip,port5=ONOS5Port )
"""
# REACTIVE FWD test
main.step( "Get list of hosts from Mininet" )
- host_list = main.Mininet1.get_hosts()
- main.log.info( host_list )
+ hostList = main.Mininet1.getHosts()
+ main.log.info( hostList )
main.step( "Get host list in ONOS format" )
- host_onos_list = main.ONOS2.get_hosts_id( host_list )
- main.log.info( host_onos_list )
+ hostOnosList = main.ONOS2.getHostsId( hostList )
+ main.log.info( hostOnosList )
# time.sleep( 5 )
main.step( "Pingall" )
- ping_result = main.FALSE
- while ping_result == main.FALSE:
+ pingResult = main.FALSE
+ while pingResult == main.FALSE:
time1 = time.time()
- ping_result = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall()
time2 = time.time()
print "Time for pingall: %2f seconds" % ( time2 - time1 )
- # Start onos cli again because u might have dropped out of onos prompt to the shell prompt
+ # Start onos cli again because u might have dropped out of
+ # onos prompt to the shell prompt
# if there was no activity
- main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case4_result = Switch_Mastership and ping_result
- if ping_result == main.TRUE:
- main.log.report(
- "Pingall Test in reactive mode to discover the hosts successful" )
+ case4Result = SwitchMastership and pingResult
+ if pingResult == main.TRUE:
+ main.log.report( "Pingall Test in reactive mode to \
+ discover the hosts successful" )
else:
- main.log.report(
- "Pingall Test in reactive mode to discover the hosts failed" )
+ main.log.report( "Pingall Test in reactive mode to \
+ discover the hosts failed" )
utilities.assert_equals(
expect=main.TRUE,
- actual=case4_result,
+ actual=case4Result,
onpass="Controller assignment and Pingall Test successful",
onfail="Controller assignment and Pingall Test NOT successful" )
@@ -633,74 +662,87 @@
main.log.report( "__________________________________" )
main.case( "Uninstalling reactive forwarding app" )
# Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result = main.ONOS2.feature_uninstall( "onos-app-fwd" )
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
main.log.info( "onos-app-fwd uninstalled" )
- # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
# So sleep for 15s
time.sleep( 15 )
flows = main.ONOS2.flows()
main.log.info( flows )
- case10_result = appUninstall_result
+ case10Result = appUninstallResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case10_result,
+ actual=case10Result,
onpass="Reactive forwarding app uninstallation successful",
onfail="Reactive forwarding app uninstallation failed" )
def CASE6( self ):
- main.log.report(
- "This testcase is testing the addition of host intents and then does pingall" )
+ main.log.report( "This testcase is testing the addition of \
+ host intents and then does pingall" )
main.log.report( "__________________________________" )
main.case( "Obtaining host id's" )
main.step( "Get hosts" )
hosts = main.ONOS2.hosts()
- # main.log.info( hosts )
+ main.log.info( hosts )
main.step( "Get all devices id" )
- devices_id_list = main.ONOS2.get_all_devices_id()
- # main.log.info( devices_id_list )
+ devicesIdList = main.ONOS2.getAllDevicesId()
+ main.log.info( devicesIdList )
- # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ # ONOS displays the hosts in hex format unlike mininet which does
+ # in decimal format
# So take care while adding intents
"""
- main.step( "Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
- print "_____________________________________________________________________________________"
+ main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
+ ONOS hosts h8 and h12" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ print "______________________________________________________"
"""
for i in range( 8, 18 ):
main.log.info(
- "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ "Adding host intent between h" + str( i ) +
+ " and h" + str( i + 10 ) )
host1 = "00:00:00:00:00:" + \
str( hex( i )[ 2: ] ).zfill( 2 ).upper()
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
# NOTE: get host can return None
# TODO: handle this
- host1_id = main.ONOS2.get_host( host1 )[ 'id' ]
- host2_id = main.ONOS2.get_host( host2 )[ 'id' ]
- tmp_result = main.ONOS2.add_host_intent( host1_id, host2_id )
+ host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+ host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
+ main.ONOS2.addHostIntent( host1Id, host2Id )
time.sleep( 10 )
- h_intents = main.ONOS2.intents( json_format=False )
- main.log.info( "intents:" + h_intents )
- flowHandle = main.ONOS2.flows()
- #main.log.info( "flow:" +flowHandle )
+ hIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intents:" + hIntents )
+ main.ONOS2.flows()
count = 1
i = 8
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
# while i<10:
while i < 18:
main.log.info(
@@ -709,8 +751,8 @@
src="h" + str( i ), target="h" + str( i + 10 ) )
if ping == main.FALSE and count < 5:
count += 1
- #i = 8
- Ping_Result = main.FALSE
+ # i = 8
+ PingResult = main.FALSE
main.log.report( "Ping between h" +
str( i ) +
" and h" +
@@ -728,7 +770,7 @@
10 ) +
"have failed" )
i = 19
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h" +
str( i ) +
@@ -737,39 +779,33 @@
10 ) +
"passed!" )
i += 1
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
- if Ping_Result == main.FALSE:
+ PingResult = main.ERROR
+ if PingResult == main.FALSE:
main.log.report(
- "Ping all test after Host intent addition failed. Cleaning up" )
+ "Ping all test after Host intent addition failed.Cleaning up" )
# main.cleanup()
# main.exit()
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report(
"Ping all test after Host intent addition successful" )
- case6_result = Ping_Result
+ case6Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case6_result,
+ actual=case6Result,
onpass="Pingall Test after Host intents addition successful",
onfail="Pingall Test after Host intents addition failed" )
def CASE5( self, main ):
import json
- from subprocess import Popen, PIPE
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- # main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
- deviceResult = main.ONOS2.devices()
- linksResult = main.ONOS2.links()
- #portsResult = main.ONOS2.ports()
- print "**************"
-
- main.log.report(
- "This testcase is testing if all ONOS nodes are in topology sync with mininet" )
+ # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.log.report( "This testcase is testing if all ONOS nodes \
+ are in topology sync with mininet" )
main.log.report( "__________________________________" )
main.case( "Comparing Mininet topology with the topology of ONOS" )
main.step( "Start continuous pings" )
@@ -836,22 +872,22 @@
ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
- Topology_Check = main.TRUE
+ TopologyCheck = main.TRUE
main.step( "Compare ONOS Topology to MN Topology" )
- devices_json = main.ONOS2.devices()
- links_json = main.ONOS2.links()
- #ports_json = main.ONOS2.ports()
- print "devices_json= ", devices_json
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ # portsJson = main.ONOS2.ports()
- result1 = main.Mininet1.compare_switches(
+ result1 = main.Mininet1.compareSwitches(
MNTopo,
- json.loads( devices_json ) )
- result2 = main.Mininet1.compare_links(
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
MNTopo,
- json.loads( links_json ) )
- #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
- #result = result1 and result2 and result3
+ # result = result1 and result2 and result3
result = result1 and result2
print "***********************"
@@ -868,55 +904,64 @@
onfail="ONOS" +
" Topology does not match MN Topology" )
- Topology_Check = Topology_Check and result
+ TopologyCheck = TopologyCheck and result
utilities.assert_equals(
expect=main.TRUE,
- actual=Topology_Check,
+ actual=TopologyCheck,
onpass="Topology checks passed",
onfail="Topology checks failed" )
def CASE7( self, main ):
+ from sts.topology.teston_topology import TestONTopology
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-
- main.log.report(
- "This testscase is killing a link to ensure that link discovery is consistent" )
+ main.log.report( "This testscase is killing a link to ensure that \
+ link discovery is consistent" )
main.log.report( "__________________________________" )
- main.log.report(
- "Killing a link to ensure that link discovery is consistent" )
- main.case(
- "Killing a link to Ensure that Link Discovery is Working Properly" )
+ main.log.report( "Killing a link to ensure that link discovery \
+ is consistent" )
+ main.case( "Killing a link to Ensure that Link Discovery \
+ is Working Properly" )
"""
main.step( "Start continuous pings" )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
- target=main.params[ 'PING' ][ 'target1' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
- target=main.params[ 'PING' ][ 'target2' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
- target=main.params[ 'PING' ][ 'target3' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
- target=main.params[ 'PING' ][ 'target4' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
- target=main.params[ 'PING' ][ 'target5' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
- target=main.params[ 'PING' ][ 'target6' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
- target=main.params[ 'PING' ][ 'target7' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
- target=main.params[ 'PING' ][ 'target8' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
- target=main.params[ 'PING' ][ 'target9' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
- target=main.params[ 'PING' ][ 'target10' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
"""
main.step( "Determine the current number of switches and links" )
- topology_output = main.ONOS2.topology()
- topology_result = main.ONOS1.get_topology( topology_output )
- activeSwitches = topology_result[ 'devices' ]
- links = topology_result[ 'links' ]
+ topologyOutput = main.ONOS2.topology()
+ topologyResult = main.ONOS1.getTopology( topologyOutput )
+ activeSwitches = topologyResult[ 'devices' ]
+ links = topologyResult[ 'links' ]
print "activeSwitches = ", type( activeSwitches )
print "links = ", type( links )
main.log.info(
@@ -925,39 +970,39 @@
main.step( "Kill Link between s3 and s28" )
main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
- time.sleep( link_sleep )
- topology_output = main.ONOS2.topology()
- Link_Down = main.ONOS1.check_status(
- topology_output, activeSwitches, str(
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkDown = main.ONOS1.checkStatus(
+ topologyOutput, activeSwitches, str(
int( links ) - 2 ) )
- if Link_Down == main.TRUE:
+ if LinkDown == main.TRUE:
main.log.report( "Link Down discovered properly" )
utilities.assert_equals(
expect=main.TRUE,
- actual=Link_Down,
+ actual=LinkDown,
onpass="Link Down discovered properly",
onfail="Link down was not discovered in " +
- str( link_sleep ) +
+ str( linkSleep ) +
" seconds" )
# Check ping result here..add code for it
main.step( "Bring link between s3 and s28 back up" )
- Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- time.sleep( link_sleep )
- topology_output = main.ONOS2.topology()
- Link_Up = main.ONOS1.check_status(
- topology_output,
+ LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkUp = main.ONOS1.checkStatus(
+ topologyOutput,
activeSwitches,
str( links ) )
- if Link_Up == main.TRUE:
+ if LinkUp == main.TRUE:
main.log.report( "Link up discovered properly" )
utilities.assert_equals(
expect=main.TRUE,
- actual=Link_Up,
+ actual=LinkUp,
onpass="Link up discovered properly",
onfail="Link up was not discovered in " +
- str( link_sleep ) +
+ str( linkSleep ) +
" seconds" )
# NOTE Check ping result here..add code for it
@@ -967,22 +1012,22 @@
main.Mininet1,
ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
- Topology_Check = main.TRUE
+ TopologyCheck = main.TRUE
- devices_json = main.ONOS2.devices()
- links_json = main.ONOS2.links()
- ports_json = main.ONOS2.ports()
- print "devices_json= ", devices_json
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ portsJson = main.ONOS2.ports()
- result1 = main.Mininet1.compare_switches(
+ result1 = main.Mininet1.compareSwitches(
MNTopo,
- json.loads( devices_json ) )
- result2 = main.Mininet1.compare_links(
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
MNTopo,
- json.loads( links_json ) )
- #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
- #result = result1 and result2 and result3
+ # result = result1 and result2 and result3
result = result1 and result2
print "***********************"
@@ -996,14 +1041,14 @@
onfail="ONOS" +
" Topology does not match MN Topology" )
- Topology_Check = Topology_Check and result
+ TopologyCheck = TopologyCheck and result
utilities.assert_equals(
expect=main.TRUE,
- actual=Topology_Check,
+ actual=TopologyCheck,
onpass="Topology checks passed",
onfail="Topology checks failed" )
- result = Link_Down and Link_Up and Topology_Check
+ result = LinkDown and LinkUp and TopologyCheck
utilities.assert_equals( expect=main.TRUE, actual=result,
onpass="Link failure is discovered correctly",
onfail="Link Discovery failed" )
@@ -1012,18 +1057,18 @@
"""
Host intents removal
"""
- main.log.report(
- "This testcase removes any previously added intents before adding the same intents or point intents" )
+ main.log.report( "This testcase removes any previously added intents \
+ before adding the same intents or point intents" )
main.log.report( "__________________________________" )
main.log.info( "Host intents removal" )
main.case( "Removing host intents" )
main.step( "Obtain the intent id's" )
- intent_result = main.ONOS2.intents( json_format=False )
- main.log.info( "intent_result = " + intent_result )
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
- intent_linewise = intent_result.split( "\n" )
+ intentLinewise = intentResult.split( "\n" )
intentList = []
- for line in intent_linewise:
+ for line in intentLinewise:
if line.startswith( "id=" ):
intentList.append( line )
@@ -1036,19 +1081,19 @@
main.step(
"Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOS2.remove_intent( intent_id=id )
+ main.ONOS2.removeIntent( intentId=id )
- intent_result = main.ONOS2.intents( json_format=False )
- main.log.info( "intent_result = " + intent_result )
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
- case8_result = main.TRUE
- if case8_result == main.TRUE:
+ case8Result = main.TRUE
+ if case8Result == main.TRUE:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- Ping_Result = main.TRUE
- if case8_result == main.TRUE:
+ PingResult = main.TRUE
+ if case8Result == main.TRUE:
i = 8
while i < 18:
main.log.info(
@@ -1057,33 +1102,33 @@
src="h" + str( i ), target="h" + str( i + 10 ) )
if ping == main.TRUE:
i = 19
- Ping_Result = Ping_Result and main.TRUE
+ PingResult = PingResult and main.TRUE
elif ping == main.FALSE:
i += 1
- Ping_Result = Ping_Result and main.FALSE
+ PingResult = PingResult and main.FALSE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report( "Host intents have not been withdrawn correctly" )
# main.cleanup()
# main.exit()
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report( "Host intents have been withdrawn correctly" )
- case8_result = case8_result and Ping_Result
+ case8Result = case8Result and PingResult
- if case8_result == main.FALSE:
+ if case8Result == main.FALSE:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- utilities.assert_equals( expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test passed" )
+ utilities.assert_equals( expect=main.FALSE, actual=case8Result,
+ onpass="Intent removal test passed",
+ onfail="Intent removal test failed" )
def CASE9( self ):
main.log.report(
@@ -1091,189 +1136,200 @@
main.log.report( "__________________________________" )
main.log.info( "Adding point intents" )
main.case(
- "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
- main.step(
- "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ "Adding bidirectional point for mn hosts \
+ ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,\
+ h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
+
+ var1 = "Add point intents for mn hosts h8 and h18 or \
+ ONOS hosts h8 and h12"
+ main.step(var1)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003008/1",
"of:0000000000006018/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006018/1",
"of:0000000000003008/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
+ main.step(var2)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003009/1",
"of:0000000000006019/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006019/1",
"of:0000000000003009/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
+ main.step(var3)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003010/1",
"of:0000000000006020/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006020/1",
"of:0000000000003010/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var4 = "Add point intents for mininet hosts h11 and h21 or \
+ ONOS hosts hB and h15"
+ main.case(var4)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003011/1",
"of:0000000000006021/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006021/1",
"of:0000000000003011/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var5 = "Add point intents for mininet hosts h12 and h22 \
+ ONOS hosts hC and h16"
+ main.case(var5)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003012/1",
"of:0000000000006022/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006022/1",
"of:0000000000003012/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var6 = "Add point intents for mininet hosts h13 and h23 or \
+ ONOS hosts hD and h17"
+ main.case(var6)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003013/1",
"of:0000000000006023/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006023/1",
"of:0000000000003013/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var7 = "Add point intents for mininet hosts h14 and h24 or \
+ ONOS hosts hE and h18"
+ main.case(var7)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003014/1",
"of:0000000000006024/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006024/1",
"of:0000000000003014/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var8 = "Add point intents for mininet hosts h15 and h25 or \
+ ONOS hosts hF and h19"
+ main.case(var8)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003015/1",
"of:0000000000006025/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006025/1",
"of:0000000000003015/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var9 = "Add intents for mininet hosts h16 and h26 or \
+ ONOS hosts h10 and h1A"
+ main.case(var9)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003016/1",
"of:0000000000006026/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006026/1",
"of:0000000000003016/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var10 = "Add point intents for mininet hosts h17 and h27 or \
+ ONOS hosts h11 and h1B"
+ main.case(var10)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003017/1",
"of:0000000000006027/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006027/1",
"of:0000000000003017/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ main.log.info( getIntentResult )
print(
- "_______________________________________________________________________________________" )
+ "___________________________________________________________" )
flowHandle = main.ONOS2.flows()
# print "flowHandle = ", flowHandle
@@ -1281,7 +1337,7 @@
count = 1
i = 8
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
while i < 18:
main.log.info(
"\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
@@ -1289,8 +1345,8 @@
src="h" + str( i ), target="h" + str( i + 10 ) )
if ping == main.FALSE and count < 5:
count += 1
- #i = 8
- Ping_Result = main.FALSE
+ # i = 8
+ PingResult = main.FALSE
main.log.report( "Ping between h" +
str( i ) +
" and h" +
@@ -1308,7 +1364,7 @@
10 ) +
"have failed" )
i = 19
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h" +
str( i ) +
@@ -1317,22 +1373,22 @@
10 ) +
"passed!" )
i += 1
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report(
"Point intents have not ben installed correctly. Cleaning up" )
# main.cleanup()
# main.exit()
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report( "Point Intents have been installed correctly" )
- case9_result = Ping_Result
+ case9Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case9_result,
+ actual=case9Result,
onpass="Point intents addition and Pingall Test successful",
onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
index 1775ebb..eaaee8d 100644
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -3,9 +3,9 @@
# For sanity and driver functionality excercises only.
import time
-import sys
-import os
-import re
+# import sys
+# import os
+# import re
import json
time.sleep( 1 )
@@ -28,9 +28,8 @@
onos-install -f
onos-wait-for-start
"""
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.case( "Setting up test environment" )
main.log.report(
@@ -38,53 +37,53 @@
main.log.report( "__________________________________" )
main.step( "Applying cell variable to environment" )
- cell_result = main.ONOSbench.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onos_remove_raft_logs()
+ main.ONOSbench.onosRemoveRaftLogs()
main.step( "Git checkout and pull master and get version" )
- main.ONOSbench.git_checkout( "master" )
- git_pull_result = main.ONOSbench.git_pull()
- main.log.info( "git_pull_result = " + git_pull_result )
- version_result = main.ONOSbench.get_version( report=True )
+ main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+ main.log.info( "git_pull_result = " + gitPullResult )
+ main.ONOSbench.getVersion( report=True )
- if git_pull_result == 1:
+ if gitPullResult == 1:
main.step( "Using mvn clean & install" )
- clean_install_result = main.ONOSbench.clean_install()
- #clean_install_result = main.TRUE
- elif git_pull_result == 0:
+ main.ONOSbench.cleanInstall()
+ elif gitPullResult == 0:
main.log.report(
"Git Pull Failed, look into logs for detailed reason" )
main.cleanup()
main.exit()
main.step( "Creating ONOS package" )
- package_result = main.ONOSbench.onos_package()
+ packageResult = main.ONOSbench.onosPackage()
main.step( "Installing ONOS package" )
- onos_install_result = main.ONOSbench.onos_install()
- if onos_install_result == main.TRUE:
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
main.log.report( "Installing ONOS package successful" )
else:
main.log.report( "Installing ONOS package failed" )
- onos1_isup = main.ONOSbench.isup()
- if onos1_isup == main.TRUE:
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up" )
main.step( "Starting ONOS service" )
- start_result = main.ONOSbench.onos_start( ONOS1_ip )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
- main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case1_result = ( package_result and
- cell_result and verify_result and onos_install_result and
- onos1_isup and start_result )
- utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+ case1Result = ( packageResult and
+ cellResult and verifyResult
+ and onosInstallResult and
+ onos1Isup and startResult )
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
onpass="Test startup successful",
onfail="Test startup NOT successful" )
@@ -94,13 +93,12 @@
"""
# NOTE: You should probably run a topology check after this
import time
- import json
main.case( "Switch down discovery" )
main.log.report( "This testcase is testing a switch down discovery" )
main.log.report( "__________________________________" )
- switch_sleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+ switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
main.log.report( description )
@@ -110,120 +108,125 @@
main.step( "Kill s28 " )
main.log.report( "Deleting s28" )
# FIXME: use new dynamic topo functions
- main.Mininet1.del_switch( "s28" )
+ main.Mininet1.delSwitch( "s28" )
main.log.info(
"Waiting " +
- str( switch_sleep ) +
+ str( switchSleep ) +
" seconds for switch down to be discovered" )
- time.sleep( switch_sleep )
+ time.sleep( switchSleep )
# Peek at the deleted switch
- device = main.ONOS2.get_device( dpid="0028" )
+ device = main.ONOS2.getDevice( dpid="0028" )
print "device = ", device
if device[ u'available' ] == 'False':
- case2_result = main.FALSE
+ case2Result = main.FALSE
else:
- case2_result = main.TRUE
- utilities.assert_equals( expect=main.TRUE, actual=case2_result,
+ case2Result = main.TRUE
+ utilities.assert_equals( expect=main.TRUE, actual=case2Result,
onpass="Switch down discovery successful",
onfail="Switch down discovery failed" )
def CASE11( self, main ):
"""
Cleanup sequence:
- onos-service <node_ip> stop
+ onos-service <nodeIp> stop
onos-uninstall
TODO: Define rest of cleanup
"""
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.case( "Cleaning up test environment" )
main.step( "Testing ONOS kill function" )
- kill_result = main.ONOSbench.onos_kill( ONOS1_ip )
+ killResult = main.ONOSbench.onosKill( ONOS1Ip )
main.step( "Stopping ONOS service" )
- stop_result = main.ONOSbench.onos_stop( ONOS1_ip )
+ stopResult = main.ONOSbench.onosStop( ONOS1Ip )
main.step( "Uninstalling ONOS service" )
- uninstall_result = main.ONOSbench.onos_uninstall()
+ uninstallResult = main.ONOSbench.onosUninstall()
+
+ case11Result = killResult and stopResult and uninstallResult
+ utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+ onpass="Cleanup successful",
+ onfail="Cleanup failed" )
def CASE3( self, main ):
"""
Test 'onos' command and its functionality in driver
"""
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
main.case( "Testing 'onos' command" )
main.step( "Sending command 'onos -w <onos-ip> system:name'" )
cmdstr1 = "system:name"
- cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
- main.log.info( "onos command returned: " + cmd_result1 )
+ cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
+ main.log.info( "onos command returned: " + cmdResult1 )
main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
cmdstr2 = "onos:topology"
- cmd_result2 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
- main.log.info( "onos command returned: " + cmd_result2 )
+ cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
+ main.log.info( "onos command returned: " + cmdResult2 )
def CASE20( self ):
"""
Exit from mininet cli
reinstall ONOS
"""
- cell_name = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- main.log.report(
- "This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology" )
+ main.log.report( "This testcase exits the mininet cli and reinstalls\
+ ONOS to switch over to Packet Optical topology" )
main.log.report( "_____________________________________________" )
main.case( "Disconnecting mininet and restarting ONOS" )
main.step( "Disconnecting mininet and restarting ONOS" )
- mininet_disconnect = main.Mininet1.disconnect()
+ mininetDisconnect = main.Mininet1.disconnect()
main.step( "Removing raft logs before a clen installation of ONOS" )
- main.ONOSbench.onos_remove_raft_logs()
+ main.ONOSbench.onosRemoveRaftLogs()
main.step( "Applying cell variable to environment" )
- cell_result = main.ONOSbench.set_cell( cell_name )
- verify_result = main.ONOSbench.verify_cell()
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
- onos_install_result = main.ONOSbench.onos_install()
- if onos_install_result == main.TRUE:
+ onosInstallResult = main.ONOSbench.onosInstall()
+ if onosInstallResult == main.TRUE:
main.log.report( "Installing ONOS package successful" )
else:
main.log.report( "Installing ONOS package failed" )
- onos1_isup = main.ONOSbench.isup()
- if onos1_isup == main.TRUE:
+ onos1Isup = main.ONOSbench.isup()
+ if onos1Isup == main.TRUE:
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up" )
main.step( "Starting ONOS service" )
- start_result = main.ONOSbench.onos_start( ONOS1_ip )
+ startResult = main.ONOSbench.onosStart( ONOS1Ip )
- main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
- print "mininet_disconnect =", mininet_disconnect
- print "onos_install_result =", onos_install_result
- print "onos1_isup =", onos1_isup
- print "start_result =", start_result
-
- case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ case20Result = mininetDisconnect and cellResult and verifyResult \
+ and onosInstallResult and onos1Isup and \
+ startResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case20_result,
- onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
- onfail="Exiting functionality mininet topology and reinstalling ONOS failed" )
+ actual=case20Result,
+ onpass="Exiting functionality mininet topology and reinstalling \
+ ONOS successful",
+ onfail="Exiting functionality mininet topology and reinstalling \
+ ONOS failed" )
def CASE21( self, main ):
- import time
"""
- On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
- which starts the rest and copies the links json file to the onos instance
- Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
+ On ONOS bench, run this command:
+ ./~/ONOS/tools/test/bin/onos-topo-cfg
+ which starts the rest and copies the links
+ json file to the onos instance.
+ Note that in case of Packet Optical, the links are not learnt
+ from the topology, instead the links are learnt
from the json config file
"""
main.log.report(
@@ -231,42 +234,47 @@
main.log.report( "_____________________________________________" )
main.case( "Starting LINC-OE and other components" )
main.step( "Starting LINC-OE and other components" )
- start_console_result = main.LincOE1.start_console()
- optical_mn_script = main.LincOE2.run_optical_mn_script()
- onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(
- instance_name=main.params[ 'CTRL' ][ 'ip1' ],
- json_file=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+ startConsoleResult = main.LincOE1.startConsole()
+ opticalMnScript = main.LincOE2.runOpticalMnScript()
+ onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
+ instanceName=main.params[ 'CTRL' ][ 'ip1' ],
+ jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
- print "start_console_result =", start_console_result
- print "optical_mn_script = ", optical_mn_script
- print "onos_topo_cfg_result =", onos_topo_cfg_result
+ print "start_console_result =", startConsoleResult
+ print "optical_mn_script = ", opticalMnScript
+ print "onos_topo_cfg_result =", onosTopoCfgResult
- case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
+ case21Result = startConsoleResult and opticalMnScript and \
+ onosTopoCfgResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case21_result,
+ actual=case21Result,
onpass="Packet optical topology spawned successsfully",
onfail="Packet optical topology spawning failed" )
def CASE22( self, main ):
"""
- Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
- Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
- and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
+ Curretly we use, 4 linear switch optical topology and
+ 2 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 4,
+ packetLayerSWCount variable = 2 and hostCount = 2
+ and this is hardcoded in the testcase. If the topology changes,
+ these hardcoded values need to be changed
"""
main.log.report(
- "This testcase compares the optical+packet topology against what is expected" )
+ "This testcase compares the optical+packet topology against what\
+ is expected" )
main.case( "Topology comparision" )
main.step( "Topology comparision" )
- main.ONOS3.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
- devices_result = main.ONOS3.devices( json_format=False )
+ main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ devicesResult = main.ONOS3.devices( jsonFormat=False )
- print "devices_result = ", devices_result
- devices_linewise = devices_result.split( "\n" )
- devices_linewise = devices_linewise[ 1:-1 ]
+ print "devices_result = ", devicesResult
+ devicesLinewise = devicesResult.split( "\n" )
+ devicesLinewise = devicesLinewise[ 1:-1 ]
roadmCount = 0
packetLayerSWCount = 0
- for line in devices_linewise:
+ for line in devicesLinewise:
components = line.split( "," )
availability = components[ 1 ].split( "=" )[ 1 ]
type = components[ 3 ].split( "=" )[ 1 ]
@@ -275,93 +283,101 @@
elif availability == 'true' and type == 'SWITCH':
packetLayerSWCount += 1
if roadmCount == 4:
- print "Number of Optical Switches = %d and is correctly detected" % roadmCount
+ print "Number of Optical Switches = %d and is \
+ correctly detected" % roadmCount
main.log.info(
"Number of Optical Switches = " +
str( roadmCount ) +
" and is correctly detected" )
- opticalSW_result = main.TRUE
+ opticalSWResult = main.TRUE
else:
- print "Number of Optical Switches = %d and is wrong" % roadCount
+ print "Number of Optical Switches = %d and is wrong" % roadmCount
main.log.info(
"Number of Optical Switches = " +
str( roadmCount ) +
" and is wrong" )
- opticalSW_result = main.FALSE
+ opticalSWResult = main.FALSE
if packetLayerSWCount == 2:
- print "Number of Packet layer or mininet Switches = %d and is correctly detected" % packetLayerSWCount
+ print "Number of Packet layer or mininet Switches = %d and \
+ is correctly detected" % packetLayerSWCount
main.log.info(
"Number of Packet layer or mininet Switches = " +
str( packetLayerSWCount ) +
" and is correctly detected" )
- packetSW_result = main.TRUE
+ packetSWResult = main.TRUE
else:
- print "Number of Packet layer or mininet Switches = %d and is wrong" % packetLayerSWCount
+ print "Number of Packet layer or mininet Switches = %d and \
+ is wrong" % packetLayerSWCount
main.log.info(
"Number of Packet layer or mininet Switches = " +
str( packetLayerSWCount ) +
" and is wrong" )
- packetSW_result = main.FALSE
+ packetSWResult = main.FALSE
print "_________________________________"
- links_result = main.ONOS3.links( json_format=False )
- print "links_result = ", links_result
+ linksResult = main.ONOS3.links( jsonFormat=False )
+ print "links_result = ", linksResult
print "_________________________________"
- # NOTE:Since only point intents are added, there is no requirement to discover the hosts
+ # NOTE:Since only point intents are added, there is no
+ # requirement to discover the hosts
# Therfore, the below portion of the code is commented.
"""
#Discover hosts using pingall
- pingall_result = main.LincOE2.pingall()
+ pingallResult = main.LincOE2.pingall()
- hosts_result = main.ONOS3.hosts( json_format=False )
- main.log.info( "hosts_result = "+hosts_result )
+ hostsResult = main.ONOS3.hosts( jsonFormat=False )
+ main.log.info( "hosts_result = "+hostsResult )
main.log.info( "_________________________________" )
- hosts_linewise = hosts_result.split( "\n" )
- hosts_linewise = hosts_linewise[ 1:-1 ]
+ hostsLinewise = hostsResult.split( "\n" )
+ hostsLinewise = hostsLinewise[ 1:-1 ]
hostCount = 0
- for line in hosts_linewise:
+ for line in hostsLinewise:
hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
hostCount +=1
if hostCount ==2:
print "Number of hosts = %d and is correctly detected" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and is correctly detected" )
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is correctly detected" )
hostDiscovery = main.TRUE
else:
print "Number of hosts = %d and is wrong" %hostCount
- main.log.info( "Number of hosts = " + str( hostCount ) +" and is wrong" )
+ main.log.info( "Number of hosts = " + str( hostCount ) +" and \
+ is wrong" )
hostDiscovery = main.FALSE
"""
- case22_result = opticalSW_result and packetSW_result
+ case22Result = opticalSWResult and packetSWResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case22_result,
+ actual=case22Result,
onpass="Packet optical topology discovery successful",
onfail="Packet optical topology discovery failed" )
def CASE23( self, main ):
import time
"""
- Add bidirectional point intents between 2 packet layer( mininet ) devices and
+ Add bidirectional point intents between 2 packet layer( mininet )
+ devices and
ping mininet hosts
"""
main.log.report(
- "This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts" )
+ "This testcase adds bidirectional point intents between 2 \
+ packet layer( mininet ) devices and ping mininet hosts" )
main.case( "Topology comparision" )
main.step( "Adding point intents" )
- ptp_intent_result = main.ONOS3.add_point_intent(
+ ptpIntentResult = main.ONOS3.addPointIntent(
"of:0000ffffffff0001/1",
"of:0000ffffffff0002/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents( json_format=False )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
- ptp_intent_result = main.ONOS3.add_point_intent(
+ ptpIntentResult = main.ONOS3.addPointIntent(
"of:0000ffffffff0002/1",
"of:0000ffffffff0001/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS3.intents( json_format=False )
+ if ptpIntentResult == main.TRUE:
+ main.ONOS3.intents( jsonFormat=False )
main.log.info( "Point to point intent install successful" )
time.sleep( 10 )
@@ -370,17 +386,17 @@
# Sleep for 30 seconds to provide time for the intent state to change
time.sleep( 30 )
- intentHandle = main.ONOS3.intents( json_format=False )
+ intentHandle = main.ONOS3.intents( jsonFormat=False )
main.log.info( "intents :" + intentHandle )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
count = 1
main.log.info( "\n\nh1 is Pinging h2" )
ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
- #ping = main.LincOE2.pinghost()
+ # ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
main.log.info(
"Ping between h1 and h2 failed. Making attempt number " +
str( count ) +
@@ -388,82 +404,91 @@
time.sleep( 2 )
elif ping == main.FALSE:
main.log.info( "All ping attempts between h1 and h2 have failed" )
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h1 and h2 passed!" )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report(
- "Point intents for packet optical have not ben installed correctly. Cleaning up" )
- if Ping_Result == main.TRUE:
+ "Point intents for packet optical have not ben installed\
+ correctly. Cleaning up" )
+ if PingResult == main.TRUE:
main.log.report(
- "Point Intents for packet optical have been installed correctly" )
+ "Point Intents for packet optical have been\
+ installed correctly" )
- case23_result = Ping_Result
+ case23Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case23_result,
- onpass="Point intents addition for packet optical and Pingall Test successful",
- onfail="Point intents addition for packet optical and Pingall Test NOT successful" )
+ actual=case23Result,
+ onpass="Point intents addition for packet optical and\
+ Pingall Test successful",
+ onfail="Point intents addition for packet optical and\
+ Pingall Test NOT successful" )
def CASE24( self, main ):
import time
import json
"""
- Test Rerouting of Packet Optical by bringing a port down ( port 22 ) of a switch( switchID=1 ), so that link ( between switch1 port22 - switch4-port30 ) is inactive
- and do a ping test. If rerouting is successful, ping should pass. also check the flows
+ Test Rerouting of Packet Optical by bringing a port down
+ ( port 22 ) of a switch( switchID=1 ), so that link
+ ( between switch1 port22 - switch4-port30 ) is inactive
+ and do a ping test. If rerouting is successful,
+ ping should pass. also check the flows
"""
main.log.report(
"This testcase tests rerouting and pings mininet hosts" )
main.case( "Test rerouting and pings mininet hosts" )
main.step( "Bring a port down and verify the link state" )
- main.LincOE1.port_down( sw_id="1", pt_id="22" )
- links_nonjson = main.ONOS3.links( json_format=False )
- main.log.info( "links = " + links_nonjson )
+ main.LincOE1.portDown( swId="1", ptId="22" )
+ linksNonjson = main.ONOS3.links( jsonFormat=False )
+ main.log.info( "links = " + linksNonjson )
links = main.ONOS3.links()
main.log.info( "links = " + links )
- links_result = json.loads( links )
- links_state_result = main.FALSE
- for item in links_result:
+ linksResult = json.loads( links )
+ linksStateResult = main.FALSE
+ for item in linksResult:
if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
'src' ][ 'port' ] == "22":
if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
'dst' ][ 'port' ] == "30":
- links_state = item[ 'state' ]
- if links_state == "INACTIVE":
+ linksState = item[ 'state' ]
+ if linksState == "INACTIVE":
main.log.info(
- "Links state is inactive as expected due to one of the ports being down" )
+ "Links state is inactive as expected due to one \
+ of the ports being down" )
main.log.report(
- "Links state is inactive as expected due to one of the ports being down" )
- links_state_result = main.TRUE
+ "Links state is inactive as expected due to one \
+ of the ports being down" )
+ linksStateResult = main.TRUE
break
else:
main.log.info(
"Links state is not inactive as expected" )
main.log.report(
"Links state is not inactive as expected" )
- links_state_result = main.FALSE
+ linksStateResult = main.FALSE
- print "links_state_result = ", links_state_result
+ print "links_state_result = ", linksStateResult
time.sleep( 10 )
flowHandle = main.ONOS3.flows()
main.log.info( "flows :" + flowHandle )
main.step( "Verify Rerouting by a ping test" )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
count = 1
main.log.info( "\n\nh1 is Pinging h2" )
ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
- #ping = main.LincOE2.pinghost()
+ # ping = main.LincOE2.pinghost()
if ping == main.FALSE and count < 5:
count += 1
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
main.log.info(
"Ping between h1 and h2 failed. Making attempt number " +
str( count ) +
@@ -471,159 +496,163 @@
time.sleep( 2 )
elif ping == main.FALSE:
main.log.info( "All ping attempts between h1 and h2 have failed" )
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h1 and h2 passed!" )
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report( "Ping test successful " )
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report( "Ping test failed" )
- case24_result = Ping_Result and links_state_result
- utilities.assert_equals( expect=main.TRUE, actual=case24_result,
+ case24Result = PingResult and linksStateResult
+ utilities.assert_equals( expect=main.TRUE, actual=case24Result,
onpass="Packet optical rerouting successful",
onfail="Packet optical rerouting failed" )
def CASE4( self, main ):
import re
import time
- main.log.report(
- "This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode" )
+ main.log.report( "This testcase is testing the assignment of \
+ all the switches to all the controllers and \
+ discovering the hists in reactive mode" )
main.log.report( "__________________________________" )
main.case( "Pingall Test" )
main.step( "Assigning switches to controllers" )
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
for i in range( 1, 29 ):
if i == 1:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 2 and i < 5:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 5 and i < 8:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 8 and i < 18:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
elif i >= 18 and i < 28:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
else:
- main.Mininet1.assign_sw_controller(
+ main.Mininet1.assignSwController(
sw=str( i ),
- ip1=ONOS1_ip,
- port1=ONOS1_port )
- Switch_Mastership = main.TRUE
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+ SwitchMastership = main.TRUE
for i in range( 1, 29 ):
if i == 1:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 2 and i < 5:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 5 and i < 8:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 8 and i < 18:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
elif i >= 18 and i < 28:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is " + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
else:
- response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+ response = main.Mininet1.getSwController( "s" + str( i ) )
print( "Response is" + str( response ) )
- if re.search( "tcp:" + ONOS1_ip, response ):
- Switch_Mastership = Switch_Mastership and main.TRUE
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ SwitchMastership = SwitchMastership and main.TRUE
else:
- Switch_Mastership = main.FALSE
+ SwitchMastership = main.FALSE
- if Switch_Mastership == main.TRUE:
+ if SwitchMastership == main.TRUE:
main.log.report( "Controller assignmnet successful" )
else:
main.log.report( "Controller assignmnet failed" )
utilities.assert_equals(
expect=main.TRUE,
- actual=Switch_Mastership,
+ actual=SwitchMastership,
onpass="MasterControllers assigned correctly" )
"""
for i in range ( 1,29 ):
- main.Mininet1.assign_sw_controller( sw=str( i ),count=5,
- ip1=ONOS1_ip,port1=ONOS1_port,
- ip2=ONOS2_ip,port2=ONOS2_port,
- ip3=ONOS3_ip,port3=ONOS3_port,
- ip4=ONOS4_ip,port4=ONOS4_port,
- ip5=ONOS5_ip,port5=ONOS5_port )
+ main.Mininet1.assignSwController( sw=str( i ),count=5,
+ ip1=ONOS1Ip,port1=ONOS1Port,
+ ip2=ONOS2Ip,port2=ONOS2Port,
+ ip3=ONOS3Ip,port3=ONOS3Port,
+ ip4=ONOS4Ip,port4=ONOS4Port,
+ ip5=ONOS5Ip,port5=ONOS5Port )
"""
# REACTIVE FWD test
main.step( "Get list of hosts from Mininet" )
- host_list = main.Mininet1.get_hosts()
- main.log.info( host_list )
+ hostList = main.Mininet1.getHosts()
+ main.log.info( hostList )
main.step( "Get host list in ONOS format" )
- host_onos_list = main.ONOS2.get_hosts_id( host_list )
- main.log.info( host_onos_list )
+ hostOnosList = main.ONOS2.getHostsId( hostList )
+ main.log.info( hostOnosList )
# time.sleep( 5 )
main.step( "Pingall" )
- ping_result = main.FALSE
- while ping_result == main.FALSE:
+ pingResult = main.FALSE
+ while pingResult == main.FALSE:
time1 = time.time()
- ping_result = main.Mininet1.pingall()
+ pingResult = main.Mininet1.pingall()
time2 = time.time()
print "Time for pingall: %2f seconds" % ( time2 - time1 )
- # Start onos cli again because u might have dropped out of onos prompt to the shell prompt
+ # Start onos cli again because u might have dropped out of
+ # onos prompt to the shell prompt
# if there was no activity
- main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
- case4_result = Switch_Mastership and ping_result
- if ping_result == main.TRUE:
- main.log.report(
- "Pingall Test in reactive mode to discover the hosts successful" )
+ case4Result = SwitchMastership and pingResult
+ if pingResult == main.TRUE:
+ main.log.report( "Pingall Test in reactive mode to \
+ discover the hosts successful" )
else:
- main.log.report(
- "Pingall Test in reactive mode to discover the hosts failed" )
+ main.log.report( "Pingall Test in reactive mode to \
+ discover the hosts failed" )
utilities.assert_equals(
expect=main.TRUE,
- actual=case4_result,
+ actual=case4Result,
onpass="Controller assignment and Pingall Test successful",
onfail="Controller assignment and Pingall Test NOT successful" )
@@ -633,74 +662,87 @@
main.log.report( "__________________________________" )
main.case( "Uninstalling reactive forwarding app" )
# Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result = main.ONOS2.feature_uninstall( "onos-app-fwd" )
+ appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
main.log.info( "onos-app-fwd uninstalled" )
- # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ # After reactive forwarding is disabled, the reactive flows on
+ # switches timeout in 10-15s
# So sleep for 15s
time.sleep( 15 )
flows = main.ONOS2.flows()
main.log.info( flows )
- case10_result = appUninstall_result
+ case10Result = appUninstallResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case10_result,
+ actual=case10Result,
onpass="Reactive forwarding app uninstallation successful",
onfail="Reactive forwarding app uninstallation failed" )
def CASE6( self ):
- main.log.report(
- "This testcase is testing the addition of host intents and then does pingall" )
+ main.log.report( "This testcase is testing the addition of \
+ host intents and then does pingall" )
main.log.report( "__________________________________" )
main.case( "Obtaining host id's" )
main.step( "Get hosts" )
hosts = main.ONOS2.hosts()
- # main.log.info( hosts )
+ main.log.info( hosts )
main.step( "Get all devices id" )
- devices_id_list = main.ONOS2.get_all_devices_id()
- # main.log.info( devices_id_list )
+ devicesIdList = main.ONOS2.getAllDevicesId()
+ main.log.info( devicesIdList )
- # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+ # ONOS displays the hosts in hex format unlike mininet which does
+ # in decimal format
# So take care while adding intents
"""
- main.step( "Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
- hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
- print "_____________________________________________________________________________________"
+ main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
+ ONOS hosts h8 and h12" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+ hthIntentResult = main.ONOS2.addHostIntent(
+ "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+ print "______________________________________________________"
"""
for i in range( 8, 18 ):
main.log.info(
- "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+ "Adding host intent between h" + str( i ) +
+ " and h" + str( i + 10 ) )
host1 = "00:00:00:00:00:" + \
str( hex( i )[ 2: ] ).zfill( 2 ).upper()
host2 = "00:00:00:00:00:" + \
str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
# NOTE: get host can return None
# TODO: handle this
- host1_id = main.ONOS2.get_host( host1 )[ 'id' ]
- host2_id = main.ONOS2.get_host( host2 )[ 'id' ]
- tmp_result = main.ONOS2.add_host_intent( host1_id, host2_id )
+ host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+ host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
+ main.ONOS2.addHostIntent( host1Id, host2Id )
time.sleep( 10 )
- h_intents = main.ONOS2.intents( json_format=False )
- main.log.info( "intents:" + h_intents )
- flowHandle = main.ONOS2.flows()
- #main.log.info( "flow:" +flowHandle )
+ hIntents = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intents:" + hIntents )
+ main.ONOS2.flows()
count = 1
i = 8
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
# while i<10:
while i < 18:
main.log.info(
@@ -709,8 +751,8 @@
src="h" + str( i ), target="h" + str( i + 10 ) )
if ping == main.FALSE and count < 5:
count += 1
- #i = 8
- Ping_Result = main.FALSE
+ # i = 8
+ PingResult = main.FALSE
main.log.report( "Ping between h" +
str( i ) +
" and h" +
@@ -728,7 +770,7 @@
10 ) +
"have failed" )
i = 19
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h" +
str( i ) +
@@ -737,39 +779,33 @@
10 ) +
"passed!" )
i += 1
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
- if Ping_Result == main.FALSE:
+ PingResult = main.ERROR
+ if PingResult == main.FALSE:
main.log.report(
- "Ping all test after Host intent addition failed. Cleaning up" )
+ "Ping all test after Host intent addition failed.Cleaning up" )
# main.cleanup()
# main.exit()
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report(
"Ping all test after Host intent addition successful" )
- case6_result = Ping_Result
+ case6Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case6_result,
+ actual=case6Result,
onpass="Pingall Test after Host intents addition successful",
onfail="Pingall Test after Host intents addition failed" )
def CASE5( self, main ):
import json
- from subprocess import Popen, PIPE
# assumes that sts is already in you PYTHONPATH
from sts.topology.teston_topology import TestONTopology
- # main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
- deviceResult = main.ONOS2.devices()
- linksResult = main.ONOS2.links()
- #portsResult = main.ONOS2.ports()
- print "**************"
-
- main.log.report(
- "This testcase is testing if all ONOS nodes are in topology sync with mininet" )
+ # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
+ main.log.report( "This testcase is testing if all ONOS nodes \
+ are in topology sync with mininet" )
main.log.report( "__________________________________" )
main.case( "Comparing Mininet topology with the topology of ONOS" )
main.step( "Start continuous pings" )
@@ -836,22 +872,22 @@
ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
- Topology_Check = main.TRUE
+ TopologyCheck = main.TRUE
main.step( "Compare ONOS Topology to MN Topology" )
- devices_json = main.ONOS2.devices()
- links_json = main.ONOS2.links()
- #ports_json = main.ONOS2.ports()
- print "devices_json= ", devices_json
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ # portsJson = main.ONOS2.ports()
- result1 = main.Mininet1.compare_switches(
+ result1 = main.Mininet1.compareSwitches(
MNTopo,
- json.loads( devices_json ) )
- result2 = main.Mininet1.compare_links(
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
MNTopo,
- json.loads( links_json ) )
- #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
- #result = result1 and result2 and result3
+ # result = result1 and result2 and result3
result = result1 and result2
print "***********************"
@@ -868,55 +904,64 @@
onfail="ONOS" +
" Topology does not match MN Topology" )
- Topology_Check = Topology_Check and result
+ TopologyCheck = TopologyCheck and result
utilities.assert_equals(
expect=main.TRUE,
- actual=Topology_Check,
+ actual=TopologyCheck,
onpass="Topology checks passed",
onfail="Topology checks failed" )
def CASE7( self, main ):
+ from sts.topology.teston_topology import TestONTopology
- ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+ linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
- link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-
- main.log.report(
- "This testscase is killing a link to ensure that link discovery is consistent" )
+ main.log.report( "This testscase is killing a link to ensure that \
+ link discovery is consistent" )
main.log.report( "__________________________________" )
- main.log.report(
- "Killing a link to ensure that link discovery is consistent" )
- main.case(
- "Killing a link to Ensure that Link Discovery is Working Properly" )
+ main.log.report( "Killing a link to ensure that link discovery \
+ is consistent" )
+ main.case( "Killing a link to Ensure that Link Discovery \
+ is Working Properly" )
"""
main.step( "Start continuous pings" )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
- target=main.params[ 'PING' ][ 'target1' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target1' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
- target=main.params[ 'PING' ][ 'target2' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target2' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
- target=main.params[ 'PING' ][ 'target3' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target3' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
- target=main.params[ 'PING' ][ 'target4' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target4' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
- target=main.params[ 'PING' ][ 'target5' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target5' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
- target=main.params[ 'PING' ][ 'target6' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target6' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
- target=main.params[ 'PING' ][ 'target7' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target7' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
- target=main.params[ 'PING' ][ 'target8' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target8' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
- target=main.params[ 'PING' ][ 'target9' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target9' ],
+ pingTime=500 )
main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
- target=main.params[ 'PING' ][ 'target10' ],pingTime=500 )
+ target=main.params[ 'PING' ][ 'target10' ],
+ pingTime=500 )
"""
main.step( "Determine the current number of switches and links" )
- topology_output = main.ONOS2.topology()
- topology_result = main.ONOS1.get_topology( topology_output )
- activeSwitches = topology_result[ 'devices' ]
- links = topology_result[ 'links' ]
+ topologyOutput = main.ONOS2.topology()
+ topologyResult = main.ONOS1.getTopology( topologyOutput )
+ activeSwitches = topologyResult[ 'devices' ]
+ links = topologyResult[ 'links' ]
print "activeSwitches = ", type( activeSwitches )
print "links = ", type( links )
main.log.info(
@@ -925,39 +970,39 @@
main.step( "Kill Link between s3 and s28" )
main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
- time.sleep( link_sleep )
- topology_output = main.ONOS2.topology()
- Link_Down = main.ONOS1.check_status(
- topology_output, activeSwitches, str(
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkDown = main.ONOS1.checkStatus(
+ topologyOutput, activeSwitches, str(
int( links ) - 2 ) )
- if Link_Down == main.TRUE:
+ if LinkDown == main.TRUE:
main.log.report( "Link Down discovered properly" )
utilities.assert_equals(
expect=main.TRUE,
- actual=Link_Down,
+ actual=LinkDown,
onpass="Link Down discovered properly",
onfail="Link down was not discovered in " +
- str( link_sleep ) +
+ str( linkSleep ) +
" seconds" )
# Check ping result here..add code for it
main.step( "Bring link between s3 and s28 back up" )
- Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
- time.sleep( link_sleep )
- topology_output = main.ONOS2.topology()
- Link_Up = main.ONOS1.check_status(
- topology_output,
+ LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+ time.sleep( linkSleep )
+ topologyOutput = main.ONOS2.topology()
+ LinkUp = main.ONOS1.checkStatus(
+ topologyOutput,
activeSwitches,
str( links ) )
- if Link_Up == main.TRUE:
+ if LinkUp == main.TRUE:
main.log.report( "Link up discovered properly" )
utilities.assert_equals(
expect=main.TRUE,
- actual=Link_Up,
+ actual=LinkUp,
onpass="Link up discovered properly",
onfail="Link up was not discovered in " +
- str( link_sleep ) +
+ str( linkSleep ) +
" seconds" )
# NOTE Check ping result here..add code for it
@@ -967,22 +1012,22 @@
main.Mininet1,
ctrls ) # can also add Intent API info for intent operations
MNTopo = Topo
- Topology_Check = main.TRUE
+ TopologyCheck = main.TRUE
- devices_json = main.ONOS2.devices()
- links_json = main.ONOS2.links()
- ports_json = main.ONOS2.ports()
- print "devices_json= ", devices_json
+ devicesJson = main.ONOS2.devices()
+ linksJson = main.ONOS2.links()
+ portsJson = main.ONOS2.ports()
- result1 = main.Mininet1.compare_switches(
+ result1 = main.Mininet1.compareSwitches(
MNTopo,
- json.loads( devices_json ) )
- result2 = main.Mininet1.compare_links(
+ json.loads( devicesJson ) )
+ result2 = main.Mininet1.compareLinks(
MNTopo,
- json.loads( links_json ) )
- #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+ json.loads( linksJson ) )
+ # result3 = main.Mininet1.comparePorts(
+ # MNTopo, json.loads( portsJson ) )
- #result = result1 and result2 and result3
+ # result = result1 and result2 and result3
result = result1 and result2
print "***********************"
@@ -996,14 +1041,14 @@
onfail="ONOS" +
" Topology does not match MN Topology" )
- Topology_Check = Topology_Check and result
+ TopologyCheck = TopologyCheck and result
utilities.assert_equals(
expect=main.TRUE,
- actual=Topology_Check,
+ actual=TopologyCheck,
onpass="Topology checks passed",
onfail="Topology checks failed" )
- result = Link_Down and Link_Up and Topology_Check
+ result = LinkDown and LinkUp and TopologyCheck
utilities.assert_equals( expect=main.TRUE, actual=result,
onpass="Link failure is discovered correctly",
onfail="Link Discovery failed" )
@@ -1012,18 +1057,18 @@
"""
Host intents removal
"""
- main.log.report(
- "This testcase removes any previously added intents before adding the same intents or point intents" )
+ main.log.report( "This testcase removes any previously added intents \
+ before adding the same intents or point intents" )
main.log.report( "__________________________________" )
main.log.info( "Host intents removal" )
main.case( "Removing host intents" )
main.step( "Obtain the intent id's" )
- intent_result = main.ONOS2.intents( json_format=False )
- main.log.info( "intent_result = " + intent_result )
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
- intent_linewise = intent_result.split( "\n" )
+ intentLinewise = intentResult.split( "\n" )
intentList = []
- for line in intent_linewise:
+ for line in intentLinewise:
if line.startswith( "id=" ):
intentList.append( line )
@@ -1036,19 +1081,19 @@
main.step(
"Iterate through the intentids list and remove each intent" )
for id in intentids:
- main.ONOS2.remove_intent( intent_id=id )
+ main.ONOS2.removeIntent( intentId=id )
- intent_result = main.ONOS2.intents( json_format=False )
- main.log.info( "intent_result = " + intent_result )
+ intentResult = main.ONOS2.intents( jsonFormat=False )
+ main.log.info( "intent_result = " + intentResult )
- case8_result = main.TRUE
- if case8_result == main.TRUE:
+ case8Result = main.TRUE
+ if case8Result == main.TRUE:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- Ping_Result = main.TRUE
- if case8_result == main.TRUE:
+ PingResult = main.TRUE
+ if case8Result == main.TRUE:
i = 8
while i < 18:
main.log.info(
@@ -1057,33 +1102,33 @@
src="h" + str( i ), target="h" + str( i + 10 ) )
if ping == main.TRUE:
i = 19
- Ping_Result = Ping_Result and main.TRUE
+ PingResult = PingResult and main.TRUE
elif ping == main.FALSE:
i += 1
- Ping_Result = Ping_Result and main.FALSE
+ PingResult = PingResult and main.FALSE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
# Note: If the ping result failed, that means the intents have been
# withdrawn correctly.
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report( "Host intents have not been withdrawn correctly" )
# main.cleanup()
# main.exit()
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report( "Host intents have been withdrawn correctly" )
- case8_result = case8_result and Ping_Result
+ case8Result = case8Result and PingResult
- if case8_result == main.FALSE:
+ if case8Result == main.FALSE:
main.log.report( "Intent removal successful" )
else:
main.log.report( "Intent removal failed" )
- utilities.assert_equals( expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test failed",
- onfail="Intent removal test passed" )
+ utilities.assert_equals( expect=main.FALSE, actual=case8Result,
+ onpass="Intent removal test passed",
+ onfail="Intent removal test failed" )
def CASE9( self ):
main.log.report(
@@ -1091,189 +1136,200 @@
main.log.report( "__________________________________" )
main.log.info( "Adding point intents" )
main.case(
- "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
- main.step(
- "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ "Adding bidirectional point for mn hosts \
+ ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,\
+ h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
+
+ var1 = "Add point intents for mn hosts h8 and h18 or \
+ ONOS hosts h8 and h12"
+ main.step(var1)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003008/1",
"of:0000000000006018/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006018/1",
"of:0000000000003008/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
+ main.step(var2)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003009/1",
"of:0000000000006019/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006019/1",
"of:0000000000003009/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
+ main.step(var3)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003010/1",
"of:0000000000006020/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006020/1",
"of:0000000000003010/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var4 = "Add point intents for mininet hosts h11 and h21 or \
+ ONOS hosts hB and h15"
+ main.case(var4)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003011/1",
"of:0000000000006021/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006021/1",
"of:0000000000003011/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var5 = "Add point intents for mininet hosts h12 and h22 \
+ ONOS hosts hC and h16"
+ main.case(var5)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003012/1",
"of:0000000000006022/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006022/1",
"of:0000000000003012/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var6 = "Add point intents for mininet hosts h13 and h23 or \
+ ONOS hosts hD and h17"
+ main.case(var6)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003013/1",
"of:0000000000006023/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006023/1",
"of:0000000000003013/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var7 = "Add point intents for mininet hosts h14 and h24 or \
+ ONOS hosts hE and h18"
+ main.case(var7)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003014/1",
"of:0000000000006024/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006024/1",
"of:0000000000003014/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var8 = "Add point intents for mininet hosts h15 and h25 or \
+ ONOS hosts hF and h19"
+ main.case(var8)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003015/1",
"of:0000000000006025/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006025/1",
"of:0000000000003015/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var9 = "Add intents for mininet hosts h16 and h26 or \
+ ONOS hosts h10 and h1A"
+ main.case(var9)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003016/1",
"of:0000000000006026/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006026/1",
"of:0000000000003016/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ # main.log.info( getIntentResult )
- main.step(
- "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ var10 = "Add point intents for mininet hosts h17 and h27 or \
+ ONOS hosts h11 and h1B"
+ main.case(var10)
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000003017/1",
"of:0000000000006027/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ main.log.info( getIntentResult )
- ptp_intent_result = main.ONOS2.add_point_intent(
+ ptpIntentResult = main.ONOS2.addPointIntent(
"of:0000000000006027/1",
"of:0000000000003017/1" )
- if ptp_intent_result == main.TRUE:
- get_intent_result = main.ONOS2.intents()
+ if ptpIntentResult == main.TRUE:
+ getIntentResult = main.ONOS2.intents()
main.log.info( "Point to point intent install successful" )
- # main.log.info( get_intent_result )
+ main.log.info( getIntentResult )
print(
- "_______________________________________________________________________________________" )
+ "___________________________________________________________" )
flowHandle = main.ONOS2.flows()
# print "flowHandle = ", flowHandle
@@ -1281,7 +1337,7 @@
count = 1
i = 8
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
while i < 18:
main.log.info(
"\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
@@ -1289,8 +1345,8 @@
src="h" + str( i ), target="h" + str( i + 10 ) )
if ping == main.FALSE and count < 5:
count += 1
- #i = 8
- Ping_Result = main.FALSE
+ # i = 8
+ PingResult = main.FALSE
main.log.report( "Ping between h" +
str( i ) +
" and h" +
@@ -1308,7 +1364,7 @@
10 ) +
"have failed" )
i = 19
- Ping_Result = main.FALSE
+ PingResult = main.FALSE
elif ping == main.TRUE:
main.log.info( "Ping test between h" +
str( i ) +
@@ -1317,22 +1373,22 @@
10 ) +
"passed!" )
i += 1
- Ping_Result = main.TRUE
+ PingResult = main.TRUE
else:
main.log.info( "Unknown error" )
- Ping_Result = main.ERROR
+ PingResult = main.ERROR
- if Ping_Result == main.FALSE:
+ if PingResult == main.FALSE:
main.log.report(
"Point intents have not ben installed correctly. Cleaning up" )
# main.cleanup()
# main.exit()
- if Ping_Result == main.TRUE:
+ if PingResult == main.TRUE:
main.log.report( "Point Intents have been installed correctly" )
- case9_result = Ping_Result
+ case9Result = PingResult
utilities.assert_equals(
expect=main.TRUE,
- actual=case9_result,
+ actual=case9Result,
onpass="Point intents addition and Pingall Test successful",
onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params
new file mode 100644
index 0000000..4dacc99
--- /dev/null
+++ b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.params
@@ -0,0 +1,41 @@
+<PARAMS>
+
+ <testcases>1,2</testcases>
+
+ <ENV>
+ <cellName>cam_cells</cellName>
+ </ENV>
+
+ <SCALE>2</SCALE>
+
+ <GIT>
+ <autopull>on</autopull>
+ <checkout>master</checkout>
+ </GIT>
+
+ <CTRL>
+ <USER>admin</USER>
+ <ip1>10.128.5.51</ip1>
+ <port1>6633</port1>
+ <ip2>10.128.5.52</ip2>
+ <port2>6633</port2>
+ <ip3>10.128.5.53</ip3>
+ <port3>6633</port3>
+ </CTRL>
+
+ <MN>
+ <ip1>10.128.5.59</ip1>
+ </MN>
+
+ <BENCH>
+ <user>admin</user>
+ <ip1>10.128.5.55</ip1>
+ </BENCH>
+
+ <TEST>
+ </TEST>
+
+ <JSON>
+ </JSON>
+
+</PARAMS>
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
new file mode 100644
index 0000000..a75d694
--- /dev/null
+++ b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.py
@@ -0,0 +1,136 @@
+# ScaleOutTemplate
+#
+# CASE1 starts number of nodes specified in param file
+#
+# cameron@onlab.us
+
+import sys
+import os
+
+
+class ScaleOutTemplate:
+ def __init__(self):
+ self.default = ''
+
+ def CASE1(self, main):
+
+ global cluster_count
+ cluster_count = 1
+
+ checkout_branch = main.params['GIT']['checkout']
+ git_pull = main.params['GIT']['autopull']
+ cell_name = main.params['ENV']['cellName']
+ BENCH_ip = main.params['BENCH']['ip1']
+ BENCH_user = main.params['BENCH']['user']
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ MN1_ip = main.params['MN']['ip1']
+
+ main.log.step("Cleaning Enviornment...")
+ main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.ONOSbench.onos_uninstall(ONOS2_ip)
+ main.ONOSbench.onos_uninstall(ONOS3_ip)
+
+ main.step("Git checkout and pull "+checkout_branch)
+ if git_pull == 'on':
+ checkout_result = main.ONOSbench.git_checkout(checkout_branch)
+ pull_result = main.ONOSbench.git_pull()
+
+ else:
+ checkout_result = main.TRUE
+ pull_result = main.TRUE
+ main.log.info("Skipped git checkout and pull")
+
+ mvn_result = main.ONOSbench.clean_install()
+
+ main.step("Set cell for ONOS cli env")
+ main.ONOS1cli.set_cell(cell_name)
+ main.ONOS2cli.set_cell(cell_name)
+ main.ONOS3cli.set_cell(cell_name)
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package() #no file or directory
+
+ main.step("Installing ONOS package")
+ install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
+
+ cell_name = main.params['ENV']['cellName']
+ main.step("Applying cell file to environment")
+ cell_apply_result = main.ONOSbench.set_cell(cell_name)
+ main.step("verify cells")
+ verify_cell_result = main.ONOSbench.verify_cell()
+
+ main.step("Set cell for ONOS cli env")
+ main.ONOS1cli.set_cell(cell_name)
+ cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+
+
+ def CASE2(self, main):
+
+ '''
+ Increase number of nodes and initiate CLI
+ '''
+ import time
+
+ global cluster_count
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ #ONOS4_ip = main.params['CTRL']['ip4']
+ #ONOS5_ip = main.params['CTRL']['ip5']
+ #ONOS6_ip = main.params['CTRL']['ip6']
+ #ONOS7_ip = main.params['CTRL']['ip7']
+ cell_name = main.params['ENV']['cellName']
+ scale = int(main.params['SCALE'])
+
+ #Cluster size increased everytime the case is defined
+ cluster_count += scale
+
+ main.log.report("Increasing cluster size to "+
+ str(cluster_count))
+ install_result = main.FALSE
+
+ if scale == 2:
+ if cluster_count == 3:
+ main.log.info("Installing nodes 2 and 3")
+ install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
+ install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ cli2 = main.ONOS1cli.start_onos_cli(ONOS2_ip)
+ cli3 = main.ONOS1cli.start_onos_cli(ONOS3_ip)
+
+ '''
+ elif cluster_count == 5:
+
+ main.log.info("Installing nodes 4 and 5")
+ node4_result = main.ONOSbench.onos_install(node=ONOS4_ip)
+ node5_result = main.ONOSbench.onos_install(node=ONOS5_ip)
+ install_result = node4_result and node5_result
+ time.sleep(5)
+
+ main.ONOS4cli.start_onos_cli(ONOS4_ip)
+ main.ONOS5cli.start_onos_cli(ONOS5_ip)
+
+ elif cluster_count == 7:
+
+ main.log.info("Installing nodes 4 and 5")
+ node6_result = main.ONOSbench.onos_install(node=ONOS6_ip)
+ node7_result = main.ONOSbench.onos_install(node=ONOS7_ip)
+ install_result = node6_result and node7_result
+ time.sleep(5)
+
+ main.ONOS6cli.start_onos_cli(ONOS6_ip)
+ main.ONOS7cli.start_onos_cli(ONOS7_ip)
+ '''
+ if scale == 1:
+ if cluster_count == 2:
+ main.log.info("Installing node 2")
+ install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
+ cli2 = main.ONOS1cli.start_onos_cli(ONOS2_ip)
+
+ if cluster_count == 3:
+ main.log.info("Installing node 3")
+ install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+ cli3 = main.ONOS1cli.start_onos_cli(ONOS3_ip)
+
diff --git a/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo
new file mode 100644
index 0000000..88c4d35
--- /dev/null
+++ b/TestON/tests/ScaleOutTemplate/ScaleOutTemplate.topo
@@ -0,0 +1,85 @@
+<TOPOLOGY>
+
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1cli>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1cli>
+
+ <ONOS2cli>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2cli>
+
+ <ONOS3cli>
+ <host>10.128.5.55</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3cli>
+
+ <ONOS1>
+ <host>10.128.5.51</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.5.52</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.5.53</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <Mininet1>
+ <host>10.128.5.59</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ <arg1> --custom ~/mininet/custom/topo-2sw-2host.py </arg1>
+ <arg2> --arp --mac --topo mytopo</arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+
+</TOPOLOGY>
+
diff --git a/TestON/tests/ScaleOutTemplate/__init__.py b/TestON/tests/ScaleOutTemplate/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/ScaleOutTemplate/__init__.py