summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2021-12-07 13:25:42 +0200
committerzsdc <taras@vyos.io>2021-12-07 14:26:22 +0200
commit1af618103f288d83c51dee3d20e49f06e02b1ac7 (patch)
tree6d700958e14d27ac0c5e5a48f3a37f43d6b79d37 /python/vyos
parent76ac6e9885d587921ac6dc54a3bd056c5dc74b4d (diff)
downloadvyos-1x-1af618103f288d83c51dee3d20e49f06e02b1ac7.tar.gz
vyos-1x-1af618103f288d83c51dee3d20e49f06e02b1ac7.zip
FRR: T4020: Updated CLI options processing for FRR daemons
Instead of analyzing options for each daemon now we use a single template for the whole configuration file. This makes logic a bit less flexible, but much easier. Removed unnecessary check for returned by the `conf.get_config_dict(base)` config. Also, added the ability to disable `strip()` of file content while using `read_file()` what is necessary for proper comparing with updated content.
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/util.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index d8e83ab8d..ce5dc51f5 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -182,16 +182,20 @@ def call(command, flag='', shell=None, input=None, timeout=None, env=None,
return code
-def read_file(fname, defaultonfailure=None):
+def read_file(fname, defaultonfailure=None, strip_end=True):
"""
- read the content of a file, stripping any end characters (space, newlines)
+ read the content of a file, optionally stripping any end characters (space, newlines)
should defaultonfailure be not None, it is returned on failure to read
"""
try:
""" Read a file to string """
with open(fname, 'r') as f:
- data = f.read().strip()
- return data
+ data = f.read()
+
+ if strip_end:
+ return data.strip()
+ else:
+ return data
except Exception as e:
if defaultonfailure is not None:
return defaultonfailure