Revision edf46e95 mininet/link.py
mininet/link.py | ||
---|---|---|
94 | 94 |
"Return whether interface is up" |
95 | 95 |
return "UP" in self.ifconfig() |
96 | 96 |
|
97 |
|
|
98 | 97 |
# The reason why we configure things in this way is so |
99 | 98 |
# That the parameters can be listed and documented in |
100 | 99 |
# the config method. |
101 | 100 |
# Dealing with subclasses and superclasses is slightly |
102 | 101 |
# annoying, but at least the information is there! |
103 | 102 |
|
104 |
def setParam( self, result, method, **param ): |
|
105 |
"""Internal method: configure single parameter |
|
106 |
result: dict of results to update |
|
107 |
method: config method |
|
108 |
param: foo=bar (ignore if bar=None)""" |
|
103 |
def setParam( self, results, method, **param ): |
|
104 |
"""Internal method: configure a *single* parameter |
|
105 |
results: dict of results to update |
|
106 |
method: config method name |
|
107 |
param: arg=value (ignore if value=None) |
|
108 |
value may also be list or dict""" |
|
109 | 109 |
name, value = param.items()[ 0 ] |
110 |
if value is None: |
|
110 |
f = getattr( self, method, None ) |
|
111 |
if not f or value is None: |
|
111 | 112 |
return |
112 | 113 |
if type( value ) is list: |
113 |
result[ name ] = getattr( self, method )( *value )
|
|
114 |
result = f( *value )
|
|
114 | 115 |
elif type( value ) is dict: |
115 |
result[ name ] = getattr( self, method )( **value )
|
|
116 |
result = f( **value )
|
|
116 | 117 |
else: |
117 |
result[ name ] = getattr( self, method )( value ) |
|
118 |
result = f( value ) |
|
119 |
results[ name ] = result |
|
120 |
return result |
|
118 | 121 |
|
119 | 122 |
def config( self, mac=None, ip=None, ifconfig=None, |
120 | 123 |
defaultRoute=None, **params): |
Also available in: Unified diff