Fix is_switch() to always succeed + whitespace edits.

This commit is contained in:
Bob Lantz
2012-03-20 15:45:46 -07:00
parent e52d0ee1de
commit 8bebd37759
+3 -2
View File
@@ -16,7 +16,7 @@ setup for testing, and can even be emulated with the Mininet package.
# from networkx.classes.graph import Graph # from networkx.classes.graph import Graph
from networkx import Graph from networkx import Graph
from mininet.util import netParse, ipStr, irange, natural, naturalSeq from mininet.util import irange, natural, naturalSeq
class Topo(object): class Topo(object):
"Data center network representation for structured multi-trees." "Data center network representation for structured multi-trees."
@@ -113,7 +113,7 @@ class Topo(object):
def is_switch(self, n): def is_switch(self, n):
'''Returns true if node is a switch.''' '''Returns true if node is a switch.'''
info = self.node_info[n] info = self.node_info[n]
return info and info['is_switch'] return info and info.get('is_switch', False)
def switches(self, sort=True): def switches(self, sort=True):
'''Return switches. '''Return switches.
@@ -163,6 +163,7 @@ class Topo(object):
return info if info is not None else {} return info if info is not None else {}
def setNodeInfo( self, name, info ): def setNodeInfo( self, name, info ):
"Set metadata (dict) for node"
self.node_info[ name ] = info self.node_info[ name ] = info
@staticmethod @staticmethod