summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2020-03-31 06:57:19 +0700
committerGitHub <noreply@github.com>2020-03-31 06:57:19 +0700
commitc707202f440e387310f97a75b737f482c11ef72e (patch)
treea0cf5004fae0cf2162614ea6d83bd2a8ccfe6404 /python/vyos
parent41f810998729057a05f240625fffe946d2bf4711 (diff)
parenta2771180be5cc98e5b361734602da91632d93b41 (diff)
downloadvyos-1x-c707202f440e387310f97a75b737f482c11ef72e.tar.gz
vyos-1x-c707202f440e387310f97a75b737f482c11ef72e.zip
Merge pull request #284 from jestabro/T2180
vyos.config: T2180: ignore CLI edit level in show_config
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/config.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/config.py b/python/vyos/config.py
index 2342f7021..75055a603 100644
--- a/python/vyos/config.py
+++ b/python/vyos/config.py
@@ -238,6 +238,19 @@ class Config(object):
str: working configuration
"""
+ # show_config should be independent of CLI edit level.
+ # Set the CLI edit environment to the top level, and
+ # restore original on exit.
+ save_env = self.__session_env
+
+ env_str = self._run(self._make_command('getEditResetEnv', ''))
+ env_list = re.findall(r'([A-Z_]+)=\'([^;\s]+)\'', env_str)
+ root_env = os.environ
+ for k, v in env_list:
+ root_env[k] = v
+
+ self.__session_env = root_env
+
# FIXUP: by default, showConfig will give you a diff
# if there are uncommitted changes.
# The config parser obviously cannot work with diffs,
@@ -253,8 +266,10 @@ class Config(object):
path = " ".join(path)
try:
out = self._run(self._make_command('showConfig', path))
+ self.__session_env = save_env
return out
except VyOSError:
+ self.__session_env = save_env
return(default)
def get_config_dict(self, path=[], effective=False):