Skip to content
Snippets Groups Projects
Commit 94c02695 authored by Bob Lantz's avatar Bob Lantz
Browse files

Clarify precedence of default classes.

parent d8c88bed
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,6 @@
from networkx import Graph
from mininet.node import SWITCH_PORT_BASE, Host, OVSSwitch
from mininet.link import Link
# BL: it's hard to figure out how to do this right yet remain flexible
# These classes will be used as the defaults if no class is passed
......@@ -93,7 +92,7 @@ class Edge(object):
'''Edge-specific metadata for a StructuredTopo graph.'''
def __init__(self, admin_on=True, power_on=True, fault=False,
cls=Link, **params):
cls=None, **params):
'''Init.
@param admin_on administratively on or off; defaults to True
......@@ -109,13 +108,17 @@ def __init__(self, admin_on=True, power_on=True, fault=False,
class Topo(object):
'''Data center network representation for structured multi-trees.'''
"""Data center network representation for structured multi-trees.
Note that the order of precedence is:
per-node/link classes and parameters
per-topo classes
per-network classes"""
def __init__(self, node=Host, switch=None, link=Link):
def __init__(self, node=None, switch=None, link=None):
"""Create Topo object.
node: default node/host class
switch: default switch class
Link: default link class"""
node: default node/host class (optional)
switch: default switch class (optional)
link: default link class (optional)"""
self.g = Graph()
self.node_info = {} # dpids hash to Node objects
self.edge_info = {} # (src_dpid, dst_dpid) tuples hash to Edge objects
......@@ -146,7 +149,7 @@ def add_edge(self, src, dst, edge=None):
src, dst = tuple(sorted([src, dst]))
self.g.add_edge(src, dst)
if not edge:
edge = Edge( link=self.link )
edge = Edge( cls=self.link )
self.edge_info[(src, dst)] = edge
self.add_port(src, dst)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment