Revision ccca871a mininet/net.py

View differences:

mininet/net.py
108 108
                 cparams=ControllerParams( '10.0.0.0', 8 ),
109 109
                 build=True, xterms=False, cleanup=False,
110 110
                 inNamespace=False,
111
                 autoSetMacs=False, autoStaticArp=False ):
111
                 autoSetMacs=False, autoStaticArp=False, listenPort=None ):
112 112
        """Create Mininet object.
113 113
           topo: Topo (topology) object or None
114 114
           switch: Switch class
......
120 120
           cleanup: if build now, cleanup before creating?
121 121
           inNamespace: spawn switches and controller in net namespaces?
122 122
           autoSetMacs: set MAC addrs from topo?
123
           autoStaticArp: set all-pairs static MAC addrs?"""
123
           autoStaticArp: set all-pairs static MAC addrs?
124
           listenPort: base listening port to open; will be incremented for
125
               each additional switch in the net if inNamespace=False"""
124 126
        self.switch = switch
125 127
        self.host = host
126 128
        self.controller = controller
......
131 133
        self.cleanup = cleanup
132 134
        self.autoSetMacs = autoSetMacs
133 135
        self.autoStaticArp = autoStaticArp
136
        self.listenPort = listenPort
134 137

  
135 138
        self.hosts = []
136 139
        self.switches = []
......
162 165
        """Add switch.
163 166
           name: name of switch to add
164 167
           mac: default MAC address for kernel/OVS switch intf 0
165
           returns: added switch"""
168
           returns: added switch
169
           side effect: increments the listenPort member variable."""
166 170
        if self.switch == UserSwitch:
167
            sw = self.switch( name, defaultMAC=mac, defaultIP=ip,
168
                inNamespace=self.inNamespace )
171
            sw = self.switch( name, listenPort=self.listenPort,
172
                defaultMAC=mac, defaultIP=ip, inNamespace=self.inNamespace )
169 173
        else:
170
            sw = self.switch( name, defaultMAC=mac, defaultIP=ip, dp=self.dps,
174
            sw = self.switch( name, listenPort=self.listenPort,
175
                defaultMAC=mac, defaultIP=ip, dp=self.dps,
171 176
                inNamespace=self.inNamespace )
177
        if not self.inNamespace:
178
            self.listenPort += 1
172 179
        self.dps += 1
173 180
        self.switches.append( sw )
174 181
        self.nameToNode[ name ] = sw

Also available in: Unified diff