Revision 3f2355a3 mininet/net.py

View differences:

mininet/net.py
112 112
                  build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
113 113
                  inNamespace=False,
114 114
                  autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
115
                  listenPort=None,
116
                  gateway=None ):
115
                  listenPort=None ):
117 116
        """Create Mininet object.
118 117
           topo: Topo (topology) object or None
119 118
           switch: default Switch class
......
130 129
           autoStaticArp: set all-pairs static MAC addrs?
131 130
           autoPinCpus: pin hosts to (real) cores (requires CPULimitedHost)?
132 131
           listenPort: base listening port to open; will be incremented for
133
               each additional switch in the net if inNamespace=False
134
           gateway: node that provides connectivity to the Internet"""
132
               each additional switch in the net if inNamespace=False"""
135 133
        self.topo = topo
136 134
        self.switch = switch
137 135
        self.host = host
......
150 148
        self.numCores = numCores()
151 149
        self.nextCore = 0  # next core for pinning hosts to CPUs
152 150
        self.listenPort = listenPort
153
        self.gateway = gateway
154 151

  
155 152
        self.hosts = []
156 153
        self.switches = []
......
166 163
        if topo and build:
167 164
            self.build()
168 165

  
169
    # list of Node subclasses that provide gateway service
170
    gateways = [ NAT ]
171

  
172 166
    def addHost( self, name, cls=None, **params ):
173 167
        """Add host.
174 168
           name: name of host to add
......
189 183
        defaults.update( params )
190 184
        # TODO: clean this up
191 185
        if params.get( 'isNAT', False ):
186
            print "***** &&&&&& !!!! nat nat nat"
192 187
            cls = NAT
193 188
        if not cls:
194 189
            cls = self.host
195 190
        h = cls( name, **defaults )
196 191
        self.hosts.append( h )
197 192
        self.nameToNode[ name ] = h
198
        if cls in self.gateways:
199
            self.gateway = h
200 193
        return h
201 194

  
202 195
    def addSwitch( self, name, cls=None, **params ):
......
242 235
    def addNAT( self, name='nat0', connect=True, **params ):
243 236
        nat = self.addHost( name, cls=NAT, **params )
244 237
        # find first switch and create link
245
        print "net/addNAT"
238
        print "******* &&&&&& net/addNAT"
246 239
        if connect:
247 240
            #connect the nat to the first switch
248 241
            self.addLink( nat, self.switches[ 0 ] )
......
326 319
            host.cmd( 'ifconfig lo up' )
327 320
        info( '\n' )
328 321

  
322
    ''' TODO: remove this!
329 323
    def configGateway( self ):
330 324
        """Add gateway routes to all hosts if the networks has a gateway."""
331 325
        if self.gateway:
......
338 332
                else:
339 333
                    # Don't mess with hosts in the root namespace
340 334
                    pass
335
    '''
341 336

  
342 337
    def buildFromTopo( self, topo=None ):
343 338
        """Build mininet from a topology object
......
397 392
            self.startTerms()
398 393
        if self.autoStaticArp:
399 394
            self.staticArp()
400
        self.configGateway()
395
        # TODO: remove this
396
        #self.configGateway()
401 397
        self.built = True
402 398

  
403 399
    def startTerms( self ):

Also available in: Unified diff