summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-12-18 06:26:56 +0100
committerChristian Breunig <christian@breunig.cc>2024-12-18 06:26:56 +0100
commite0c6262a7e564f1be54020606ae32de74e9b016a (patch)
treecb34f6b5f3513517b7db18c4eaef9aa66db290d9
parent31e71556f18308c85a1c0b0ef9f6f77b0ab83f7a (diff)
parent14ae33a55298e2a5264b26d20c8f8f06d3b2266a (diff)
downloadvyos-1x-e0c6262a7e564f1be54020606ae32de74e9b016a.tar.gz
vyos-1x-e0c6262a7e564f1be54020606ae32de74e9b016a.zip
Merge branch 'frr-10' into current
* frr-10: op-mode: T6746: add "show log frr" and "monitor log frr" commands frrender: T6746: do not render candidate FRR config to running FRR config file path frrender: T6746: ensure there are no empty lines in the rendered FRR configuration bgp: T6746: remove debug code
-rw-r--r--op-mode-definitions/monitor-log.xml.in6
-rwxr-xr-xop-mode-definitions/show-log.xml.in6
-rw-r--r--python/vyos/frrender.py27
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py5
4 files changed, 28 insertions, 16 deletions
diff --git a/op-mode-definitions/monitor-log.xml.in b/op-mode-definitions/monitor-log.xml.in
index 66b7ecb2f..f6b70be32 100644
--- a/op-mode-definitions/monitor-log.xml.in
+++ b/op-mode-definitions/monitor-log.xml.in
@@ -114,6 +114,12 @@
</properties>
<command>journalctl --no-hostname --boot --follow --unit uacctd.service</command>
</leafNode>
+ <leafNode name="frr">
+ <properties>
+ <help>Monitor last lines of FRRouting suite log</help>
+ </properties>
+ <command>journalctl --no-hostname --boot --follow --unit frr.service</command>
+ </leafNode>
<leafNode name="ipoe-server">
<properties>
<help>Monitor last lines of IP over Ethernet server log</help>
diff --git a/op-mode-definitions/show-log.xml.in b/op-mode-definitions/show-log.xml.in
index b032f5e38..9dcebb6af 100755
--- a/op-mode-definitions/show-log.xml.in
+++ b/op-mode-definitions/show-log.xml.in
@@ -533,6 +533,12 @@
</properties>
<command>journalctl --no-hostname --boot --unit uacctd.service</command>
</leafNode>
+ <leafNode name="frr">
+ <properties>
+ <help>Show log for FRRouting suite</help>
+ </properties>
+ <command>journalctl --no-hostname --boot --unit frr.service</command>
+ </leafNode>
<leafNode name="https">
<properties>
<help>Show log for HTTPs</help>
diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py
index 95d6c7243..0c9dde315 100644
--- a/python/vyos/frrender.py
+++ b/python/vyos/frrender.py
@@ -19,8 +19,11 @@ Library used to interface with FRRs mgmtd introduced in version 10.0
import os
+from time import sleep
+
from vyos.defaults import frr_debug_enable
from vyos.utils.file import write_file
+from vyos.utils.process import cmd
from vyos.utils.process import rc_cmd
from vyos.template import render_to_string
from vyos import ConfigError
@@ -53,7 +56,7 @@ zebra_daemon = 'zebra'
class FRRender:
def __init__(self):
- self._frr_conf = '/run/frr/config/frr.conf'
+ self._frr_conf = '/run/frr/config/vyos.frr.conf'
def generate(self, config):
if not isinstance(config, dict):
@@ -136,7 +139,7 @@ class FRRender:
output += '\n'
if 'vrf' in config and 'name' in config['vrf']:
- output += render_to_string('frr/zebra.vrf.route-map.frr.j2', config['vrf']) + '\n'
+ output += render_to_string('frr/zebra.vrf.route-map.frr.j2', config['vrf'])
for vrf, vrf_config in config['vrf']['name'].items():
if 'protocols' not in vrf_config:
continue
@@ -145,32 +148,34 @@ class FRRender:
output += inline_helper(vrf_config['protocols'])
+ # remove any accidently added empty newline to not confuse FRR
+ output = os.linesep.join([s for s in output.splitlines() if s])
+
+ if '!!' in output:
+ raise ConfigError('FRR configuration contains "!!" which is not allowed')
+
debug(output)
debug('======< RENDERING CONFIG COMPLETE >======')
write_file(self._frr_conf, output)
- if DEBUG_ON: write_file('/tmp/frr.conf.debug', output)
- def apply(self):
+ def apply(self, count_max=5):
count = 0
- count_max = 5
emsg = ''
while count < count_max:
count += 1
debug(f'FRR: Reloading configuration - tries: {count} | Python class ID: {id(self)}')
-
cmdline = '/usr/lib/frr/frr-reload.py --reload'
- if DEBUG_ON:
- cmdline += ' --debug'
+ if DEBUG_ON: cmdline += ' --debug'
rc, emsg = rc_cmd(f'{cmdline} {self._frr_conf}')
if rc != 0:
- debug('FRR configuration reload failed, retrying')
+ sleep(2)
continue
debug(emsg)
debug('======< DONE APPLYING CONFIG >======')
break
+
if count >= count_max:
raise ConfigError(emsg)
- def save_configuration():
- """ T3217: Save FRR configuration to /run/frr/config/frr.conf """
+ # T3217: Save FRR configuration to /run/frr/config/frr.conf
return cmd('/usr/bin/vtysh -n --writeconfig')
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index ae32dd839..60f3f2ad0 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -176,11 +176,6 @@ def verify_afi(peer_config, bgp_config):
return False
def verify(config_dict):
-
- print('====== verify() ======')
- import pprint
- pprint.pprint(config_dict)
-
if not has_frr_protocol_in_dict(config_dict, 'bgp'):
return None