summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-17 20:28:11 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-17 20:28:11 +0100
commitc9e630b446f069b3a803c1e7c22e559797bce975 (patch)
tree59d08b7f488c66ca6fe0b2194c1b8ed251cab487 /src
parentfe5c69723ceaf94514336119907c5e1a2acbae74 (diff)
downloadvyos-1x-c9e630b446f069b3a803c1e7c22e559797bce975.tar.gz
vyos-1x-c9e630b446f069b3a803c1e7c22e559797bce975.zip
bgp: T2174: add debug option
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index de0148b2f..0029b032a 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import os
+
from sys import exit
from vyos.config import Config
@@ -29,6 +31,14 @@ airbag.enable()
config_file = r'/tmp/bgp.frr'
+DEBUG = os.path.exists('/tmp/bgp.debug')
+if DEBUG:
+ import logging
+ lg = logging.getLogger("vyos.frr")
+ lg.setLevel(logging.DEBUG)
+ ch = logging.StreamHandler()
+ lg.addHandler(ch)
+
def get_config():
conf = Config()
base = ['protocols', 'bgp']
@@ -147,13 +157,19 @@ def apply(bgp):
frr_cfg.commit_configuration(daemon='bgpd')
# Debugging
- '''
- print('')
- print('--------- DEBUGGING ----------')
- print(f'Existing config:\n{frr_cfg["original_config"]}\n\n')
- print(f'Replacement config:\n{bgp["new_frr_config"]}\n\n')
- print(f'Modified config:\n{frr_cfg["modified_config"]}\n\n')
- '''
+ if DEBUG:
+ from pprint import pprint
+ print('')
+ print('--------- DEBUGGING ----------')
+ pprint(dir(frr_cfg))
+ print('Existing config:\n')
+ for line in frr_cfg.original_config:
+ print(line)
+ print(f'Replacement config:\n')
+ print(f'{bgp["new_frr_config"]}')
+ print(f'Modified config:\n')
+ print(f'{frr_cfg}')
+
return None