diff options
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/config.py | 11 | ||||
-rw-r--r-- | python/vyos/configsession.py | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/python/vyos/config.py b/python/vyos/config.py index 9a5125eb9..96e9631e0 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -87,9 +87,13 @@ class Config(object): the only state it keeps is relative *config path* for convenient access to config subtrees. """ - def __init__(self): + def __init__(self, session_env=None): self._cli_shell_api = "/bin/cli-shell-api" self._level = "" + if session_env: + self.__session_env = session_env + else: + self.__session_env = None def _make_command(self, op, path): args = path.split() @@ -97,7 +101,10 @@ class Config(object): return cmd def _run(self, cmd): - p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + if self.__session_env: + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=self.__session_env) + else: + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) out = p.stdout.read() p.wait() if p.returncode != 0: diff --git a/python/vyos/configsession.py b/python/vyos/configsession.py index b989d3be5..c84d80a77 100644 --- a/python/vyos/configsession.py +++ b/python/vyos/configsession.py @@ -69,6 +69,9 @@ class ConfigSession(object): if result != 0: raise ConfigSessionError(output) + def get_session_env(self): + return self.__session_env + def set(self, path, value=None): if not value: value = [] |