mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
103 lines
2.6 KiB
Python
103 lines
2.6 KiB
Python
"""Default FRRouting Directives."""
|
|
|
|
# Project
|
|
from hyperglass.models.directive import Rule, Text, BuiltinDirective
|
|
|
|
__all__ = (
|
|
"FRRouting_BGPASPath",
|
|
"FRRouting_BGPCommunity",
|
|
"FRRouting_BGPRoute",
|
|
"FRRouting_Ping",
|
|
"FRRouting_Traceroute",
|
|
)
|
|
|
|
FRRouting_BGPRoute = BuiltinDirective(
|
|
id="__hyperglass_frr_bgp_route__",
|
|
name="BGP Route",
|
|
rules=[
|
|
Rule(
|
|
condition="0.0.0.0/0",
|
|
action="permit",
|
|
command='vtysh -c "show bgp ipv4 unicast {target}"',
|
|
),
|
|
Rule(
|
|
condition="::/0",
|
|
action="permit",
|
|
command='vtysh -c "show bgp ipv6 unicast {target}"',
|
|
),
|
|
],
|
|
field=Text(description="IP Address, Prefix, or Hostname"),
|
|
platforms=["frr"],
|
|
)
|
|
|
|
FRRouting_BGPASPath = BuiltinDirective(
|
|
id="__hyperglass_frr_bgp_aspath__",
|
|
name="BGP AS Path",
|
|
rules=[
|
|
Rule(
|
|
condition="*",
|
|
action="permit",
|
|
commands=[
|
|
'vtysh -c "show bgp ipv4 unicast regexp {target}"',
|
|
'vtysh -c "show bgp ipv6 unicast regexp {target}"',
|
|
],
|
|
)
|
|
],
|
|
field=Text(description="AS Path Regular Expression"),
|
|
platforms=["frr"],
|
|
)
|
|
|
|
FRRouting_BGPCommunity = BuiltinDirective(
|
|
id="__hyperglass_frr_bgp_community__",
|
|
name="BGP Community",
|
|
rules=[
|
|
Rule(
|
|
condition="*",
|
|
action="permit",
|
|
commands=[
|
|
'vtysh -c "show bgp ipv4 unicast community {target}"',
|
|
'vtysh -c "show bgp ipv6 unicast community {target}"',
|
|
],
|
|
)
|
|
],
|
|
field=Text(description="BGP Community String"),
|
|
platforms=["frr"],
|
|
)
|
|
|
|
FRRouting_Ping = BuiltinDirective(
|
|
id="__hyperglass_frr_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=["frr"],
|
|
)
|
|
|
|
FRRouting_Traceroute = BuiltinDirective(
|
|
id="__hyperglass_frr_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=["frr"],
|
|
)
|