From 1666e3d99b8de700c880f09ce6ad5ea8bc7f4568 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 8 Dec 2024 15:41:53 +0100 Subject: frr: T6746: add default entry for config debug file A lot of services have dynamic debug capabilities which will be turned on by creating a file in /tmp. These scripts have the path hardcoded and sometimes accross multiple places (bad). This commit introduces vyos.defaults.frr_debug_enable to get the path for the debug file from a single location. --- python/vyos/configdict.py | 10 ++++++---- python/vyos/defaults.py | 1 + python/vyos/frr.py | 3 ++- python/vyos/frrender.py | 4 ++-- src/init/vyos-router | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 88d131573..c7384f71d 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -19,6 +19,7 @@ A library for retrieving value dicts from VyOS configs in a declarative fashion. import os import json +from vyos.defaults import frr_debug_enable from vyos.utils.dict import dict_search from vyos.utils.process import cmd @@ -1124,8 +1125,9 @@ def get_frrender_dict(conf) -> dict: dict.update({'vrf' : vrf}) - print('======== < > ==========') - import pprint - pprint.pprint(dict) - print('======== < > ==========') + if os.path.exists(frr_debug_enable): + print('======== < BEGIN > ==========') + import pprint + pprint.pprint(dict) + print('========= < END > ===========') return dict diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py index 425990967..9757a34df 100644 --- a/python/vyos/defaults.py +++ b/python/vyos/defaults.py @@ -42,6 +42,7 @@ directories = { config_status = '/tmp/vyos-config-status' api_config_state = '/run/http-api-state' +frr_debug_enable = '/tmp/vyos.frr.debug' cfg_group = 'vyattacfg' diff --git a/python/vyos/frr.py b/python/vyos/frr.py index 183805e13..67279a6f7 100644 --- a/python/vyos/frr.py +++ b/python/vyos/frr.py @@ -69,6 +69,7 @@ import tempfile import re from vyos import ConfigError +from vyos.defaults import frr_debug_enable from vyos.utils.process import cmd from vyos.utils.process import popen from vyos.utils.process import STDOUT @@ -144,7 +145,7 @@ class ConfigSectionNotFound(FrrError): def init_debugging(): global DEBUG - DEBUG = os.path.exists('/tmp/vyos.frr.debug') + DEBUG = os.path.exists(frr_debug_enable) if DEBUG: LOG.setLevel(logging.DEBUG) diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py index 015596a8f..2069930a9 100644 --- a/python/vyos/frrender.py +++ b/python/vyos/frrender.py @@ -19,13 +19,13 @@ Library used to interface with FRRs mgmtd introduced in version 10.0 import os +from vyos.defaults import frr_debug_enable from vyos.utils.file import write_file from vyos.utils.process import rc_cmd from vyos.template import render_to_string from vyos import ConfigError -DEBUG_ON = os.path.exists('/tmp/vyos.frr.debug') -DEBUG_ON = True +DEBUG_ON = os.path.exists(frr_debug_enable) def debug(message): if not DEBUG_ON: diff --git a/src/init/vyos-router b/src/init/vyos-router index e2e964656..00136309b 100755 --- a/src/init/vyos-router +++ b/src/init/vyos-router @@ -474,9 +474,10 @@ start () # enable some debugging before loading the configuration if grep -q vyos-debug /proc/cmdline; then log_action_begin_msg "Enable runtime debugging options" + FRR_DEBUG=$(python3 -c "from vyos.defaults import frr_debug_enable; print(frr_debug_enable)") + touch $FRR_DEBUG touch /tmp/vyos.container.debug touch /tmp/vyos.ifconfig.debug - touch /tmp/vyos.frr.debug touch /tmp/vyos.container.debug touch /tmp/vyos.smoketest.debug fi -- cgit v1.2.3