diff options
Diffstat (limited to 'lib/ansible/module_utils/netcfg.py')
-rw-r--r-- | lib/ansible/module_utils/netcfg.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/netcfg.py b/lib/ansible/module_utils/netcfg.py index 5d2a4a91d2..d4f4a5ff4a 100644 --- a/lib/ansible/module_utils/netcfg.py +++ b/lib/ansible/module_utils/netcfg.py @@ -92,13 +92,20 @@ class ConfigLine(object): assert isinstance(obj, ConfigLine), 'child must be of type `ConfigLine`' self._children.append(obj) + def ignore_line(text, tokens=None): for item in (tokens or DEFAULT_COMMENT_TOKENS): if text.startswith(item): return True -_obj_to_text = lambda x: [o.text for o in x] -_obj_to_raw = lambda x: [o.raw for o in x] + +def _obj_to_text(x): + return [o.text for o in x] + + +def _obj_to_raw(x): + return [o.raw for o in x] + def _obj_to_block(objects, visited=None): items = list() @@ -110,6 +117,7 @@ def _obj_to_block(objects, visited=None): items.append(child) return _obj_to_raw(items) + def dumps(objects, output='block', comments=False): if output == 'block': items = _obj_to_block(objects) @@ -130,6 +138,7 @@ def dumps(objects, output='block', comments=False): return '\n'.join(items) + class NetworkConfig(object): def __init__(self, indent=1, contents=None): @@ -328,7 +337,7 @@ class NetworkConfig(object): offset = 0 obj = None - ## global config command + # global config command if not parents: for line in lines: item = ConfigLine(line) |