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

Slightly cleaned up setParam to match node.py.

parent b1f90976
No related branches found
No related tags found
No related merge requests found
...@@ -94,27 +94,30 @@ def isUp( self, set=False ): ...@@ -94,27 +94,30 @@ def isUp( self, set=False ):
"Return whether interface is up" "Return whether interface is up"
return "UP" in self.ifconfig() return "UP" in self.ifconfig()
# The reason why we configure things in this way is so # The reason why we configure things in this way is so
# That the parameters can be listed and documented in # That the parameters can be listed and documented in
# the config method. # the config method.
# Dealing with subclasses and superclasses is slightly # Dealing with subclasses and superclasses is slightly
# annoying, but at least the information is there! # annoying, but at least the information is there!
def setParam( self, result, method, **param ): def setParam( self, results, method, **param ):
"""Internal method: configure single parameter """Internal method: configure a *single* parameter
result: dict of results to update results: dict of results to update
method: config method method: config method name
param: foo=bar (ignore if bar=None)""" param: arg=value (ignore if value=None)
value may also be list or dict"""
name, value = param.items()[ 0 ] name, value = param.items()[ 0 ]
if value is None: f = getattr( self, method, None )
if not f or value is None:
return return
if type( value ) is list: if type( value ) is list:
result[ name ] = getattr( self, method )( *value ) result = f( *value )
elif type( value ) is dict: elif type( value ) is dict:
result[ name ] = getattr( self, method )( **value ) result = f( **value )
else: else:
result[ name ] = getattr( self, method )( value ) result = f( value )
results[ name ] = result
return result
def config( self, mac=None, ip=None, ifconfig=None, def config( self, mac=None, ip=None, ifconfig=None,
defaultRoute=None, **params): defaultRoute=None, **params):
......
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