Revision a802d8b1 mininet/topo.py

View differences:

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