Merge branch 'devl/cleanup' second round
diff --git a/TestON/bin/unpep8 b/TestON/bin/unpep8
index ff911e8..733d5a3 100755
--- a/TestON/bin/unpep8
+++ b/TestON/bin/unpep8
@@ -179,6 +179,7 @@
def convertFromPep8( program ):
oldProgram = program
# Program text transforms
+ program = reinstateCapWords( program ) # Turning off for now
program = reinstateCapWords( program )
program = fixKeywords( program )
program = insertExtraSpaces( program )
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..d275df0 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -53,12 +53,12 @@
self.name = self.options[ 'name' ]
self.handle = \
super( LincOEDriver, self ).connect(
- user_name=self.user_name,
- ip_address=self.ip_address,
+ userName=self.userName,
+ ipAddress=self.ipAddress,
port=None,
pwd=self.pwd )
- self.ssh_handle = self.handle
+ self.sshHandle = self.handle
if self.handle:
main.log.info( "Handle successfully created" )
@@ -67,40 +67,18 @@
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 " +
- self.user_name + "@" + self.ip_address )
+ self.userName + "@" + self.ipAddress )
main.log.error( self.name +
": 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
@@ -116,9 +94,9 @@
main.log.error(
self.name +
": Connection failed to the host " +
- self.user_name +
+ self.userName +
"@" +
- self.ip_address )
+ self.ipAddress )
main.log.error( self.name +
": Failed to connect to Linc-OE" )
return main.FALSE
@@ -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 d82a58e..4b30f4d 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -66,12 +66,12 @@
self.handle = super(
MininetCliDriver,
self ).connect(
- user_name=self.user_name,
- ip_address=self.ip_address,
+ userName=self.userName,
+ ipAddress=self.ipAddress,
port=None,
pwd=self.pwd )
- self.ssh_handle = self.handle
+ self.sshHandle = self.handle
if self.handle:
main.log.info(
@@ -148,13 +148,13 @@
main.log.error(
self.name +
": Connection failed to the host " +
- self.user_name +
+ self.userName +
"@" +
- self.ip_address )
+ self.ipAddress )
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:
@@ -164,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 ):
@@ -227,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" )
@@ -297,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 ):
@@ -468,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" )
@@ -494,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" )
@@ -527,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" )
@@ -710,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 ):
@@ -804,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"
@@ -837,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 )
@@ -882,12 +882,12 @@
main.exit()
except:
main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( ":" * 50 )
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 )
@@ -904,7 +904,7 @@
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. MN repo should be on
@@ -940,7 +940,7 @@
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. MN repo should be on
@@ -971,7 +971,7 @@
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. MN repo should be on
@@ -1004,7 +1004,7 @@
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. MN repo should be on
@@ -1036,7 +1036,7 @@
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. MN repo should be on
@@ -1075,7 +1075,7 @@
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
@@ -1176,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:
@@ -1196,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"""
@@ -1250,12 +1250,12 @@
main.exit()
except:
main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( ":" * 50 )
main.cleanup()
main.exit()
- def stop_tcpdump( self ):
+ def stopTcpdump( self ):
"pkills tcpdump"
try:
self.handle.sendline( "sh sudo pkill tcpdump" )
@@ -1269,28 +1269,28 @@
main.exit()
except:
main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( ":" * 50 )
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
for switch in topo.graph.switches:
ports = []
for port in switch.ports.values():
- ports.append( { 'of_port': port.port_no,
- 'mac': str( port.hw_addr ).replace( '\'',
- '' ),
+ ports.append( { 'of_port': port.portNo,
+ 'mac': str( port.hwAddr ).replace( '\'',
+ '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1299,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=( ',', ': ' ) )
@@ -1315,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' ]:
@@ -1338,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 ) )
@@ -1346,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
@@ -1363,109 +1363,109 @@
# 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
for switch in topo.graph.switches:
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
+ # print port.hwAddr.toStr( separator='' )
+ tmpPort = {}
+ tmpPort[ 'of_port' ] = port.portNo
+ tmpPort[ 'mac' ] = str( port.hwAddr ).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:
@@ -1473,10 +1473,10 @@
# print switch
ports = []
for port in switch.ports.values():
- # print port.hw_addr.toStr( separator='' )
- ports.append( { 'of_port': port.port_no,
- 'mac': str( port.hw_addr ).replace( '\'',
- '' ),
+ # print port.hwAddr.toStr( separator='' )
+ ports.append( { 'of_port': port.portNo,
+ 'mac': str( port.hwAddr ).replace( '\'',
+ '' ),
'name': port.name } )
output[ 'switches' ].append( {
"name": switch.name,
@@ -1484,33 +1484,33 @@
"ports": ports } )
# LINKS
- mn_links = [
- link for link in topo.patch_panel.network_links if (
+ mnLinks = [
+ link for link in topo.patchPanel.networkLinks 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:
@@ -1528,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 ' +
@@ -1559,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 ' +
@@ -1581,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"""
@@ -1608,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..e2e00e1 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.
+ """,userName, ipAddress, pwd,options ):
+ Here the main is the TestON instance after creating all the log
+ handles."""
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
@@ -53,12 +54,12 @@
self.handle = super(
RemoteMininetDriver,
self ).connect(
- user_name=self.user_name,
- ip_address=self.ip_address,
+ userName=self.userName,
+ ipAddress=self.ipAddress,
port=None,
pwd=self.pwd )
- self.ssh_handle = self.handle
+ self.sshHandle = self.handle
# Copying the readme file to process the
if self.handle:
@@ -67,32 +68,20 @@
else:
main.log.error(
"Connection failed to the host " +
- self.user_name +
+ self.userName +
"@" +
- self.ip_address )
+ self.ipAddress )
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 +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ self.name + ":" * 60 )
+ main.log.error( traceback.printExc() )
+ 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 +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ self.name + ":" * 60 )
+ main.log.error( traceback.printExc() )
+ 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 ] )
@@ -599,40 +577,41 @@
self.name +
": Timeout exception in setIpTables function" )
except:
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.cleanup()
main.exit()
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 ] )
@@ -641,12 +620,13 @@
self.name +
": Timeout exception in setIpTables function" )
except:
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.cleanup()
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..abe064f 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
@@ -48,8 +47,8 @@
self.name = self.options[ 'name' ]
self.handle = super( OnosCliDriver, self ).connect(
- user_name=self.user_name,
- ip_address=self.ip_address,
+ userName=self.userName,
+ ipAddress=self.ipAddress,
port=self.port,
pwd=self.pwd,
home=self.home )
@@ -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 d671f48..5eae84d 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -48,11 +48,11 @@
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 )
+ userName=self.userName,
+ ipAddress=self.ipAddress,
+ 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.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 30 )
+ main.log.error( traceback.printExc() )
+ 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.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
+ main.log.error( traceback.printExc() )
+ 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.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
+ main.log.error( traceback.printExc() )
+ 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.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
+ main.log.error( traceback.printExc() )
+ 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( "export TERM=xterm-256color" )
@@ -442,7 +457,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" )
@@ -474,76 +490,73 @@
main.cleanup()
main.exit()
except:
- main.log.info(
- self.name +
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info(
- ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
+ main.log.info( self.name + ":" * 60 )
+ main.log.error( traceback.printExc() )
+ 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
@@ -551,8 +564,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
@@ -563,12 +576,12 @@
main.exit()
except:
main.log.info( self.name + ":::::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( ":::::::" )
main.cleanup()
main.exit()
- def set_cell( self, cellname ):
+ def setCell( self, cellname ):
"""
Calls 'cell <name>' to set the environment variables on ONOSbench
"""
@@ -579,19 +592,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
@@ -602,12 +615,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 verify_cell( self ):
+ def verifyCell( self ):
"""
Calls 'onos-verify-cell' to check for cell installation
"""
@@ -619,15 +632,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:
@@ -637,16 +650,16 @@
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 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
@@ -659,7 +672,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:
@@ -670,26 +683,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" )
@@ -698,12 +711,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 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.
@@ -723,7 +736,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 )
@@ -753,12 +766,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 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
@@ -766,7 +779,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",
@@ -791,12 +804,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 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
@@ -804,7 +817,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",
@@ -816,7 +829,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" )
@@ -829,12 +842,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 onos_uninstall( self, node_ip="" ):
+ def onosUninstall( self, nodeIp="" ):
"""
Calls the command: 'onos-uninstall'
Uninstalls ONOS from the designated cell machine, stopping
@@ -843,10 +856,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
@@ -858,12 +871,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 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
@@ -871,14 +884,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:
@@ -891,12 +904,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 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
@@ -905,7 +918,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",
@@ -915,14 +928,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" )
@@ -935,12 +950,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 onos_remove_raft_logs( self ):
+ def onosRemoveRaftLogs( self ):
"""
Removes Raft / Copy cat files from ONOS to ensure
a cleaner environment.
@@ -972,12 +987,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 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
@@ -1011,7 +1026,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()
@@ -1045,54 +1060,62 @@
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 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" )
@@ -1101,12 +1124,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 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
@@ -1115,13 +1138,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
@@ -1149,17 +1172,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 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
@@ -1168,42 +1191,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 )
@@ -1215,12 +1242,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 tshark_pcap( self, interface, dir_file ):
+ def tsharkPcap( self, interface, dirFile ):
"""
Capture all packet activity and store in specified
directory/file
@@ -1233,7 +1260,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" )
@@ -1241,19 +1268,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( "\$" )
@@ -1263,7 +1292,7 @@
except:
return main.FALSE
- def tshark_grep( self, grep, directory, interface='eth0' ):
+ def tsharkGrep( self, grep, directory, interface='eth0' ):
"""
Required:
* grep string
@@ -1278,14 +1307,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
"""
@@ -1332,13 +1367,13 @@
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 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
@@ -1348,17 +1383,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:
@@ -1366,18 +1401,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,16 +1429,16 @@
except:
main.log.error( "Copying files failed" )
main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
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,10 +1451,10 @@
except:
main.log.error( "Some error in check_logs:" )
main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
+ main.log.error( traceback.printExc() )
main.log.info( self.name + " ::::::" )
- def onos_status( self, node="" ):
+ def onosStatus( self, node="" ):
"""
Calls onos command: 'onos-service [<node-ip>] status'
"""
@@ -1446,7 +1485,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/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 28f95af..f0cfecc 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -26,21 +26,21 @@
self.name = self.options[ 'name' ]
# self.handle = super( QuaggaCliDriver,self ).connect(
- # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
+ # userName=self.userName, ipAddress=self.ipAddress,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 )
+ userName=self.userName,
+ ipAddress="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.userName ) + ";" + str(
+ self.ipAddress ) + ";" + str(
+ self.port ) + ";" + str(
+ self.pwd ) )
if self.handle:
# self.handle.expect( "",timeout=10 )
@@ -59,13 +59,19 @@
main.log.info( "NO HANDLE" )
return main.FALSE
- def loginQuagga( self, ip_address ):
+ def loginQuagga( self, ipAddress ):
self.name = self.options[ 'name' ]
self.handle = super( QuaggaCliDriver, self ).connect(
- user_name=self.user_name, ip_address=ip_address,
+ userName=self.userName, ipAddress=ipAddress,
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.userName ) +
+ ";" +
+ str( self.ipAddress ) +
+ ";" +
+ str( self.port ) +
+ ";" +
+ str( self.pwd ) )
if self.handle:
# self.handle.expect( "" )
@@ -79,14 +85,14 @@
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 ) )
+ main.log.info( "I in quagga on host " + str( ipAddress ) )
return self.handle
else:
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' ]:
+ for peer in sdnipData[ 'bgpPeers' ]:
if peer[ 'ipAddress' ] == nextHop:
- egress = "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
+ 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,28 +273,35 @@
# 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' ] ):
+ if eq(
+ interfaceAddress[ 'interfaceDpid' ],
+ peer[ 'attachmentDpid' ] ) and eq(
+ interfaceAddress[ 'interfacePort' ],
+ peer[ 'attachmentPort' ] ):
bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
break
else:
@@ -274,17 +309,21 @@
# 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[ 'ipAddress' ] + "/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[ 'ipAddress' ] + "/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[ 'ipAddress' ] + "/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[ 'ipAddress' ] + "/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 ):
- main.log.info( "Start the ping test on host:" + str( ip_address ) )
+ def pingTest( self, ipAddress, pingTestFile, pingTestResultFile ):
+ main.log.info( "Start the ping test on host:" + str( ipAddress ) )
self.name = self.options[ 'name' ]
self.handle = super( QuaggaCliDriver, self ).connect(
- user_name=self.user_name, ip_address=ip_address,
+ userName=self.userName, ipAddress=ipAddress,
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.userName ) +
+ ";" +
+ str( self.ipAddress ) +
+ ";" +
+ 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( "I in host " + str( ipAddress ) )
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/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/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/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index 851522c..08a3158 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -2,7 +2,7 @@
<testcases>1,2,3</testcases>
<ENV>
- <cellName>topo_perf_test</cellName>
+ <cellName>kelvin2</cellName>
</ENV>
<GIT>
@@ -13,21 +13,21 @@
<CTRL>
<user>admin</user>
- <ip1>10.128.174.1</ip1>
+ <ip1>10.128.10.21</ip1>
<port1>6633</port1>
- <ip2>10.128.174.2</ip2>
+ <ip2>10.128.10.22</ip2>
<port2>6633</port2>
- <ip3>10.128.174.3</ip3>
+ <ip3>10.128.10.23</ip3>
<port3>6633</port3>
</CTRL>
<MN>
- <ip1>10.128.10.90</ip1>
- <ip2>10.128.10.91</ip2>
+ <ip1>10.128.10.24</ip1>
+ <ip2>10.128.10.24</ip2>
</MN>
<BENCH>
- <ip>10.128.174.10</ip>
+ <ip>10.128.10.20</ip>
</BENCH>
<TEST>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.topo b/TestON/tests/TopoPerfNext/TopoPerfNext.topo
index 4ee44e2..896e991 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.topo
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.topo
@@ -2,72 +2,72 @@
<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>
<ONOS1cli>
- <host>10.128.174.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosCliDriver</type>
<connect_order>2</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1cli>
<ONOS2cli>
- <host>10.128.174.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosCliDriver</type>
<connect_order>2</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS2cli>
<ONOS3cli>
- <host>10.128.174.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosCliDriver</type>
<connect_order>2</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3cli>
<ONOS1>
- <host>10.128.174.1</host>
+ <host>10.128.10.21</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
<ONOS2>
- <host>10.128.174.2</host>
+ <host>10.128.10.22</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS2>
<ONOS3>
- <host>10.128.174.3</host>
+ <host>10.128.10.23</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS3>
<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>4</connect_order>
<COMPONENTS>
@@ -79,9 +79,9 @@
</Mininet1>
<Mininet2>
- <host>10.128.10.90</host>
+ <host>10.128.10.24</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>RemoteMininetDriver</type>
<connect_order>5</connect_order>
<COMPONENTS> </COMPONENTS>
diff --git a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.params b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.params
index f797706..0db0459 100644
--- a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.params
+++ b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.params
@@ -2,7 +2,7 @@
<testcases>1,2,3,4,5</testcases>
<ENV>
- <cellName>topo_perf_test</cellName>
+ <cellName>kelvin2</cellName>
</ENV>
<GIT>
@@ -13,21 +13,21 @@
<CTRL>
<user>admin</user>
- <ip1>10.128.174.1</ip1>
+ <ip1>10.128.10.21</ip1>
<port1>6633</port1>
- <ip2>10.128.174.2</ip2>
+ <ip2>10.128.10.22</ip2>
<port2>6633</port2>
- <ip3>10.128.174.3</ip3>
+ <ip3>10.128.10.23</ip3>
<port3>6633</port3>
</CTRL>
<MN>
- <ip1>10.128.10.90</ip1>
- <ip2>10.128.10.91</ip2>
+ <ip1>10.128.10.20</ip1>
+ <ip2>10.128.10.25</ip2>
</MN>
<BENCH>
- <ip>10.128.174.10</ip>
+ <ip>10.128.10.20</ip>
</BENCH>
<TEST>
diff --git a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.topo b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.topo
index 3fc7bdc..ecf46d3 100644
--- a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.topo
+++ b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.topo
@@ -2,36 +2,36 @@
<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>
<ONOS1cli>
- <host>10.128.174.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosCliDriver</type>
<connect_order>2</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1cli>
<ONOS1>
- <host>10.128.174.1</host>
+ <host>10.128.20.21</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
<Mininet1>
- <host>10.128.10.90</host>
+ <host>10.128.10.20</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>MininetCliDriver</type>
<connect_order>4</connect_order>
<COMPONENTS>
@@ -43,9 +43,9 @@
</Mininet1>
<Mininet2>
- <host>10.128.10.90</host>
+ <host>10.128.10.25</host>
<user>admin</user>
- <password>onos_test</password>
+ <password></password>
<type>RemoteMininetDriver</type>
<connect_order>5</connect_order>
<COMPONENTS> </COMPONENTS>