[ONOS-7039] [ONOS-7044] Fix PEP8 Warnings in TestON
Change-Id: Ied79ff9caff5487a6df50466307f757468d7ca3a
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py
old mode 100755
new mode 100644
index 9849069..e15fe72
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
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.
+ ( 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
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Multiple ovsdb OVS!!
@@ -32,7 +31,6 @@
delegated to the ovsdb instance.
"""
-
from mininet.net import Mininet
from mininet.node import Node, OVSSwitch
from mininet.node import OVSBridge
@@ -46,7 +44,9 @@
from itertools import groupby
from operator import attrgetter
+
class OVSDB( Node ):
+
"Namespace for an OVSDB instance"
privateDirs = [ '/etc/openvswitch',
@@ -70,7 +70,7 @@
info( '### Adding NAT for control and data networks'
' (use --nat flush=0 for data network)\n' )
cls.cnet = cnet
- cls.nat = cnet.addNAT( 'ovsdbnat0')
+ cls.nat = cnet.addNAT( 'ovsdbnat0' )
cnet.start()
info( '### Control network started\n' )
return cnet
@@ -155,6 +155,7 @@
class OVSSwitchNS( OVSSwitch ):
+
"OVS Switch in shared OVSNS namespace"
isSetup = False
@@ -162,7 +163,7 @@
@classmethod
def batchStartup( cls, switches ):
result = []
- for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb') ):
+ for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb' ) ):
switchGroup = list( switchGroup )
info( '(%s)' % ovsdb )
result += OVSSwitch.batchStartup( switchGroup, run=ovsdb.cmd )
@@ -171,7 +172,7 @@
@classmethod
def batchShutdown( cls, switches ):
result = []
- for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb') ):
+ for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb' ) ):
switchGroup = list( switchGroup )
info( '(%s)' % ovsdb )
for switch in switches:
@@ -214,7 +215,7 @@
# Delegate methods and initialize local vars
attrs = ( 'cmd', 'cmdPrint', 'sendCmd', 'waitOutput',
'monitor', 'write', 'read',
- 'pid', 'shell', 'stdout',)
+ 'pid', 'shell', 'stdout', )
for attr in attrs:
setattr( self, attr, getattr( ovsdb, attr ) )
self.defaultIntf().updateIP()
@@ -246,14 +247,14 @@
super( OVSSwitchNS, self ).terminate( *args, **kwargs )
else:
self.pid = None
- self.shell= None
+ self.shell = None
def defaultIntf( self ):
return self.ovsdb.defaultIntf()
def __init__( self, *args, **kwargs ):
"""n: number of OVS instances per OVSDB
- shell: run private shell/bash process? (False)
+ shell: run private shell/bash process? ( False )
If shell is shared/not private, cmd() and popen() are
delegated to the OVSDB instance, which is different than
regular OVSSwitch semantics!!"""
@@ -261,7 +262,9 @@
self.privateShell = kwargs.pop( 'shell', False )
super( OVSSwitchNS, self ).__init__( *args, **kwargs )
+
class OVSLinkNS( Link ):
+
"OVSLink that supports OVSSwitchNS"
def __init__( self, node1, node2, **kwargs ):
@@ -279,6 +282,7 @@
links = { 'ovs': OVSLinkNS }
+
def test():
"Test OVSNS switch"
setLogLevel( 'info' )
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py
old mode 100755
new mode 100644
index 1f1c487..596ff2c
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
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.
+ ( 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
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Custom topology for Mininet
"""
@@ -35,19 +34,23 @@
from mininet.util import dumpNodeConnections
from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
class VLANHost( Host ):
+
def config( self, vlan=100, **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
self.cmd( 'ifconfig %s inet 0' % intf )
self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
- self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params[ 'ip' ] ) )
newName = '%s.%d' % ( intf, vlan )
intf.name = newName
self.nameToIntf[ newName ] = intf
return r
+
class IPv6Host( Host ):
+
def config( self, v6Addr='1000:1/64', **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
@@ -55,56 +58,59 @@
self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
return r
+
class dualStackHost( Host ):
+
def config( self, v6Addr='2000:1/64', **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
return r
+
class MyTopo( Topo ):
def __init__( self ):
# Initialize topology
Topo.__init__( self )
# Switch S5 Hosts
- host1=self.addHost( 'h1', ip='10.1.0.2/24' )
- host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
- host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
- #VLAN hosts
- host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
- host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host6=self.addHost( 'h6', ip='11.1.0.2/24' )
- host7=self.addHost( 'h7', ip='12.1.0.2/24' )
- #Multicast Sender
- host8=self.addHost( 'h8', ip='10.1.0.4/24' )
+ host1 = self.addHost( 'h1', ip='10.1.0.2/24' )
+ host2 = self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ host3 = self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
+ # VLAN hosts
+ host4 = self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
+ host5 = self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
+ # VPN-1 and VPN-2 Hosts
+ host6 = self.addHost( 'h6', ip='11.1.0.2/24' )
+ host7 = self.addHost( 'h7', ip='12.1.0.2/24' )
+ # Multicast Sender
+ host8 = self.addHost( 'h8', ip='10.1.0.4/24' )
# Switch S6 Hosts
- host9=self.addHost( 'h9', ip='10.1.0.5/24' )
- host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
- host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
- #VLAN hosts
- host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
- host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host14=self.addHost( 'h14', ip='11.1.0.3/24' )
- host15=self.addHost( 'h15', ip='12.1.0.3/24' )
- #Multicast Receiver
- host16=self.addHost( 'h16', ip='10.1.0.7/24' )
+ host9 = self.addHost( 'h9', ip='10.1.0.5/24' )
+ host10 = self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ host11 = self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
+ # VLAN hosts
+ host12 = self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
+ host13 = self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
+ # VPN-1 and VPN-2 Hosts
+ host14 = self.addHost( 'h14', ip='11.1.0.3/24' )
+ host15 = self.addHost( 'h15', ip='12.1.0.3/24' )
+ # Multicast Receiver
+ host16 = self.addHost( 'h16', ip='10.1.0.7/24' )
# Switch S7 Hosts
- host17=self.addHost( 'h17', ip='10.1.0.8/24' )
- host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
- host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
- #VLAN hosts
- host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
- host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host22=self.addHost( 'h22', ip='11.1.0.4/24' )
- host23=self.addHost( 'h23', ip='12.1.0.4/24' )
- #Multicast Receiver
- host24=self.addHost( 'h24', ip='10.1.0.10/24' )
+ host17 = self.addHost( 'h17', ip='10.1.0.8/24' )
+ host18 = self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ host19 = self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
+ # VLAN hosts
+ host20 = self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
+ host21 = self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
+ # VPN-1 and VPN-2 Hosts
+ host22 = self.addHost( 'h22', ip='11.1.0.4/24' )
+ host23 = self.addHost( 'h23', ip='12.1.0.4/24' )
+ # Multicast Receiver
+ host24 = self.addHost( 'h24', ip='10.1.0.10/24' )
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
@@ -114,56 +120,57 @@
s6 = self.addSwitch( 's6' )
s7 = self.addSwitch( 's7' )
- self.addLink(s5,host1)
- self.addLink(s5,host2)
- self.addLink(s5,host3)
- self.addLink(s5,host4)
- self.addLink(s5,host5)
- self.addLink(s5,host6)
- self.addLink(s5,host7)
- self.addLink(s5,host8)
+ self.addLink( s5, host1 )
+ self.addLink( s5, host2 )
+ self.addLink( s5, host3 )
+ self.addLink( s5, host4 )
+ self.addLink( s5, host5 )
+ self.addLink( s5, host6 )
+ self.addLink( s5, host7 )
+ self.addLink( s5, host8 )
- self.addLink(s6,host9)
- self.addLink(s6,host10)
- self.addLink(s6,host11)
- self.addLink(s6,host12)
- self.addLink(s6,host13)
- self.addLink(s6,host14)
- self.addLink(s6,host15)
- self.addLink(s6,host16)
+ self.addLink( s6, host9 )
+ self.addLink( s6, host10 )
+ self.addLink( s6, host11 )
+ self.addLink( s6, host12 )
+ self.addLink( s6, host13 )
+ self.addLink( s6, host14 )
+ self.addLink( s6, host15 )
+ self.addLink( s6, host16 )
- self.addLink(s7,host17)
- self.addLink(s7,host18)
- self.addLink(s7,host19)
- self.addLink(s7,host20)
- self.addLink(s7,host21)
- self.addLink(s7,host22)
- self.addLink(s7,host23)
- self.addLink(s7,host24)
+ self.addLink( s7, host17 )
+ self.addLink( s7, host18 )
+ self.addLink( s7, host19 )
+ self.addLink( s7, host20 )
+ self.addLink( s7, host21 )
+ self.addLink( s7, host22 )
+ self.addLink( s7, host23 )
+ self.addLink( s7, host24 )
- self.addLink(s1,s2)
- self.addLink(s1,s3)
- self.addLink(s1,s4)
- self.addLink(s1,s5)
- self.addLink(s2,s3)
- self.addLink(s2,s5)
- self.addLink(s2,s6)
- self.addLink(s3,s4)
- self.addLink(s3,s6)
- self.addLink(s4,s7)
+ self.addLink( s1, s2 )
+ self.addLink( s1, s3 )
+ self.addLink( s1, s4 )
+ self.addLink( s1, s5 )
+ self.addLink( s2, s3 )
+ self.addLink( s2, s5 )
+ self.addLink( s2, s6 )
+ self.addLink( s3, s4 )
+ self.addLink( s3, s6 )
+ self.addLink( s4, s7 )
topos = { 'mytopo': ( lambda: MyTopo() ) }
# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
def setupNetwork():
"Create network"
topo = MyTopo()
- network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+ network = Mininet( topo=topo, autoSetMacs=True, controller=None )
network.start()
CLI( network )
network.stop()
if __name__ == '__main__':
- setLogLevel('info')
- #setLogLevel('debug')
+ setLogLevel( 'info' )
+ # setLogLevel( 'debug' )
setupNetwork()
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
index ae30723..7620354 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
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.
+ ( 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
@@ -18,7 +18,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Wrapper function for FuncTopo
Includes onosclidriver and mininetclidriver functions
@@ -27,13 +26,15 @@
import json
import re
+
def __init__( self ):
self.default = ''
+
def getTimestampFromString( main, targetString ):
- #Get time string from the target string
+ # Get time string from the target string
try:
- assert type( targetString ) is str
+ assert isinstance( targetString, str )
timeString = targetString.split( ' | ' )
timeString = timeString[ 0 ]
from datetime import datetime
@@ -53,10 +54,11 @@
main.log.error( "Got wrong string from log" )
return -1
+
def getRoleRequestTimeFromTshark( main ):
try:
main.log.info( "Get role request time" )
- with open(main.tsharkResultPath, "r" ) as resultFile:
+ with open( main.tsharkResultPath, "r" ) as resultFile:
resultText = resultFile.readlines()
# select the last role request string
roleRequestString = resultText[ len( resultText ) - 1 ]
@@ -64,18 +66,19 @@
# get timestamp from role request string
roleRequestTime = roleRequestString.split( " " )
resultFile.close()
- return float(roleRequestTime[1])
+ return float( roleRequestTime[ 1 ] )
except IndexError:
- main.log.error("Got wrong role request string from Tshark file")
+ main.log.error( "Got wrong role request string from Tshark file" )
return -1
-def compareTimeDiffWithRoleRequest(main, term, Mode, index=0 ):
- '''
+
+def compareTimeDiffWithRoleRequest( main, term, Mode, index=0 ):
+ """
Description:
Compare the time difference between the time of target term and the time of role request
Inclides onosclidriver functions
- '''
+ """
try:
termInfo = main.Cluster.active( index ).CLI.logSearch( mode=Mode, searchTerm=term )
termTime = getTimestampFromString( main, termInfo[ 0 ] )
@@ -91,37 +94,38 @@
main.writeData = -1
return -1
+
def getInfoFromLog( main, term1, mode1, term2, mode2, index=0, funcMode='TD' ):
- '''
+ """
Description:
Get needed informations of the search term from karaf.log
Includes onosclidriver functions
Function mode:
- TD (time difference):
+ TD ( time difference ):
Get time difference between start and end
Term1: startTerm
Term2: endTerm
- DR (disconnect rate):
+ DR ( disconnect rate ):
Get switch disconnect rate
Term1: disconnectTerm
Term2: connectTerm
- '''
+ """
try:
termInfo1 = main.Cluster.active( index ).CLI.logSearch( mode=mode1, searchTerm=term1 )
termInfo2 = main.Cluster.active( index ).CLI.logSearch( mode=mode2, searchTerm=term2 )
if funcMode == 'TD':
- startTime = getTimestampFromString( main, termInfo1[0] )
- endTime = getTimestampFromString ( main, termInfo2[0] )
+ startTime = getTimestampFromString( main, termInfo1[ 0 ] )
+ endTime = getTimestampFromString( main, termInfo2[ 0 ] )
if startTime == -1 or endTime == -1:
main.log.error( "Wrong Time!" )
main.writeData = -1
return -1
return endTime - startTime
if funcMode == 'DR':
- #In this mode, termInfo1 means the total number of switch disconnection and
- #termInfo2 means the total number of new switch connection
- #termInfo2 - termInfo1 means the actual real number of switch connection.
+ # In this mode, termInfo1 means the total number of switch disconnection and
+ # termInfo2 means the total number of new switch connection
+ # termInfo2 - termInfo1 means the actual real number of switch connection.
disconnection = int( termInfo1 ) * 1.0
expectConnection = int( main.currScale ) ** 2
realConnection = int( termInfo2 ) - int( termInfo1 )
@@ -136,6 +140,7 @@
main.writeData = -1
return -1
+
def testTopology( main, topoFile='', args='', mnCmd='', timeout=300, clean=True ):
"""
Description:
@@ -173,16 +178,16 @@
# Starts topology
startResult = startNewTopology( main, topoFile, args, mnCmd, timeout=timeout )
# onos needs time to see the links
- time.sleep(15)
+ time.sleep( 15 )
# Gets list of switches in mininet
- #assignSwitch( main )
+ # assignSwitch( main )
testTopoResult = startResult and topoObjectResult
-
return testTopoResult
+
def startNewTopology( main, topoFile='', args='', mnCmd='', timeout=900 ):
"""
Description:
@@ -215,14 +220,14 @@
main.log.info( main.topoName + ": Starting topology with '" +
mnCmd + "' Mininet command" )
-
result = main.Mininet1.startNet( topoFile=topoFile,
args=args,
mnCmd=mnCmd,
- timeout=timeout)
+ timeout=timeout )
return result
+
def stopMininet( main ):
"""
Stops current topology and execute mn -c basically triggers
@@ -235,9 +240,10 @@
stopResult = main.Mininet1.stopNet()
time.sleep( 30 )
if not stopResult:
- main.log.info( main.topoName + ": Did not stop Mininet topology" )
+ main.log.info( main.topoName + ": Did not stop Mininet topology" )
return stopResult
+
def compareTopo( main ):
"""
Compare topology( devices, links, ports, hosts ) between ONOS and
@@ -254,13 +260,14 @@
main.topoRelated = Topology()
return main.topoRelated.compareTopos( main.Mininet1 )
+
def assignSwitch( main ):
"""
Returns switch list using getSwitch in Mininet driver
"""
switchList = []
assignResult = main.TRUE
- switchList = main.Mininet1.getSwitch()
+ switchList = main.Mininet1.getSwitch()
assignResult = main.Mininet1.assignSwController( sw=switchList,
ip=main.Cluster.active( 0 ).ipAddress,
port=6633 )
@@ -274,6 +281,7 @@
return switchList
+
def connectivity( main, timeout=900, shortCircuit=True, acceptableFailed=20 ):
"""
Use fwd app and pingall to discover all the hosts
@@ -309,6 +317,7 @@
return pingResult
+
def getHostsData( main ):
"""
Use fwd app and pingall to discover all the hosts
@@ -369,6 +378,7 @@
return getDataResult
+
def reinstallOnos( main ):
"""
Description:
@@ -422,8 +432,4 @@
if cliResult != main.TRUE:
restartResult = main.FALSE
-
return restartResult
-
-
-
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py
index 973385a..32c8419 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
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.
+ ( 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
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Custom topology for Mininet
Author: kelvin@onlab.us
@@ -45,7 +44,9 @@
totalSwitches = 0
totalEndSwitches = 0
totalHosts = 0
-endSwitchCount = 0 # total count of end switch in each row in gui
+endSwitchCount = 0 # total count of end switch in each row in gui
+
+
class spineTopo( Topo ):
def __init__( self, **opts ):
@@ -71,8 +72,8 @@
global endSwitchCount
endSwitchCount = e
- print "Creating topology with", s,"spine", l,"leaf", c,"core",\
- e,"end switches and",h,"host for each end switches"
+ print "Creating topology with", s, "spine", l, "leaf", c, "core",\
+ e, "end switches and", h, "host for each end switches"
self.addCore( c )
self.addSpine( s )
@@ -89,7 +90,6 @@
deviceData = self.createSwitchDict()
self.genCfgJson( deviceData )
-
def addCore( self, numSwitch ):
global totalSwitches
global coreSwitches
@@ -134,7 +134,6 @@
return host
-
def linkHosts( self, numHosts ):
global endSwitches
switches = sorted( endSwitches.values() )
@@ -143,7 +142,6 @@
for i in xrange( numHosts ):
self.addLink( sw, self.addEndHosts() )
-
def linkLayer( self, topLayer, botLayer ):
"""
Description:
@@ -156,7 +154,6 @@
layer below
botLater - Layer that is below the upper layer to be linked at
"""
-
topSwitches = sorted( topLayer.keys() )
botSwitches = sorted( botLayer.keys() )
@@ -164,7 +161,6 @@
for botSw in botSwitches:
self.addLink( topLayer.get( topSw ), botLayer.get( botSw ) )
-
def linkEndSwitch( self, numSwitch, leafLayer ):
global totalSwitches
global totalEndSwitches
@@ -182,7 +178,7 @@
self.addLink( leaf[ i ], endSw )
self.addLink( leaf[ i + 1 ], endSw )
break
- if i == ( len( leafSwitches ) - 1 ) and len( leafSwitches )%2:
+ if i == ( len( leafSwitches ) - 1 ) and len( leafSwitches ) % 2:
for j in xrange( numSwitch ):
self.addLink( leaf[ i ], self.addEnd() )
break
@@ -194,7 +190,7 @@
continue
if i == 1:
continue
- if i%2 == 0:
+ if i % 2 == 0:
for j in xrange( numSwitch ):
endSw = self.addEnd()
self.addLink( leaf[ i ], endSw )
@@ -206,11 +202,9 @@
configJson[ "devices" ] = deviceData
with open( 'spine.json', 'w+' ) as outfile:
json.dump( configJson, outfile )
- #cfgFile = open( "spine.json" , 'w+' )
- #cfgFile.write( configJson )
- #cfgFile.close()
-
-
+ # cfgFile = open( "spine.json" , 'w+' )
+ # cfgFile.write( configJson )
+ # cfgFile.close()
def createSwitchDict( self ):
global allSwitches
@@ -222,18 +216,18 @@
spineLong = -80
leafLong = -90
endLat = 30
- rowCount = 0 # count of end switches or rows
- colOffSet = 0 # off set for end switches; longitude
+ rowCount = 0 # count of end switches or rows
+ colOffSet = 0 # off set for end switches; longitude
- #for i in xrange( len( allSwitches ) ):
+ # for i in xrange( len( allSwitches ) ):
deviceList = []
deviceDict = {}
for sw in allSwitches:
tempSw = allSwitches.get( sw )
- uri = str( "{0:0>16}".format( str( hex( int( tempSw[ 1: ] ) )\
- ).split( "x" )[ 1 ] ) )
- mac = str( "{0:0>12}".format( str( hex( int( tempSw[ 1: ] ) )\
- ).split( "x" )[ 1 ] ) )
+ uri = str( "{0:0>16}".format( str( hex( int( tempSw[ 1: ] ) )
+ ).split( "x" )[ 1 ] ) )
+ mac = str( "{0:0>12}".format( str( hex( int( tempSw[ 1: ] ) )
+ ).split( "x" )[ 1 ] ) )
if "core" in sw:
latitude = 45
@@ -259,7 +253,7 @@
endLat -= 1
rowCount += 1
- tempItem = { "alias": allSwitches.get( sw ) ,
+ tempItem = { "alias": allSwitches.get( sw ),
"uri": "of:" + uri,
"mac": mac,
"annotations": { "name": sw,
@@ -269,21 +263,22 @@
deviceList.append( tempItem )
return deviceList
- #def createHostsJson( hostDict ):
+ # def createHostsJson( hostDict ):
topos = { 'spine': ( lambda s=2, l=3, c=1, e=5, h=1: spineTopo( s=s,
l=l,
c=c,
e=e,
- h=h) ) }
+ h=h ) ) }
# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
def setupNetwork():
"Create network"
topo = spineTopo()
- #if controller_ip == '':
- #controller_ip = '10.0.2.2';
+ # if controller_ip == '':
+ # controller_ip = '10.0.2.2';
# controller_ip = '127.0.0.1';
network = Mininet( topo=topo,
autoSetMacs=True,
@@ -294,5 +289,5 @@
if __name__ == '__main__':
setLogLevel( 'info' )
- #setLogLevel('debug')
+ # setLogLevel( 'debug' )
setupNetwork()
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
index c5c1f88..373ed2b 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
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.
+ ( 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
@@ -18,15 +18,14 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
These functions can be used for topology comparisons
"""
-
import time
import os
import json
+
def sendArpPackage( main, hostList ):
import json
import time
@@ -35,10 +34,10 @@
return the total hosts number from Onos
"""
main.log.info( "Sending Arping package..." )
- if isinstance(hostList, list):
+ if isinstance( hostList, list ):
for h in hostList:
main.Mininet1.arping( srcHost=h, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
- time.sleep(0.5)
+ time.sleep( 0.5 )
else:
main.Mininet1.arping( srcHost=hostList, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
try:
@@ -46,8 +45,8 @@
summaryStr = json.loads( main.Cluster.active( 0 ).CLI.summary().encode() )
hostNum = summaryStr.get( 'hosts' )
- except (TypeError, ValueError):
- main.log.exception( " Object not as expected: {!r}".format( summaryStr) )
+ except ( TypeError, ValueError ):
+ main.log.exception( " Object not as expected: {!r}".format( summaryStr ) )
return -1
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )