summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/frrender.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py
index 7221d5053..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):
@@ -154,29 +157,25 @@ class FRRender:
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')