From 18e0b3e7e7aa61015fd79b131052a760e150c2bb Mon Sep 17 00:00:00 2001 From: Andrew Ying Date: Fri, 15 Nov 2024 17:34:29 +0000 Subject: [PATCH] Add 6WIND directives (#1) Reviewed-on: https://git.witine.com/witine/lookingglass/pulls/1 --- hyperglass/defaults/directives/sixwind_os.py | 76 ++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 hyperglass/defaults/directives/sixwind_os.py diff --git a/hyperglass/defaults/directives/sixwind_os.py b/hyperglass/defaults/directives/sixwind_os.py new file mode 100644 index 0000000..e024e72 --- /dev/null +++ b/hyperglass/defaults/directives/sixwind_os.py @@ -0,0 +1,76 @@ +"""Default 6WIND Directives.""" + +# Project +from hyperglass.models.directive import ( + Text, + RuleWithIPv4, + RuleWithIPv6, + RuleWithPattern, + BuiltinDirective, +) + +__all__ = ( + "SixWind_BGPRoute", + "SixWind_Ping", + "SixWind_Traceroute", +) + +NAME = "6WIND" +PLATFORMS = ["sixwind_os"] + +SixWind_BGPRoute = BuiltinDirective( + id="__hyperglass_sixwind_os_bgp_route__", + name="BGP Route", + rules=[ + RuleWithIPv4( + condition="0.0.0.0/0", + action="permit", + command="show bgp ipv4 unicast prefix {target}", + ), + RuleWithIPv6( + condition="::/0", + action="permit", + command="show bgp ipv6 unicast prefix {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=PLATFORMS, +) + +SixWind_Ping = BuiltinDirective( + id="__hyperglass_sixwind_os_ping__", + name="Ping", + rules=[ + RuleWithIPv4( + condition="0.0.0.0/0", + action="permit", + command="cmd ping packetsize 256 source {source4} {target}", + ), + RuleWithIPv6( + condition="::/0", + action="permit", + command="cmd ping packetsize 256 ipv6 source {source6} {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=PLATFORMS, +) + +SixWind_Traceroute = BuiltinDirective( + id="__hyperglass_sixwind_os_traceroute__", + name="Traceroute", + rules=[ + RuleWithIPv4( + condition="0.0.0.0/0", + action="permit", + command="cmd traceroute source {source4} {target}", + ), + RuleWithIPv6( + condition="::/0", + action="permit", + command="cmd traceroute ipv6 source {source6} {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=PLATFORMS, +)