Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Added support for BGP Large communities with Frr #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hyperglass_frr/configuration.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ key = "1234"
[commands.ipv4]
bgp_route = "show bgp ipv4 unicast {target}"
bgp_community = "show bgp ipv4 unicast community {target}"
bgp_large_community = "show bgp ipv4 unicast large-community {target}"
bgp_aspath = "show bgp ipv4 unicast regexp {target}"
ping = "ping -4 -c 5 -I {source} {target}"
traceroute = "traceroute -4 -w 1 -q 1 -s {source} {target}"

[commands.ipv6]
bgp_route = "show bgp ipv6 unicast {target}"
bgp_community = "show bgp ipv6 unicast community {target}"
bgp_large_community = "show bgp ipv6 unicast large-community {target}"
bgp_aspath = "show bgp ipv6 unicast regexp {target}"
ping = "ping -6 -c 5 -I {source} {target}"
traceroute = "traceroute -6 -w 1 -q 1 -s {source} {target}"
10 changes: 9 additions & 1 deletion hyperglass_frr/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Execute the constructed command
"""
# Standard Imports
import re
import logging
import subprocess

Expand All @@ -24,6 +25,13 @@ def execute(query):
logger.debug(f"Received query: {query}")
query_type = query.get("query_type")
try:
if query_type in ["bgp_community"]:
target = query.get("target")
logger.debug(f'{query_type}: Check for large community {target}')
if re.match("^([0-9]{1,10})\:([0-9]{1,10})\:[0-9]{1,10}$", target):
logger.debug(f'Large community detected.')
query["query_type"] = "bgp_large_community"

command = configuration.Command(query)
if query_type in ["bgp_route", "bgp_community", "bgp_aspath"]:
logger.debug(f'Running vtysh command "{command}"')
Expand All @@ -36,5 +44,5 @@ def execute(query):
except subprocess.CalledProcessError as error_exception:
output = f'Unable to reach {query["target"]}.'
status = 504
logger.debug(f"{output} Error:\n{ping_error}")
logger.debug(f"{output} Ping error:\n")
return (output, status)