summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRunar Borge <runar@borge.nu>2021-02-09 20:11:39 +0100
committerRunar Borge <runar@borge.nu>2021-02-09 20:26:48 +0100
commit015651a8f6de4cb12614e16d6212142b7985f98f (patch)
tree845cc87384ab2767cee0e46d1652e86693ba1e73 /python
parent96d1c8148bbc3d7fbe6438d34dbd0ceb85fab3ff (diff)
downloadvyos-1x-015651a8f6de4cb12614e16d6212142b7985f98f.tar.gz
vyos-1x-015651a8f6de4cb12614e16d6212142b7985f98f.zip
T2638: Enable more debugging in the FRR library
This will enable more debugging on the frr reload library, changes: * Adds a /tmp/vyos.frr.debug hook to enable system wide vyos.frr debugging * Log the initial imported configs * Log the FRR config submitted to frr-reload * redirecting frr-reload output to the debug log.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/frr.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/python/vyos/frr.py b/python/vyos/frr.py
index 76e204ab3..69c7a14ce 100644
--- a/python/vyos/frr.py
+++ b/python/vyos/frr.py
@@ -69,8 +69,17 @@ import tempfile
import re
from vyos import util
import logging
+from logging.handlers import SysLogHandler
+import os
LOG = logging.getLogger(__name__)
+DEBUG = os.path.exists('/tmp/vyos.frr.debug')
+if DEBUG:
+ LOG.setLevel(logging.DEBUG)
+ ch = SysLogHandler(address='/dev/log')
+ ch2 = logging.StreamHandler()
+ LOG.addHandler(ch)
+ LOG.addHandler(ch2)
_frr_daemons = ['zebra', 'bgpd', 'fabricd', 'isisd', 'ospf6d', 'ospfd', 'pbrd',
'pimd', 'ripd', 'ripngd', 'sharpd', 'staticd', 'vrrpd', 'ldpd']
@@ -175,15 +184,23 @@ def reload_configuration(config, daemon=None):
f.write(config)
f.flush()
+ LOG.debug(f'reload_configuration: Reloading config using temporary file: {f.name}')
cmd = f'{path_frr_reload} --reload'
if daemon:
cmd += f' --daemon {daemon}'
+
+ if DEBUG:
+ cmd += f' --debug --stdout'
+
cmd += f' {f.name}'
+ LOG.debug(f'reload_configuration: Executing command against frr-reload: "{cmd}"')
output, code = util.popen(cmd, stderr=util.STDOUT)
f.close()
+ for i, e in enumerate(output.split('\n')):
+ LOG.debug(f'frr-reload output: {i:3} {e}')
if code == 1:
- raise CommitError(f'Configuration FRR failed while commiting code: {repr(output)}')
+ raise CommitError(f'Configuration FRR failed while commiting code, please enabling debugging to examine logs')
elif code:
raise OSError(code, output)
@@ -382,6 +399,11 @@ class FRRConfig:
raise ValueError(
'The config element needs to be a string or list type object')
+ if config:
+ LOG.debug(f'__init__: frr library initiated with initial config')
+ for i, e in enumerate(self.config):
+ LOG.debug(f'__init__: initial {i:3} {e}')
+
def load_configuration(self, daemon=None):
'''Load the running configuration from FRR into the config object
daemon: str with name of the FRR Daemon to load configuration from or
@@ -390,9 +412,16 @@ class FRRConfig:
Using this overwrites the current loaded config objects and replaces the original loaded config
'''
self.imported_config = get_configuration(daemon=daemon)
- LOG.debug(f'load_configuration: Configuration loaded from FRR: {self.imported_config}')
+ if daemon:
+ LOG.debug(f'load_configuration: Configuration loaded from FRR daemon {daemon}')
+ else:
+ LOG.debug(f'load_configuration: Configuration loaded from FRR integrated config')
+
self.original_config = self.imported_config.split('\n')
self.config = self.original_config.copy()
+
+ for i, e in enumerate(self.imported_config.split('\n')):
+ LOG.debug(f'load_configuration: loaded {i:3} {e}')
return
def test_configuration(self):
@@ -408,6 +437,8 @@ class FRRConfig:
None to use the consolidated config
'''
LOG.debug('commit_configuration: Commiting configuration')
+ for i, e in enumerate(self.config):
+ LOG.debug(f'commit_configuration: new_config {i:3} {e}')
reload_configuration('\n'.join(self.config), daemon=daemon)
def modify_section(self, start_pattern, replacement=[], stop_pattern=r'\S+', remove_stop_mark=False, count=0):