From 3e1100b71adf40a2fad60b818f7a724c53c460b6 Mon Sep 17 00:00:00 2001 From: Bob Lantz <rlantz@cs.stanford.edu> Date: Mon, 10 Nov 2014 15:10:35 -0800 Subject: [PATCH] Clarify MultiTopo docstrs and copy addLInk opts Note: it's a bit confusing, but we need to copy the link parameter dicts (since we update them with node info), but we can share the node dicts. Perhaps we should copy the node dicts as well... --- mininet/topo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mininet/topo.py b/mininet/topo.py index af3eac5f..efc16aa4 100644 --- a/mininet/topo.py +++ b/mininet/topo.py @@ -23,7 +23,8 @@ def __init__( self ): def add_node( self, node, attr_dict=None, **attrs): """Add node to graph attr_dict: attribute dict (optional) - attrs: more attributes (optional)""" + attrs: more attributes (optional) + warning: updates attr_dict with attrs""" attr_dict = {} if attr_dict is None else attr_dict attr_dict.update( attrs ) self.node[ node ] = attr_dict @@ -31,7 +32,9 @@ def add_node( self, node, attr_dict=None, **attrs): def add_edge( self, src, dst, key=None, attr_dict=None, **attrs ): """Add edge to graph key: optional key - attr_dict: optional attribute dict""" + attr_dict: optional attribute dict + attrs: more attributes + warning: udpates attr_dict with attrs""" attr_dict = {} if attr_dict is None else attr_dict attr_dict.update( attrs ) self.node.setdefault( src, {} ) @@ -151,6 +154,7 @@ def addLink( self, node1, node2, port1=None, port2=None, if not opts and self.lopts: opts = self.lopts port1, port2 = self.addPort( node1, node2, port1, port2 ) + opts = dict( opts ) opts.update( node1=node1, node2=node2, port1=port1, port2=port2 ) self.g.add_edge(node1, node2, key, opts ) return key -- GitLab