Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions mininet/topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Topo( object ):
def __init__( self, *args, **params ):
"""Topo object.
Optional named parameters:
hinfo: default host options
hopts: default host options
sopts: default switch options
lopts: default link options
calls build()"""
Expand Down Expand Up @@ -134,17 +134,15 @@ def addHost( self, name, **opts ):
name: host name
opts: host options
returns: host name"""
if not opts and self.hopts:
opts = self.hopts
opts.update({k:v for k,v in self.hopts.items() if k not in opts})
return self.addNode( name, **opts )

def addSwitch( self, name, **opts ):
"""Convenience method: Add switch to graph.
name: switch name
opts: switch options
returns: switch name"""
if not opts and self.sopts:
opts = self.sopts
opts.update({k:v for k,v in self.sopts.items() if k not in opts})
result = self.addNode( name, isSwitch=True, **opts )
return result

Expand All @@ -154,8 +152,7 @@ def addLink( self, node1, node2, port1=None, port2=None,
port1, port2: ports (optional)
opts: link options (optional)
returns: link info key"""
if not opts and self.lopts:
opts = self.lopts
opts.update({k:v for k,v in self.lopts.items() if k not in opts})
port1, port2 = self.addPort( node1, node2, port1, port2 )
opts = dict( opts )
opts.update( node1=node1, node2=node2, port1=port1, port2=port2 )
Expand Down