summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-12-14 16:47:37 +0100
committerChristian Poessinger <christian@poessinger.com>2020-12-28 19:42:50 +0100
commite7649f9cf4f6beda6adb50998db3e57964bd5010 (patch)
tree51b73f9bebc5587ff20c708105f1d56d0ed73e00 /src/conf_mode
parenta8a019c4f318ba6ad2f83b9b4f605de3830c7b28 (diff)
downloadvyos-1x-e7649f9cf4f6beda6adb50998db3e57964bd5010.tar.gz
vyos-1x-e7649f9cf4f6beda6adb50998db3e57964bd5010.zip
webproxy: T563: improve handling of cache-peers
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/service_webproxy.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/conf_mode/service_webproxy.py b/src/conf_mode/service_webproxy.py
index 128393e51..332e10329 100755
--- a/src/conf_mode/service_webproxy.py
+++ b/src/conf_mode/service_webproxy.py
@@ -44,16 +44,26 @@ def get_config(config=None):
# We have gathered the dict representation of the CLI, but there are default
# options which we need to update into the dictionary retrived.
default_values = defaults(base)
+
# if no authentication method is supplid, no need to add defaults
if not dict_search('authentication.method', proxy):
default_values.pop('authentication')
+
+ # XXX: T2665: blend in proper cache-peer default values later
+ default_values.pop('cache_peer')
proxy = dict_merge(default_values, proxy)
+ # XXX: T2665: blend in proper cache-peer default values
+ if 'cache_peer' in proxy:
+ default_values = defaults(base + ['cache-peer'])
+ for peer in proxy['cache_peer']:
+ proxy['cache_peer'][peer] = dict_merge(default_values,
+ proxy['cache_peer'][peer])
+
import pprint
pprint.pprint(proxy)
return proxy
-
def verify(proxy):
if not proxy:
return None
@@ -99,6 +109,11 @@ def verify(proxy):
if 'base_dn' not in ldap_config:
raise ConfigError('LDAP base-dn must be set!')
+ if 'cache_peer' in proxy:
+ for peer, config in proxy['cache_peer'].items():
+ if 'address' not in config:
+ raise ConfigError(f'Cache-peer "{peer}" address must be set!')
+
def generate(proxy):
if not proxy:
return None