summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/system_syslog.py23
-rw-r--r--src/migration-scripts/system/28-to-297
2 files changed, 20 insertions, 10 deletions
diff --git a/src/conf_mode/system_syslog.py b/src/conf_mode/system_syslog.py
index ce806a540..6f6546fd1 100755
--- a/src/conf_mode/system_syslog.py
+++ b/src/conf_mode/system_syslog.py
@@ -53,16 +53,13 @@ def get_config(config=None):
if syslog.from_defaults(['global']):
del syslog['global']
- if (
- 'global' in syslog
- and 'preserve_fqdn' in syslog['global']
- and conf.exists(['system', 'host-name'])
- and conf.exists(['system', 'domain-name'])
- ):
- hostname = conf.return_value(['system', 'host-name'])
- domain = conf.return_value(['system', 'domain-name'])
- fqdn = f'{hostname}.{domain}'
- syslog['global']['local_host_name'] = fqdn
+ if 'preserve_fqdn' in syslog:
+ if conf.exists(['system', 'host-name']):
+ tmp = conf.return_value(['system', 'host-name'])
+ syslog['preserve_fqdn']['host_name'] = tmp
+ if conf.exists(['system', 'domain-name']):
+ tmp = conf.return_value(['system', 'domain-name'])
+ syslog['preserve_fqdn']['domain_name'] = tmp
return syslog
@@ -70,6 +67,12 @@ def verify(syslog):
if not syslog:
return None
+ if 'preserve_fqdn' in syslog:
+ if 'host_name' not in syslog['preserve_fqdn']:
+ Warning('No "system host-name" defined - cannot set syslog FQDN!')
+ if 'domain_name' not in syslog['preserve_fqdn']:
+ Warning('No "system domain-name" defined - cannot set syslog FQDN!')
+
if 'remote' in syslog:
for host, host_options in syslog['remote'].items():
if 'protocol' in host_options and host_options['protocol'] == 'udp':
diff --git a/src/migration-scripts/system/28-to-29 b/src/migration-scripts/system/28-to-29
index 1addad035..dadfc994a 100644
--- a/src/migration-scripts/system/28-to-29
+++ b/src/migration-scripts/system/28-to-29
@@ -16,6 +16,7 @@
# T6989:
# - remove syslog arbitrary file logging
# - remove syslog user console logging
+# - move "global preserve-fqdn" one CLI level up
# - rename "host" to "remote"
from vyos.configtree import ConfigTree
@@ -34,6 +35,12 @@ def migrate(config: ConfigTree) -> None:
if config.exists(base + ['user']):
config.delete(base + ['user'])
+ # Move "global preserve-fqdn" one CLI level up, as it relates to all
+ # logging targets (console, global and remote)
+ if config.exists(base + ['global', 'preserve-fqdn']):
+ config.delete(base + ['global', 'preserve-fqdn'])
+ config.set(base + ['preserve-fqdn'])
+
# Rename host x.x.x.x -> remote x.x.x.x
if config.exists(base + ['host']):
config.set(base + ['remote'])