Clarify precedence of default classes.
This commit is contained in:
+11
-8
@@ -17,7 +17,6 @@ setup for testing, and can even be emulated with the Mininet package.
|
|||||||
|
|
||||||
from networkx import Graph
|
from networkx import Graph
|
||||||
from mininet.node import SWITCH_PORT_BASE, Host, OVSSwitch
|
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
|
# 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
|
# 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.'''
|
'''Edge-specific metadata for a StructuredTopo graph.'''
|
||||||
|
|
||||||
def __init__(self, admin_on=True, power_on=True, fault=False,
|
def __init__(self, admin_on=True, power_on=True, fault=False,
|
||||||
cls=Link, **params):
|
cls=None, **params):
|
||||||
'''Init.
|
'''Init.
|
||||||
|
|
||||||
@param admin_on administratively on or off; defaults to True
|
@param admin_on administratively on or off; defaults to True
|
||||||
@@ -109,13 +108,17 @@ class Edge(object):
|
|||||||
|
|
||||||
|
|
||||||
class Topo(object):
|
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.
|
"""Create Topo object.
|
||||||
node: default node/host class
|
node: default node/host class (optional)
|
||||||
switch: default switch class
|
switch: default switch class (optional)
|
||||||
Link: default link class"""
|
link: default link class (optional)"""
|
||||||
self.g = Graph()
|
self.g = Graph()
|
||||||
self.node_info = {} # dpids hash to Node objects
|
self.node_info = {} # dpids hash to Node objects
|
||||||
self.edge_info = {} # (src_dpid, dst_dpid) tuples hash to Edge objects
|
self.edge_info = {} # (src_dpid, dst_dpid) tuples hash to Edge objects
|
||||||
@@ -146,7 +149,7 @@ class Topo(object):
|
|||||||
src, dst = tuple(sorted([src, dst]))
|
src, dst = tuple(sorted([src, dst]))
|
||||||
self.g.add_edge(src, dst)
|
self.g.add_edge(src, dst)
|
||||||
if not edge:
|
if not edge:
|
||||||
edge = Edge( link=self.link )
|
edge = Edge( cls=self.link )
|
||||||
self.edge_info[(src, dst)] = edge
|
self.edge_info[(src, dst)] = edge
|
||||||
self.add_port(src, dst)
|
self.add_port(src, dst)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user