diff options
-rw-r--r-- | ncserver/module/nms_ifupdownng.py | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/ncserver/module/nms_ifupdownng.py b/ncserver/module/nms_ifupdownng.py index 5a06f47..f844d32 100644 --- a/ncserver/module/nms_ifupdownng.py +++ b/ncserver/module/nms_ifupdownng.py @@ -172,25 +172,24 @@ def _iface_path(iface: str) -> pathlib.Path: # P A R A M E T E R S # ############################# +_ENI_MAPPING = {'description': 'netconf-description', + 'enabled': 'auto'} +"""Mapping of NMSA keys to /e/n/i keys.""" -def get_desc(iface: str, _): - """Retrieve the description for the specified interface.""" - return _find_one(iface, 'netconf-description') +def get_one_eni(iface: str, parameter: str): + """Retrieve the specified parameter from /e/n/i.""" + return _find_one(iface, _ENI_MAPPING[parameter]) -def set_desc(iface: str, _, value: str): - """Set the description for the specified interface.""" - _replace_one(iface, 'netconf-description', value) +def unset_one_eni(iface: str, parameter: str): + """Unset a parameter in /e/n/i.""" + _remove_one(iface, _ENI_MAPPING[parameter]) -def unset_desc(iface: str, _): - """Unset the description for the specified interface.""" - _remove_one(iface, 'netconf-description') - -def get_auto(iface: str, _): - """Retrieve whether the interface is auto or not.""" - return _find_one(iface, 'auto') +def set_desc(iface: str, _, value: str): + """Set the description for the specified interface.""" + _replace_one(iface, 'netconf-description', value) def live_enabled(iface: str, _): @@ -205,18 +204,13 @@ def live_enabled(iface: str, _): def set_auto(iface: str, _, value: bool): """Set the auto flag for the specified interface.""" - _replace_one(iface, 'auto', value) - - -def unset_auto(iface: str, _): - """Unset the auto flag for the specified interface.""" - _remove_one(iface, 'auto') + _replace_one(iface, 'auto', str(value).lower()) _PARAMETERS = { # "name": (getter, live getter, setter, unsetter) - "description": (get_desc, get_desc, set_desc, unset_desc), - "enabled": (get_auto, live_enabled, set_auto, unset_auto) + "description": (get_one_eni, get_one_eni, set_desc, unset_one_eni), + "enabled": (get_one_eni, live_enabled, set_auto, unset_one_eni) } """Describes all supported parameters and their methods.""" |