From 4b3c01ceac65082a5e202d88c995c04d8c80e3ce Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 23 Oct 2019 10:31:16 -0500 Subject: [vyos.config] T1758: check that config setup has completed before calling showConfig, else, default to config.boot --- python/vyos/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/vyos/config.py b/python/vyos/config.py index d70093531..2232d900c 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -63,6 +63,7 @@ In operational mode, all functions return values from the running config. """ +import os import re import subprocess @@ -96,7 +97,11 @@ class Config(object): # Running config can be obtained either from op or conf mode, it always succeeds # (if config system is initialized at all). - running_config_text = self._run([self._cli_shell_api, '--show-active-only', '--show-show-defaults', 'showConfig']) + if os.path.isfile('/tmp/vyos-config-status'): + running_config_text = self._run([self._cli_shell_api, '--show-active-only', '--show-show-defaults', 'showConfig']) + else: + with open('/opt/vyatta/etc/config/config.boot') as f: + running_config_text = f.read() # Session config ("active") only exists in conf mode. # Trying to obtain it from op mode will cause a fatal cli-shell-api error. -- cgit v1.2.3