Internal method: configure a *single* parameter results: dict of results to update method: config method name param: arg=value (ignore if value=None) value may also be list or dict
( self, results, method, **param )
| 167 | # annoying, but at least the information is there! |
| 168 | |
| 169 | def setParam( self, results, method, **param ): |
| 170 | """Internal method: configure a *single* parameter |
| 171 | results: dict of results to update |
| 172 | method: config method name |
| 173 | param: arg=value (ignore if value=None) |
| 174 | value may also be list or dict""" |
| 175 | name, value = list( param.items() )[ 0 ] |
| 176 | f = getattr( self, method, None ) |
| 177 | if not f or value is None: |
| 178 | return None |
| 179 | if isinstance( value, list ): |
| 180 | result = f( *value ) |
| 181 | elif isinstance( value, dict ): |
| 182 | result = f( **value ) |
| 183 | else: |
| 184 | result = f( value ) |
| 185 | results[ name ] = result |
| 186 | return result |
| 187 | |
| 188 | def config( self, mac=None, ip=None, ifconfig=None, |
| 189 | up=True, **_params ): |