Revision a802d8b1

View differences:

mininet/net.py
181 181
            self.nextCore = ( self.nextCore + 1 ) % self.numCores
182 182
        self.nextIP += 1
183 183
        defaults.update( params )
184
        # TODO: clean this up
185
        if params.get( 'isNAT', False ):
186
            print "***** &&&&&& !!!! nat nat nat"
187
            cls = NAT
188 184
        if not cls:
189 185
            cls = self.host
190 186
        h = cls( name, **defaults )
......
319 315
            host.cmd( 'ifconfig lo up' )
320 316
        info( '\n' )
321 317

  
322
    ''' TODO: remove this!
323
    def configGateway( self ):
324
        """Add gateway routes to all hosts if the networks has a gateway."""
325
        if self.gateway:
326
            gatewayIP = self.gateway.defaultIntf().IP()
327
            for host in self.hosts:
328
                if host.inNamespace and self.gateway:
329
                    host.cmd( 'ip route flush root 0/0' )
330
                    host.cmd( 'route add -net', self.ipBase, 'dev', host.defaultIntf() )
331
                    host.cmd( 'route add default gw', gatewayIP )
332
                else:
333
                    # Don't mess with hosts in the root namespace
334
                    pass
335
    '''
336

  
337 318
    def buildFromTopo( self, topo=None ):
338 319
        """Build mininet from a topology object
339 320
           At the end of this function, everything should be connected
......
392 373
            self.startTerms()
393 374
        if self.autoStaticArp:
394 375
            self.staticArp()
395
        # TODO: remove this
396
        #self.configGateway()
397 376
        self.built = True
398 377

  
399 378
    def startTerms( self ):
mininet/topo.py
12 12
'''
13 13

  
14 14
from mininet.util import irange, natural, naturalSeq
15
from mininet.node import NAT
16 15

  
17 16
class MultiGraph( object ):
18 17
    "Utility class to track nodes and edges - replaces networkx.Graph"
......
90 89
        result = self.addNode(name, isSwitch=True, **opts)
91 90
        return result
92 91

  
93
    def addNAT(self, name='nat', connect=True, inNamespace=False, **opts):
94
        """Convenience method: Add NAT to graph.
95
           name: NAT name
96
           connect: True will automatically connect to the first switch"""
97
        #nat = self.addNode(name, isNAT=True, inNamespace=False)
98
        nat = self.addNode(name, cls=NAT, inNamespace=inNamespace, hosts=self.hosts(), **opts)
99
        if connect:
100
            # connect the NAT to the first switch
101
            self.addLink(name, self.switches()[ 0 ])
102
        return nat
103

  
104 92
    def addLink(self, node1, node2, port1=None, port2=None,
105 93
                **opts):
106 94
        """node1, node2: nodes to link together

Also available in: Unified diff