Replaced example topologies __init__ with build
This commit is contained in:
@@ -13,12 +13,9 @@ from mininet.topo import Topo
|
|||||||
class MyTopo( Topo ):
|
class MyTopo( Topo ):
|
||||||
"Simple topology example."
|
"Simple topology example."
|
||||||
|
|
||||||
def __init__( self ):
|
def build( self ):
|
||||||
"Create custom topo."
|
"Create custom topo."
|
||||||
|
|
||||||
# Initialize topology
|
|
||||||
Topo.__init__( self )
|
|
||||||
|
|
||||||
# Add hosts and switches
|
# Add hosts and switches
|
||||||
leftHost = self.addHost( 'h1' )
|
leftHost = self.addHost( 'h1' )
|
||||||
rightHost = self.addHost( 'h2' )
|
rightHost = self.addHost( 'h2' )
|
||||||
|
|||||||
@@ -100,10 +100,9 @@ class MininetFacade( object ):
|
|||||||
|
|
||||||
class ControlNetwork( Topo ):
|
class ControlNetwork( Topo ):
|
||||||
"Control Network Topology"
|
"Control Network Topology"
|
||||||
def __init__( self, n, dataController=DataController, **kwargs ):
|
def build( self, n, dataController=DataController, **kwargs ):
|
||||||
"""n: number of data network controller nodes
|
"""n: number of data network controller nodes
|
||||||
dataController: class for data network controllers"""
|
dataController: class for data network controllers"""
|
||||||
Topo.__init__( self, **kwargs )
|
|
||||||
# Connect everything to a single switch
|
# Connect everything to a single switch
|
||||||
cs0 = self.addSwitch( 'cs0' )
|
cs0 = self.addSwitch( 'cs0' )
|
||||||
# Add hosts which will serve as data network controllers
|
# Add hosts which will serve as data network controllers
|
||||||
|
|||||||
@@ -38,11 +38,7 @@ flush = sys.stdout.flush
|
|||||||
class LinearTestTopo( Topo ):
|
class LinearTestTopo( Topo ):
|
||||||
"Topology for a string of N hosts and N-1 switches."
|
"Topology for a string of N hosts and N-1 switches."
|
||||||
|
|
||||||
def __init__( self, N, **params ):
|
def build( self, N, **params ):
|
||||||
|
|
||||||
# Initialize topology
|
|
||||||
Topo.__init__( self, **params )
|
|
||||||
|
|
||||||
# Create switches and hosts
|
# Create switches and hosts
|
||||||
hosts = [ self.addHost( 'h%s' % h )
|
hosts = [ self.addHost( 'h%s' % h )
|
||||||
for h in irange( 1, N ) ]
|
for h in irange( 1, N ) ]
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ def runMultiLink():
|
|||||||
class simpleMultiLinkTopo( Topo ):
|
class simpleMultiLinkTopo( Topo ):
|
||||||
"Simple topology with multiple links"
|
"Simple topology with multiple links"
|
||||||
|
|
||||||
def __init__( self, n, **kwargs ):
|
def build( self, n, **kwargs ):
|
||||||
Topo.__init__( self, **kwargs )
|
|
||||||
|
|
||||||
h1, h2 = self.addHost( 'h1' ), self.addHost( 'h2' )
|
h1, h2 = self.addHost( 'h1' ), self.addHost( 'h2' )
|
||||||
s1 = self.addSwitch( 's1' )
|
s1 = self.addSwitch( 's1' )
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -27,9 +27,7 @@ from mininet.util import irange
|
|||||||
|
|
||||||
class InternetTopo(Topo):
|
class InternetTopo(Topo):
|
||||||
"Single switch connected to n hosts."
|
"Single switch connected to n hosts."
|
||||||
def __init__(self, n=2, **opts):
|
def build(self, n=2, **opts):
|
||||||
Topo.__init__(self, **opts)
|
|
||||||
|
|
||||||
# set up inet switch
|
# set up inet switch
|
||||||
inetSwitch = self.addSwitch('s0')
|
inetSwitch = self.addSwitch('s0')
|
||||||
# add inet host
|
# add inet host
|
||||||
|
|||||||
Reference in New Issue
Block a user