summaryrefslogtreecommitdiff
path: root/src/conf_mode/system-syslog.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode/system-syslog.py')
-rwxr-xr-xsrc/conf_mode/system-syslog.py58
1 files changed, 5 insertions, 53 deletions
diff --git a/src/conf_mode/system-syslog.py b/src/conf_mode/system-syslog.py
index cf34bad2e..07fbb0734 100755
--- a/src/conf_mode/system-syslog.py
+++ b/src/conf_mode/system-syslog.py
@@ -19,12 +19,10 @@ import os
from sys import exit
from vyos.config import Config
-from vyos.configdict import dict_merge
from vyos.configdict import is_node_changed
from vyos.configverify import verify_vrf
-from vyos.util import call
+from vyos.utils.process import call
from vyos.template import render
-from vyos.xml import defaults
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -46,59 +44,13 @@ def get_config(config=None):
get_first_key=True, no_tag_node_value_mangle=True)
syslog.update({ 'logrotate' : logrotate_conf })
+
tmp = is_node_changed(conf, base + ['vrf'])
if tmp: syslog.update({'restart_required': {}})
- # 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)
- # XXX: some syslog default values can not be merged here (originating from
- # a tagNode - remove and add them later per individual tagNode instance
- if 'console' in default_values:
- del default_values['console']
- for entity in ['global', 'user', 'host', 'file']:
- if entity in default_values:
- del default_values[entity]
-
- syslog = dict_merge(default_values, syslog)
-
- # XXX: add defaults for "console" tree
- if 'console' in syslog and 'facility' in syslog['console']:
- default_values = defaults(base + ['console', 'facility'])
- for facility in syslog['console']['facility']:
- syslog['console']['facility'][facility] = dict_merge(default_values,
- syslog['console']['facility'][facility])
-
- # XXX: add defaults for "host" tree
- if 'host' in syslog:
- default_values_host = defaults(base + ['host'])
- if 'facility' in default_values_host:
- del default_values_host['facility']
- default_values_facility = defaults(base + ['host', 'facility'])
-
- for host, host_config in syslog['host'].items():
- syslog['host'][host] = dict_merge(default_values_host, syslog['host'][host])
- if 'facility' in host_config:
- for facility in host_config['facility']:
- syslog['host'][host]['facility'][facility] = dict_merge(default_values_facility,
- syslog['host'][host]['facility'][facility])
-
- # XXX: add defaults for "user" tree
- if 'user' in syslog:
- default_values = defaults(base + ['user', 'facility'])
- for user, user_config in syslog['user'].items():
- if 'facility' in user_config:
- for facility in user_config['facility']:
- syslog['user'][user]['facility'][facility] = dict_merge(default_values,
- syslog['user'][user]['facility'][facility])
-
- # XXX: add defaults for "file" tree
- if 'file' in syslog:
- default_values = defaults(base + ['file'])
- for file, file_config in syslog['file'].items():
- for facility in file_config['facility']:
- syslog['file'][file]['facility'][facility] = dict_merge(default_values,
- syslog['file'][file]['facility'][facility])
+ syslog = conf.merge_defaults(syslog, recursive=True)
+ if syslog.from_defaults(['global']):
+ del syslog['global']
return syslog