Skip to content

Commit

Permalink
Add OpenBGPD support, closes #206
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Dec 26, 2022
1 parent 7fd35f5 commit 6fcf8ca
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hyperglass/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@
DRIVER_MAP = {
"bird": "netmiko",
"frr": "netmiko",
"openbgpd": "netmiko",
"http": "hyperglass_http_client",
}

LINUX_PLATFORMS = (
"frr",
"bird",
"openbgpd",
)
103 changes: 103 additions & 0 deletions hyperglass/defaults/directives/openbgpd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""Default FRRouting Directives."""

# Project
from hyperglass.models.directive import Rule, Text, BuiltinDirective

__all__ = (
"OpenBGPD_BGPASPath",
"OpenBGPD_BGPCommunity",
"OpenBGPD_BGPRoute",
"OpenBGPD_Ping",
"OpenBGPD_Traceroute",
)

OpenBGPD_BGPRoute = BuiltinDirective(
id="__hyperglass_openbgpd_bgp_route__",
name="BGP Route",
rules=[
Rule(
condition="0.0.0.0/0",
action="permit",
command="bgpctl show rib inet {target}",
),
Rule(
condition="::/0",
action="permit",
command="bgpctl show rib inet6 {target}",
),
],
field=Text(description="IP Address, Prefix, or Hostname"),
platforms=["openbgpd"],
)

OpenBGPD_BGPASPath = BuiltinDirective(
id="__hyperglass_openbgpd_bgp_aspath__",
name="BGP AS Path",
rules=[
Rule(
condition="*",
action="permit",
commands=[
"bgpctl show rib inet as {target}",
"bgpctl show rib inet6 as {target}",
],
)
],
field=Text(description="AS Path Regular Expression"),
platforms=["openbgpd"],
)

OpenBGPD_BGPCommunity = BuiltinDirective(
id="__hyperglass_openbgpd_bgp_community__",
name="BGP Community",
rules=[
Rule(
condition="*",
action="permit",
commands=[
"bgpctl show rib inet community {target}",
"bgpctl show rib inet6 community {target}",
],
)
],
field=Text(description="BGP Community String"),
platforms=["openbgpd"],
)

OpenBGPD_Ping = BuiltinDirective(
id="__hyperglass_openbgpd_ping__",
name="Ping",
rules=[
Rule(
condition="0.0.0.0/0",
action="permit",
command="ping -4 -c 5 -I {source4} {target}",
),
Rule(
condition="::/0",
action="permit",
command="ping -6 -c 5 -I {source6} {target}",
),
],
field=Text(description="IP Address, Prefix, or Hostname"),
platforms=["openbgpd"],
)

OpenBGPD_Traceroute = BuiltinDirective(
id="__hyperglass_openbgpd_traceroute__",
name="Traceroute",
rules=[
Rule(
condition="0.0.0.0/0",
action="permit",
command="traceroute -4 -w 1 -q 1 -s {source4} {target}",
),
Rule(
condition="::/0",
action="permit",
command="traceroute -6 -w 1 -q 1 -s {source6} {target}",
),
],
field=Text(description="IP Address, Prefix, or Hostname"),
platforms=["openbgpd"],
)

0 comments on commit 6fcf8ca

Please sign in to comment.