summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorJernej Jakob <jernej.jakob@gmail.com>2020-06-11 08:24:06 +0200
committerJernej Jakob <jernej.jakob@gmail.com>2020-06-11 22:10:47 +0200
commit1eaf0077f2b42405d9bf8699dcf813c1b249d6fc (patch)
treef3c5b582a128c1331cc90c243eb62d329fbe282d /src/conf_mode
parent2b49fbf65aace72a9cd5629db48ae211e18a4e4a (diff)
downloadvyos-1x-1eaf0077f2b42405d9bf8699dcf813c1b249d6fc.tar.gz
vyos-1x-1eaf0077f2b42405d9bf8699dcf813c1b249d6fc.zip
dns forwarding: T2486: move Config() call into main
As Config is required in both get_config and verify, init it once and pass it to both functions.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/dns_forwarding.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py
index 188a39ef0..aedfb2623 100755
--- a/src/conf_mode/dns_forwarding.py
+++ b/src/conf_mode/dns_forwarding.py
@@ -46,9 +46,8 @@ default_config_data = {
}
-def get_config():
+def get_config(conf):
dns = deepcopy(default_config_data)
- conf = Config()
base = ['service', 'dns', 'forwarding']
if not conf.exists(base):
@@ -122,7 +121,7 @@ def bracketize_ipv6_addrs(addrs):
"""Wraps each IPv6 addr in addrs in [], leaving IPv4 addrs untouched."""
return ['[{0}]'.format(a) if a.count(':') > 1 else a for a in addrs]
-def verify(dns):
+def verify(conf, dns):
# bail out early - looks like removal from running config
if dns is None:
return None
@@ -164,8 +163,9 @@ if __name__ == '__main__':
try:
- c = get_config()
- verify(c)
+ conf = Config()
+ c = get_config(conf)
+ verify(conf, c)
generate(c)
apply(c)
except ConfigError as e: