diff options
author | Daniil Baturin <daniil@baturin.org> | 2020-01-29 00:28:26 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2020-01-29 00:57:01 +0100 |
commit | a7efd45bf79e316b7a60cf97f8130f58fc130bf6 (patch) | |
tree | 84cb274a511c52c982f79ef50382d65065929df2 /python | |
parent | 105af1c5580b591efd1f2ecd77329f84de74e06a (diff) | |
download | vyos-1x-a7efd45bf79e316b7a60cf97f8130f58fc130bf6.tar.gz vyos-1x-a7efd45bf79e316b7a60cf97f8130f58fc130bf6.zip |
T1989: use explicit active/working showConfig options to prevent getting diffs
when there are uncommitted changes.
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/config.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/python/vyos/config.py b/python/vyos/config.py index 77698ac68..2342f7021 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -228,7 +228,7 @@ class Config(object): except VyOSError: return False - def show_config(self, path=[], default=None): + def show_config(self, path=[], default=None, effective=False): """ Args: path (str list): Configuration tree path, or empty @@ -237,6 +237,18 @@ class Config(object): Returns: str: working configuration """ + + # FIXUP: by default, showConfig will give you a diff + # if there are uncommitted changes. + # The config parser obviously cannot work with diffs, + # so we need to supress diff production using appropriate + # options for getting either running (active) + # or proposed (working) config. + if effective: + path = ['--show-active-only'] + path + else: + path = ['--show-working-only'] + path + if isinstance(path, list): path = " ".join(path) try: @@ -250,7 +262,7 @@ class Config(object): Args: path (str list): Configuration tree path, can be empty Returns: a dict representation of the config """ - res = self.show_config(self._make_path(path)) + res = self.show_config(self._make_path(path), effective=effective) config_tree = vyos.configtree.ConfigTree(res) config_dict = json.loads(config_tree.to_json()) return config_dict |