Revision ccca871a

View differences:

bin/mn
176 176
                        ' controller]' )
177 177
        opts.add_option( '--innamespace', action='store_true',
178 178
                        default=False, help='sw and ctrl in namespace?' )
179
        opts.add_option( '--listenport', type='int', default=6634,
180
                        help='[base port for passive switch listening'
181
                        ' controller]' )
179 182
        opts.add_option( '--pre', type='string', default=None,
180 183
                        help='[CLI script to run before tests]' )
181 184
        opts.add_option( '--post', type='string', default=None,
......
222 225
        xterms = self.options.xterms
223 226
        mac = self.options.mac
224 227
        arp = self.options.arp
228
        listenPort = self.options.listenport
225 229
        mn = Mininet( topo, switch, host, controller, controllerParams,
226 230
                     inNamespace=inNamespace,
227 231
                     xterms=xterms, autoSetMacs=mac,
228
                     autoStaticArp=arp )
232
                     autoStaticArp=arp, listenPort=listenPort )
229 233
        if self.options.pre:
230 234
            CLI( mn, script=self.options.pre )
231 235

  
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
mininet/node.py
434 434

  
435 435
    portBase = SWITCH_PORT_BASE  # 0 for OF < 1.0, 1 for OF >= 1.0
436 436

  
437
    def __init__( self, name, opts='', **kwargs):
437
    def __init__( self, name, opts='', listenPort=None, **kwargs):
438 438
        Node.__init__( self, name, **kwargs )
439 439
        self.opts = opts
440
        self.listenPort = listenPort
441
        if self.listenPort:
442
            self.opts += ' --listen=ptcp:%i ' % self.listenPort
440 443

  
441 444
    def sendCmd( self, *cmd, **kwargs ):
442 445
        """Send command to Node.

Also available in: Unified diff