From fdc3156a915b22ddc47e3463c02d8ebb979ac70f Mon Sep 17 00:00:00 2001 From: None Date: Thu, 17 Jan 2019 12:01:09 -0800 Subject: [PATCH] Replaced example topologies __init__ with build --- custom/topo-2sw-2host.py | 5 +---- examples/controlnet.py | 3 +-- examples/linearbandwidth.py | 6 +----- examples/multilink.py | 4 +--- examples/natnet.py | 4 +--- 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/custom/topo-2sw-2host.py b/custom/topo-2sw-2host.py index 6f8638e..49b1b37 100644 --- a/custom/topo-2sw-2host.py +++ b/custom/topo-2sw-2host.py @@ -13,12 +13,9 @@ from mininet.topo import Topo class MyTopo( Topo ): "Simple topology example." - def __init__( self ): + def build( self ): "Create custom topo." - # Initialize topology - Topo.__init__( self ) - # Add hosts and switches leftHost = self.addHost( 'h1' ) rightHost = self.addHost( 'h2' ) diff --git a/examples/controlnet.py b/examples/controlnet.py index e5cf765..68fd3d9 100755 --- a/examples/controlnet.py +++ b/examples/controlnet.py @@ -100,10 +100,9 @@ class MininetFacade( object ): class ControlNetwork( Topo ): "Control Network Topology" - def __init__( self, n, dataController=DataController, **kwargs ): + def build( self, n, dataController=DataController, **kwargs ): """n: number of data network controller nodes dataController: class for data network controllers""" - Topo.__init__( self, **kwargs ) # Connect everything to a single switch cs0 = self.addSwitch( 'cs0' ) # Add hosts which will serve as data network controllers diff --git a/examples/linearbandwidth.py b/examples/linearbandwidth.py index 88aa862..3bb608c 100755 --- a/examples/linearbandwidth.py +++ b/examples/linearbandwidth.py @@ -38,11 +38,7 @@ flush = sys.stdout.flush class LinearTestTopo( Topo ): "Topology for a string of N hosts and N-1 switches." - def __init__( self, N, **params ): - - # Initialize topology - Topo.__init__( self, **params ) - + def build( self, N, **params ): # Create switches and hosts hosts = [ self.addHost( 'h%s' % h ) for h in irange( 1, N ) ] diff --git a/examples/multilink.py b/examples/multilink.py index 469bddb..eb9318d 100755 --- a/examples/multilink.py +++ b/examples/multilink.py @@ -21,9 +21,7 @@ def runMultiLink(): class simpleMultiLinkTopo( Topo ): "Simple topology with multiple links" - def __init__( self, n, **kwargs ): - Topo.__init__( self, **kwargs ) - + def build( self, n, **kwargs ): h1, h2 = self.addHost( 'h1' ), self.addHost( 'h2' ) s1 = self.addSwitch( 's1' ) diff --git a/examples/natnet.py b/examples/natnet.py index 33e4df3..da7d54f 100755 --- a/examples/natnet.py +++ b/examples/natnet.py @@ -27,9 +27,7 @@ from mininet.util import irange class InternetTopo(Topo): "Single switch connected to n hosts." - def __init__(self, n=2, **opts): - Topo.__init__(self, **opts) - + def build(self, n=2, **opts): # set up inet switch inetSwitch = self.addSwitch('s0') # add inet host