From c8c13eea273044e1e1acbbbc3ee861bd82eb1ae7 Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Mon, 26 Dec 2022 10:57:30 -0500 Subject: [PATCH] migrate legacy builtin commands to directives --- hyperglass/defaults/directives/bird.py | 101 +++++++++++++++++ hyperglass/defaults/directives/cisco_ios.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/cisco_nxos.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/cisco_xr.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/frr.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/huawei.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/mikrotik.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/nokia_sros.py | 101 +++++++++++++++++ hyperglass/defaults/directives/tnsr.py | 103 ++++++++++++++++++ hyperglass/defaults/directives/vyos.py | 103 ++++++++++++++++++ hyperglass/models/commands/__init__.py | 62 ----------- hyperglass/models/commands/_mikrotik_base.py | 60 ---------- hyperglass/models/commands/arista_eos.py | 93 ---------------- hyperglass/models/commands/bird.py | 56 ---------- hyperglass/models/commands/cisco_ios.py | 56 ---------- hyperglass/models/commands/cisco_nxos.py | 56 ---------- hyperglass/models/commands/cisco_xr.py | 56 ---------- hyperglass/models/commands/common.py | 26 ----- hyperglass/models/commands/frr.py | 56 ---------- hyperglass/models/commands/huawei.py | 64 ----------- hyperglass/models/commands/juniper.py | 95 ---------------- .../models/commands/mikrotik_routeros.py | 9 -- .../models/commands/mikrotik_switchos.py | 9 -- hyperglass/models/commands/nokia_sros.py | 56 ---------- hyperglass/models/commands/tnsr.py | 72 ------------ hyperglass/models/commands/vyos.py | 56 ---------- 26 files changed, 1026 insertions(+), 882 deletions(-) create mode 100644 hyperglass/defaults/directives/bird.py create mode 100644 hyperglass/defaults/directives/cisco_ios.py create mode 100644 hyperglass/defaults/directives/cisco_nxos.py create mode 100644 hyperglass/defaults/directives/cisco_xr.py create mode 100644 hyperglass/defaults/directives/frr.py create mode 100644 hyperglass/defaults/directives/huawei.py create mode 100644 hyperglass/defaults/directives/mikrotik.py create mode 100644 hyperglass/defaults/directives/nokia_sros.py create mode 100644 hyperglass/defaults/directives/tnsr.py create mode 100644 hyperglass/defaults/directives/vyos.py delete mode 100644 hyperglass/models/commands/__init__.py delete mode 100644 hyperglass/models/commands/_mikrotik_base.py delete mode 100644 hyperglass/models/commands/arista_eos.py delete mode 100644 hyperglass/models/commands/bird.py delete mode 100644 hyperglass/models/commands/cisco_ios.py delete mode 100644 hyperglass/models/commands/cisco_nxos.py delete mode 100644 hyperglass/models/commands/cisco_xr.py delete mode 100644 hyperglass/models/commands/common.py delete mode 100644 hyperglass/models/commands/frr.py delete mode 100644 hyperglass/models/commands/huawei.py delete mode 100644 hyperglass/models/commands/juniper.py delete mode 100644 hyperglass/models/commands/mikrotik_routeros.py delete mode 100644 hyperglass/models/commands/mikrotik_switchos.py delete mode 100644 hyperglass/models/commands/nokia_sros.py delete mode 100644 hyperglass/models/commands/tnsr.py delete mode 100644 hyperglass/models/commands/vyos.py diff --git a/hyperglass/defaults/directives/bird.py b/hyperglass/defaults/directives/bird.py new file mode 100644 index 0000000..1e04c6c --- /dev/null +++ b/hyperglass/defaults/directives/bird.py @@ -0,0 +1,101 @@ +"""Default BIRD Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "BIRD_BGPASPath", + "BIRD_BGPCommunity", + "BIRD_BGPRoute", + "BIRD_Ping", + "BIRD_Traceroute", +) + +BIRD_BGPRoute = BuiltinDirective( + id="__hyperglass_bird_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command='birdc "show route all where {target} ~ net"', + ), + Rule( + condition="::/0", + action="permit", + command='birdc "show route all where {target} ~ net"', + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["bird"], +) + +BIRD_BGPASPath = BuiltinDirective( + id="__hyperglass_bird_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'birdc "show route all where bgp_path ~ {target}"', + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["bird"], +) + +BIRD_BGPCommunity = BuiltinDirective( + id="__hyperglass_bird_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'birdc "show route all where {target} ~ bgp_community"', + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["bird"], +) + +BIRD_Ping = BuiltinDirective( + id="__hyperglass_bird_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=["bird"], +) + +BIRD_Traceroute = BuiltinDirective( + id="__hyperglass_bird_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=["bird"], +) diff --git a/hyperglass/defaults/directives/cisco_ios.py b/hyperglass/defaults/directives/cisco_ios.py new file mode 100644 index 0000000..f8326de --- /dev/null +++ b/hyperglass/defaults/directives/cisco_ios.py @@ -0,0 +1,103 @@ +"""Default Cisco IOS Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "CiscoIOS_BGPASPath", + "CiscoIOS_BGPCommunity", + "CiscoIOS_BGPRoute", + "CiscoIOS_Ping", + "CiscoIOS_Traceroute", +) + +CiscoIOS_BGPRoute = BuiltinDirective( + id="__hyperglass_cisco_ios_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="show bgp ipv4 unicast {target} | exclude pathid:|Epoch", + ), + Rule( + condition="::/0", + action="permit", + command="show bgp ipv6 unicast {target} | exclude pathid:|Epoch", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_ios"], +) + +CiscoIOS_BGPASPath = BuiltinDirective( + id="__hyperglass_cisco_ios_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'show bgp ipv4 unicast quote-regexp "{target}"', + 'show bgp ipv6 unicast quote-regexp "{target}"', + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["cisco_ios"], +) + +CiscoIOS_BGPCommunity = BuiltinDirective( + id="__hyperglass_cisco_ios_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "show bgp ipv4 unicast community {target}", + "show bgp ipv6 unicast community {target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["cisco_ios"], +) + +CiscoIOS_Ping = BuiltinDirective( + id="__hyperglass_cisco_ios_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping {target} repeat 5 source {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="ping ipv6 {target} repeat 5 source {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_ios"], +) + +CiscoIOS_Traceroute = BuiltinDirective( + id="__hyperglass_cisco_ios_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="traceroute {target} timeout 1 probe 2 source {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="traceroute ipv6 {target} timeout 1 probe 2 source {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_ios"], +) diff --git a/hyperglass/defaults/directives/cisco_nxos.py b/hyperglass/defaults/directives/cisco_nxos.py new file mode 100644 index 0000000..e021dd9 --- /dev/null +++ b/hyperglass/defaults/directives/cisco_nxos.py @@ -0,0 +1,103 @@ +"""Default Cisco NX-OS Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "CiscoNXOS_BGPASPath", + "CiscoNXOS_BGPCommunity", + "CiscoNXOS_BGPRoute", + "CiscoNXOS_Ping", + "CiscoNXOS_Traceroute", +) + +CiscoNXOS_BGPRoute = BuiltinDirective( + id="__hyperglass_cisco_nxos_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="show bgp ipv4 unicast {target}", + ), + Rule( + condition="::/0", + action="permit", + command="show bgp ipv6 unicast {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_nxos"], +) + +CiscoNXOS_BGPASPath = BuiltinDirective( + id="__hyperglass_cisco_nxos_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'show bgp ipv4 unicast regexp "{target}"', + 'show bgp ipv6 unicast regexp "{target}"', + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["cisco_nxos"], +) + +CiscoNXOS_BGPCommunity = BuiltinDirective( + id="__hyperglass_cisco_nxos_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "show bgp ipv4 unicast community {target}", + "show bgp ipv6 unicast community {target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["cisco_nxos"], +) + +CiscoNXOS_Ping = BuiltinDirective( + id="__hyperglass_cisco_nxos_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping {target} source {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="ping6 {target} source {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_nxos"], +) + +CiscoNXOS_Traceroute = BuiltinDirective( + id="__hyperglass_cisco_nxos_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="traceroute {target} source {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="traceroute6 {target} source {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_nxos"], +) diff --git a/hyperglass/defaults/directives/cisco_xr.py b/hyperglass/defaults/directives/cisco_xr.py new file mode 100644 index 0000000..20ec5ca --- /dev/null +++ b/hyperglass/defaults/directives/cisco_xr.py @@ -0,0 +1,103 @@ +"""Default Cisco IOS-XR Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "CiscoXR_BGPASPath", + "CiscoXR_BGPCommunity", + "CiscoXR_BGPRoute", + "CiscoXR_Ping", + "CiscoXR_Traceroute", +) + +CiscoXR_BGPRoute = BuiltinDirective( + id="__hyperglass_cisco_xr_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="show bgp ipv4 unicast {target}", + ), + Rule( + condition="::/0", + action="permit", + command="show bgp ipv6 unicast {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_xr"], +) + +CiscoXR_BGPASPath = BuiltinDirective( + id="__hyperglass_cisco_xr_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "show bgp ipv4 unicast regexp {target}", + "show bgp ipv6 unicast regexp {target}", + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["cisco_xr"], +) + +CiscoXR_BGPCommunity = BuiltinDirective( + id="__hyperglass_cisco_xr_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "show bgp ipv4 unicast community {target}", + "show bgp ipv6 unicast community {target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["cisco_xr"], +) + +CiscoXR_Ping = BuiltinDirective( + id="__hyperglass_cisco_xr_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping ipv4 {target} count 5 source {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="ping ipv6 {target} count 5 source {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_xr"], +) + +CiscoXR_Traceroute = BuiltinDirective( + id="__hyperglass_cisco_xr_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="traceroute ipv4 {target} timeout 1 probe 2 source {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="traceroute ipv6 {target} timeout 1 probe 2 source {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["cisco_xr"], +) diff --git a/hyperglass/defaults/directives/frr.py b/hyperglass/defaults/directives/frr.py new file mode 100644 index 0000000..c214786 --- /dev/null +++ b/hyperglass/defaults/directives/frr.py @@ -0,0 +1,103 @@ +"""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"], +) diff --git a/hyperglass/defaults/directives/huawei.py b/hyperglass/defaults/directives/huawei.py new file mode 100644 index 0000000..99b4c35 --- /dev/null +++ b/hyperglass/defaults/directives/huawei.py @@ -0,0 +1,103 @@ +"""Default Huawei Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "Huawei_BGPASPath", + "Huawei_BGPCommunity", + "Huawei_BGPRoute", + "Huawei_Ping", + "Huawei_Traceroute", +) + +Huawei_BGPRoute = BuiltinDirective( + id="__hyperglass_huawei_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="display bgp routing-table {target}", + ), + Rule( + condition="::/0", + action="permit", + command="display bgp ipv6 routing-table {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["huawei"], +) + +Huawei_BGPASPath = BuiltinDirective( + id="__hyperglass_huawei_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "display bgp routing-table regular-expression {target}", + "display bgp ipv6 routing-table regular-expression {target}", + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["huawei"], +) + +Huawei_BGPCommunity = BuiltinDirective( + id="__hyperglass_huawei_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "display bgp routing-table community {target}", + "display bgp ipv6 routing-table community {target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["huawei"], +) + +Huawei_Ping = BuiltinDirective( + id="__hyperglass_huawei_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping -c 5 -a {source4} {target}", + ), + Rule( + condition="::/0", + action="permit", + command="ping ipv6 -c 5 -a {source6} {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["huawei"], +) + +Huawei_Traceroute = BuiltinDirective( + id="__hyperglass_huawei_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="tracert -q 2 -f 1 -a {source4} {target}", + ), + Rule( + condition="::/0", + action="permit", + command="tracert -q 2 -f 1 -a {source6} {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["huawei"], +) diff --git a/hyperglass/defaults/directives/mikrotik.py b/hyperglass/defaults/directives/mikrotik.py new file mode 100644 index 0000000..17d19bb --- /dev/null +++ b/hyperglass/defaults/directives/mikrotik.py @@ -0,0 +1,103 @@ +"""Default Mikrotik Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "Mikrotik_BGPASPath", + "Mikrotik_BGPCommunity", + "Mikrotik_BGPRoute", + "Mikrotik_Ping", + "Mikrotik_Traceroute", +) + +Mikrotik_BGPRoute = BuiltinDirective( + id="__hyperglass_mikrotik_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ip route print where dst-address={target}", + ), + Rule( + condition="::/0", + action="permit", + command="ipv6 route print where dst-address={target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["mikrotik_routeros", "mikrotik_switchos"], +) + +Mikrotik_BGPASPath = BuiltinDirective( + id="__hyperglass_mikrotik_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "ip route print where bgp-as-path={target}", + "ipv6 route print where bgp-as-path={target}", + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["mikrotik_routeros", "mikrotik_switchos"], +) + +Mikrotik_BGPCommunity = BuiltinDirective( + id="__hyperglass_mikrotik_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "ip route print where bgp-communities={target}", + "ipv6 route print where bgp-communities={target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["mikrotik_routeros", "mikrotik_switchos"], +) + +Mikrotik_Ping = BuiltinDirective( + id="__hyperglass_mikrotik_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping src-address={source4} count=5 {target}", + ), + Rule( + condition="::/0", + action="permit", + command="ping src-address={source6} count=5 {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["mikrotik_routeros", "mikrotik_switchos"], +) + +Mikrotik_Traceroute = BuiltinDirective( + id="__hyperglass_mikrotik_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="tool traceroute src-address={source4} timeout=1 duration=5 count=1 {target}", + ), + Rule( + condition="::/0", + action="permit", + command="tool traceroute src-address={source6} timeout=1 duration=5 count=1 {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["mikrotik_routeros", "mikrotik_switchos"], +) diff --git a/hyperglass/defaults/directives/nokia_sros.py b/hyperglass/defaults/directives/nokia_sros.py new file mode 100644 index 0000000..6995c04 --- /dev/null +++ b/hyperglass/defaults/directives/nokia_sros.py @@ -0,0 +1,101 @@ +"""Default Nokia SR-OS Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "NokiaSROS_BGPASPath", + "NokiaSROS_BGPCommunity", + "NokiaSROS_BGPRoute", + "NokiaSROS_Ping", + "NokiaSROS_Traceroute", +) + +NokiaSROS_BGPRoute = BuiltinDirective( + id="__hyperglass_nokia_sros_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="/show router bgp routes {target} ipv4 hunt", + ), + Rule( + condition="::/0", + action="permit", + command="/show router bgp routes {target} ipv6 hunt", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["nokia_sros"], +) + +NokiaSROS_BGPASPath = BuiltinDirective( + id="__hyperglass_nokia_sros_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "/show router bgp routes aspath-regex {target}", + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["nokia_sros"], +) + +NokiaSROS_BGPCommunity = BuiltinDirective( + id="__hyperglass_nokia_sros_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "/show router bgp routes community {target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["nokia_sros"], +) + +NokiaSROS_Ping = BuiltinDirective( + id="__hyperglass_nokia_sros_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="/ping {target} source-address {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="/ping {target} source-address {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["nokia_sros"], +) + +NokiaSROS_Traceroute = BuiltinDirective( + id="__hyperglass_nokia_sros_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="/traceroute {target} source-address {source4} wait 2 seconds", + ), + Rule( + condition="::/0", + action="permit", + command="/traceroute {target} source-address {source6} wait 2 seconds", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["nokia_sros"], +) diff --git a/hyperglass/defaults/directives/tnsr.py b/hyperglass/defaults/directives/tnsr.py new file mode 100644 index 0000000..65e50a5 --- /dev/null +++ b/hyperglass/defaults/directives/tnsr.py @@ -0,0 +1,103 @@ +"""Default TNSR Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "TNSR_BGPASPath", + "TNSR_BGPCommunity", + "TNSR_BGPRoute", + "TNSR_Ping", + "TNSR_Traceroute", +) + +TNSR_BGPRoute = BuiltinDirective( + id="__hyperglass_tnsr_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command='dataplane shell sudo vtysh -c "show bgp ipv4 unicast {target}"', + ), + Rule( + condition="::/0", + action="permit", + command='dataplane shell sudo vtysh -c "show bgp ipv6 unicast {target}"', + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["tnsr"], +) + +TNSR_BGPASPath = BuiltinDirective( + id="__hyperglass_tnsr_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'dataplane shell sudo vtysh -c "show bgp ipv4 unicast regexp {target}"', + 'dataplane shell sudo vtysh -c "show bgp ipv6 unicast regexp {target}"', + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["tnsr"], +) + +TNSR_BGPCommunity = BuiltinDirective( + id="__hyperglass_tnsr_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'dataplane shell sudo vtysh -c "show bgp ipv4 unicast community {target}"', + 'dataplane shell sudo vtysh -c "show bgp ipv6 unicast community {target}"', + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["tnsr"], +) + +TNSR_Ping = BuiltinDirective( + id="__hyperglass_tnsr_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping {target} ipv4 source {source4} count 5 timeout 1", + ), + Rule( + condition="::/0", + action="permit", + command="ping {target} ipv6 source {source6} count 5 timeout 1", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["tnsr"], +) + +TNSR_Traceroute = BuiltinDirective( + id="__hyperglass_tnsr_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="traceroute {target} ipv4 source {source4} timeout 1 waittime 1", + ), + Rule( + condition="::/0", + action="permit", + command="traceroute {target} ipv6 source {source6} timeout 1 waittime 1", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["tnsr"], +) diff --git a/hyperglass/defaults/directives/vyos.py b/hyperglass/defaults/directives/vyos.py new file mode 100644 index 0000000..8eedb9c --- /dev/null +++ b/hyperglass/defaults/directives/vyos.py @@ -0,0 +1,103 @@ +"""Default VyOS Directives.""" + +# Project +from hyperglass.models.directive import Rule, Text, BuiltinDirective + +__all__ = ( + "VyOS_BGPASPath", + "VyOS_BGPCommunity", + "VyOS_BGPRoute", + "VyOS_Ping", + "VyOS_Traceroute", +) + +VyOS_BGPRoute = BuiltinDirective( + id="__hyperglass_vyos_bgp_route__", + name="BGP Route", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="show ip bgp {target}", + ), + Rule( + condition="::/0", + action="permit", + command="show ipv6 bgp {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["vyos"], +) + +VyOS_BGPASPath = BuiltinDirective( + id="__hyperglass_vyos_bgp_aspath__", + name="BGP AS Path", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + 'show ip bgp regexp "{target}"', + 'show ipv6 bgp regexp "{target}"', + ], + ) + ], + field=Text(description="AS Path Regular Expression"), + platforms=["vyos"], +) + +VyOS_BGPCommunity = BuiltinDirective( + id="__hyperglass_vyos_bgp_community__", + name="BGP Community", + rules=[ + Rule( + condition="*", + action="permit", + commands=[ + "show ip bgp community {target}", + "show ipv6 bgp community {target}", + ], + ) + ], + field=Text(description="BGP Community String"), + platforms=["vyos"], +) + +VyOS_Ping = BuiltinDirective( + id="__hyperglass_vyos_ping__", + name="Ping", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="ping {target} count 5 interface {source4}", + ), + Rule( + condition="::/0", + action="permit", + command="ping {target} count 5 interface {source6}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["vyos"], +) + +VyOS_Traceroute = BuiltinDirective( + id="__hyperglass_vyos_traceroute__", + name="Traceroute", + rules=[ + Rule( + condition="0.0.0.0/0", + action="permit", + command="mtr -4 -G 1 -c 1 -w -o SAL -a {source4} {target}", + ), + Rule( + condition="::/0", + action="permit", + command="mtr -6 -G 1 -c 1 -w -o SAL -a {source6} {target}", + ), + ], + field=Text(description="IP Address, Prefix, or Hostname"), + platforms=["vyos"], +) diff --git a/hyperglass/models/commands/__init__.py b/hyperglass/models/commands/__init__.py deleted file mode 100644 index 4e1ef4d..0000000 --- a/hyperglass/models/commands/__init__.py +++ /dev/null @@ -1,62 +0,0 @@ -"""Validate command configuration variables.""" - -# Local -from .frr import FRRCommands -from .bird import BIRDCommands -from .tnsr import TNSRCommands -from .vyos import VyosCommands -from ..main import HyperglassModel -from .common import CommandGroup -from .huawei import HuaweiCommands -from .juniper import JuniperCommands -from .cisco_xr import CiscoXRCommands -from .cisco_ios import CiscoIOSCommands -from .arista_eos import AristaEOSCommands -from .cisco_nxos import CiscoNXOSCommands -from .nokia_sros import NokiaSROSCommands -from .mikrotik_routeros import MikrotikRouterOS -from .mikrotik_switchos import MikrotikSwitchOS - -_DEVICE_TYPE_MAP = { - "arista_eos": AristaEOSCommands, - "bird": BIRDCommands, - "cisco_ios": CiscoIOSCommands, - "cisco_nxos": CiscoNXOSCommands, - "cisco_xr": CiscoXRCommands, - "frr": FRRCommands, - "huawei": HuaweiCommands, - "juniper": JuniperCommands, - "mikrotik_routeros": MikrotikRouterOS, - "mikrotik_switchos": MikrotikSwitchOS, - "nokia_sros": NokiaSROSCommands, - "tnsr": TNSRCommands, - "vyos": VyosCommands, -} - - -class Commands(HyperglassModel, extra="allow", validate_all=False): - """Base class for command definitions.""" - - arista_eos: CommandGroup = AristaEOSCommands() - bird: CommandGroup = BIRDCommands() - cisco_ios: CommandGroup = CiscoIOSCommands() - cisco_nxos: CommandGroup = CiscoNXOSCommands() - cisco_xr: CommandGroup = CiscoXRCommands() - frr: CommandGroup = FRRCommands() - huawei: CommandGroup = HuaweiCommands() - juniper: CommandGroup = JuniperCommands() - mikrotik_routeros: CommandGroup = MikrotikRouterOS() - mikrotik_switchos: CommandGroup = MikrotikSwitchOS() - nokia_sros: CommandGroup = NokiaSROSCommands() - tnsr: CommandGroup = TNSRCommands() - vyos: CommandGroup = VyosCommands() - - @classmethod - def import_params(cls, **input_params): - """Import loaded YAML, initialize per-command definitions.""" - obj = Commands() - for platform, cmds in input_params.items(): - cmd_set = _DEVICE_TYPE_MAP.get(platform, CommandGroup) - cmds = cmd_set(**cmds) - setattr(obj, platform, cmds) - return obj diff --git a/hyperglass/models/commands/_mikrotik_base.py b/hyperglass/models/commands/_mikrotik_base.py deleted file mode 100644 index 39e1877..0000000 --- a/hyperglass/models/commands/_mikrotik_base.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Base Mikrotik Commands Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Default commands for ipv4 commands.""" - - bgp_community: StrictStr = "ip route print where bgp-communities={target}" - bgp_aspath: StrictStr = "ip route print where bgp-as-path={target}" - bgp_route: StrictStr = "ip route print where dst-address={target}" - ping: StrictStr = "ping src-address={source} count=5 {target}" - traceroute: StrictStr = ( - "tool traceroute src-address={source} timeout=1 duration=5 count=1 {target}" - ) - - -class _IPv6(CommandSet): - """Default commands for ipv6 commands.""" - - bgp_community: StrictStr = "ipv6 route print where bgp-communities={target}" - bgp_aspath: StrictStr = "ipv6 route print where bgp-as-path={target}" - bgp_route: StrictStr = "ipv6 route print where dst-address={target}" - ping: StrictStr = "ping src-address={source} count=5 {target}" - traceroute: StrictStr = ( - "tool traceroute src-address={source} timeout=1 duration=5 count=1 {target}" - ) - - -class _VPNIPv4(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = "ip route print where bgp-communities={target} routing-mark={vrf}" - bgp_aspath: StrictStr = "ip route print where bgp-as-path={target} routing-mark={vrf}" - bgp_route: StrictStr = "ip route print where dst-address={target} routing-mark={vrf}" - ping: StrictStr = "ping src-address={source} count=5 routing-table={vrf} {target}" - traceroute: StrictStr = "tool traceroute src-address={source} timeout=1 duration=5 count=1 routing-table={vrf} {target}" - - -class _VPNIPv6(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = "ipv6 route print where bgp-communities={target} routing-mark={vrf}" - bgp_aspath: StrictStr = "ipv6 route print where bgp-as-path={target} routing-mark={vrf}" - bgp_route: StrictStr = "ipv6 route print where dst-address={target} routing-mark={vrf}" - ping: StrictStr = "ping src-address={source} count=5 routing-table={vrf} {target}" - traceroute: StrictStr = "tool traceroute src-address={source} timeout=1 duration=5 count=1 routing-table={vrf} {target}" - - -class MikrotikCommands(CommandGroup): - """Validation model for default mikrotik commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/arista_eos.py b/hyperglass/models/commands/arista_eos.py deleted file mode 100644 index 29dbc3a..0000000 --- a/hyperglass/models/commands/arista_eos.py +++ /dev/null @@ -1,93 +0,0 @@ -"""Arista EOS Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Validation model for non-default dual afi commands.""" - - bgp_route: StrictStr = "show ip bgp {target}" - bgp_aspath: StrictStr = "show ip bgp regexp {target}" - bgp_community: StrictStr = "show ip bgp community {target}" - ping: StrictStr = "ping ip {target} source {source}" - traceroute: StrictStr = "traceroute ip {target} source {source}" - - -class _IPv6(CommandSet): - """Validation model for non-default ipv4 commands.""" - - bgp_route: StrictStr = "show ipv6 bgp {target}" - bgp_aspath: StrictStr = "show ipv6 bgp regexp {target}" - bgp_community: StrictStr = "show ipv6 bgp community {target}" - ping: StrictStr = "ping ipv6 {target} source {source}" - traceroute: StrictStr = "traceroute ipv6 {target} source {source}" - - -class _VPNIPv4(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show ip bgp {target} vrf {vrf}" - bgp_aspath: StrictStr = "show ip bgp regexp {target} vrf {vrf}" - bgp_community: StrictStr = "show ip bgp community {target} vrf {vrf}" - ping: StrictStr = "ping vrf {vrf} ip {target} source {source}" - traceroute: StrictStr = "traceroute vrf {vrf} ip {target} source {source}" - - -class _VPNIPv6(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show ipv6 bgp {target} vrf {vrf}" - bgp_aspath: StrictStr = "show ipv6 bgp regexp {target} vrf {vrf}" - bgp_community: StrictStr = "show ipv6 bgp community {target} vrf {vrf}" - ping: StrictStr = "ping vrf {vrf} ipv6 {target} source {source}" - traceroute: StrictStr = "traceroute vrf {vrf} ipv6 {target} source {source}" - - -_structured = CommandGroup( - ipv4_default=CommandSet( - bgp_route="show ip bgp {target} | json", - bgp_aspath="show ip bgp regexp {target} | json", - bgp_community="show ip bgp community {target} | json", - ping="ping ip {target} source {source}", - traceroute="traceroute ip {target} source {source}", - ), - ipv6_default=CommandSet( - bgp_route="show ipv6 bgp {target} | json", - bgp_aspath="show ipv6 bgp regexp {target} | json", - bgp_community="show ipv6 bgp community {target} | json", - ping="ping ipv6 {target} source {source}", - traceroute="traceroute ipv6 {target} source {source}", - ), - ipv4_vpn=CommandSet( - bgp_route="show ip bgp {target} vrf {vrf} | json", - bgp_aspath="show ip bgp regexp {target} vrf {vrf} | json", - bgp_community="show ip bgp community {target} vrf {vrf} | json", - ping="ping vrf {vrf} ip {target} source {source}", - traceroute="traceroute vrf {vrf} ip {target} source {source}", - ), - ipv6_vpn=CommandSet( - bgp_route="show ipv6 bgp {target} vrf {vrf} | json", - bgp_aspath="show ipv6 bgp regexp {target} vrf {vrf} | json", - bgp_community="show ipv6 bgp community {target} vrf {vrf} | json", - ping="ping vrf {vrf} ipv6 {target} source {source}", - traceroute="traceroute vrf {vrf} ipv6 {target} source {source}", - ), -) - - -class AristaEOSCommands(CommandGroup): - """Validation model for default arista_eos commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() - - def __init__(self, **kwargs): - """Initialize command group, ensure structured fields are not overridden.""" - super().__init__(**kwargs) - self.structured = _structured diff --git a/hyperglass/models/commands/bird.py b/hyperglass/models/commands/bird.py deleted file mode 100644 index 9a86f0a..0000000 --- a/hyperglass/models/commands/bird.py +++ /dev/null @@ -1,56 +0,0 @@ -"""BIRD Routing Daemon Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Default commands for ipv4 commands.""" - - bgp_community: str = 'birdc "show route all where {target} ~ bgp_community"' - bgp_aspath: str = 'birdc "show route all where bgp_path ~ {target}"' - bgp_route: str = 'birdc "show route all where {target} ~ net"' - ping: str = "ping -4 -c 5 -I {source} {target}" - traceroute: str = "traceroute -4 -w 1 -q 1 -s {source} {target}" - - -class _IPv6(CommandSet): - """Default commands for ipv6 commands.""" - - bgp_community: str = 'birdc "show route all where {target} ~ bgp_community"' - bgp_aspath: str = 'birdc "show route all where bgp_path ~ {target}"' - bgp_route: str = 'birdc "show route all where {target} ~ net"' - ping: StrictStr = "ping -6 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -6 -w 1 -q 1 -s {source} {target}" - - -class _VPNIPv4(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: str = 'birdc "show route all table {vrf} where {target} ~ bgp_community"' - bgp_aspath: str = 'birdc "show route all table {vrf} where bgp_path ~ {target}"' - bgp_route: str = 'birdc "show route all table {vrf} where {target} ~ net"' - ping: StrictStr = "ping -4 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -4 -w 1 -q 1 -s {source} {target}" - - -class _VPNIPv6(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: str = 'birdc "show route all table {vrf} where {target} ~ bgp_community"' - bgp_aspath: str = 'birdc "show route all table {vrf} where bgp_path ~ {target}"' - bgp_route: str = 'birdc "show route all table {vrf} where {target} ~ net"' - ping: StrictStr = "ping -6 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -6 -w 1 -q 1 -s {source} {target}" - - -class BIRDCommands(CommandGroup): - """Validation model for default BIRD commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/cisco_ios.py b/hyperglass/models/commands/cisco_ios.py deleted file mode 100644 index 7cc9da1..0000000 --- a/hyperglass/models/commands/cisco_ios.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Cisco IOS Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Default commands for ipv4 commands.""" - - bgp_community: StrictStr = "show bgp ipv4 unicast community {target}" - bgp_aspath: StrictStr = 'show bgp ipv4 unicast quote-regexp "{target}"' - bgp_route: StrictStr = "show bgp ipv4 unicast {target} | exclude pathid:|Epoch" - ping: StrictStr = "ping {target} repeat 5 source {source}" - traceroute: StrictStr = "traceroute {target} timeout 1 probe 2 source {source}" - - -class _IPv6(CommandSet): - """Default commands for ipv6 commands.""" - - bgp_community: StrictStr = "show bgp ipv6 unicast community {target}" - bgp_aspath: StrictStr = 'show bgp ipv6 unicast quote-regexp "{target}"' - bgp_route: StrictStr = "show bgp ipv6 unicast {target} | exclude pathid:|Epoch" - ping: StrictStr = "ping ipv6 {target} repeat 5 source {source}" - traceroute: StrictStr = "traceroute ipv6 {target} timeout 1 probe 2 source {source}" - - -class _VPNIPv4(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = "show bgp vpnv4 unicast vrf {vrf} community {target}" - bgp_aspath: StrictStr = 'show bgp vpnv4 unicast vrf {vrf} quote-regexp "{target}"' - bgp_route: StrictStr = "show bgp vpnv4 unicast vrf {vrf} {target}" - ping: StrictStr = "ping vrf {vrf} {target} repeat 5 source {source}" - traceroute: StrictStr = "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}" - - -class _VPNIPv6(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = "show bgp vpnv6 unicast vrf {vrf} community {target}" - bgp_aspath: StrictStr = 'show bgp vpnv6 unicast vrf {vrf} quote-regexp "{target}"' - bgp_route: StrictStr = "show bgp vpnv6 unicast vrf {vrf} {target}" - ping: StrictStr = "ping vrf {vrf} {target} repeat 5 source {source}" - traceroute: StrictStr = "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}" - - -class CiscoIOSCommands(CommandGroup): - """Validation model for default cisco_ios commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/cisco_nxos.py b/hyperglass/models/commands/cisco_nxos.py deleted file mode 100644 index 58e61fc..0000000 --- a/hyperglass/models/commands/cisco_nxos.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Cisco NX-OS Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Validation model for non-default dual afi commands.""" - - bgp_route: StrictStr = "show bgp ipv4 unicast {target}" - bgp_aspath: StrictStr = 'show bgp ipv4 unicast regexp "{target}"' - bgp_community: StrictStr = "show bgp ipv4 unicast community {target}" - ping: StrictStr = "ping {target} source {source}" - traceroute: StrictStr = "traceroute {target} source {source}" - - -class _IPv6(CommandSet): - """Validation model for non-default ipv4 commands.""" - - bgp_route: StrictStr = "show bgp ipv6 unicast {target}" - bgp_aspath: StrictStr = 'show bgp ipv6 unicast regexp "{target}"' - bgp_community: StrictStr = "show bgp ipv6 unicast community {target}" - ping: StrictStr = "ping6 {target} source {source}" - traceroute: StrictStr = "traceroute6 {target} source {source}" - - -class _VPNIPv4(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show bgp ipv4 unicast {target} vrf {vrf}" - bgp_aspath: StrictStr = 'show bgp ipv4 unicast regexp "{target}" vrf {vrf}' - bgp_community: StrictStr = "show bgp ipv4 unicast community {target} vrf {vrf}" - ping: StrictStr = "ping {target} source {source} vrf {vrf}" - traceroute: StrictStr = "traceroute {target} source {source} vrf {vrf}" - - -class _VPNIPv6(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show bgp ipv6 unicast {target} vrf {vrf}" - bgp_aspath: StrictStr = 'show bgp ipv6 unicast regexp "{target}" vrf {vrf}' - bgp_community: StrictStr = "show bgp ipv6 unicast community {target} vrf {vrf}" - ping: StrictStr = "ping6 {target} source {source} vrf {vrf}" - traceroute: StrictStr = "traceroute6 {target} source {source} vrf {vrf}" - - -class CiscoNXOSCommands(CommandGroup): - """Validation model for default cisco_nxos commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/cisco_xr.py b/hyperglass/models/commands/cisco_xr.py deleted file mode 100644 index 01ed2a5..0000000 --- a/hyperglass/models/commands/cisco_xr.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Cisco IOS XR Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Validation model for non-default dual afi commands.""" - - bgp_route: StrictStr = "show bgp ipv4 unicast {target}" - bgp_aspath: StrictStr = "show bgp ipv4 unicast regexp {target}" - bgp_community: StrictStr = "show bgp ipv4 unicast community {target}" - ping: StrictStr = "ping ipv4 {target} count 5 source {source}" - traceroute: StrictStr = "traceroute ipv4 {target} timeout 1 probe 2 source {source}" - - -class _IPv6(CommandSet): - """Validation model for non-default ipv4 commands.""" - - bgp_route: StrictStr = "show bgp ipv6 unicast {target}" - bgp_aspath: StrictStr = "show bgp ipv6 unicast regexp {target}" - bgp_community: StrictStr = "show bgp ipv6 unicast community {target}" - ping: StrictStr = "ping ipv6 {target} count 5 source {source}" - traceroute: StrictStr = "traceroute ipv6 {target} timeout 1 probe 2 source {source}" - - -class _VPNIPv4(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show bgp vpnv4 unicast vrf {vrf} {target}" - bgp_aspath: StrictStr = "show bgp vpnv4 unicast vrf {vrf} regexp {target}" - bgp_community: StrictStr = "show bgp vpnv4 unicast vrf {vrf} community {target}" - ping: StrictStr = "ping vrf {vrf} {target} count 5 source {source}" - traceroute: StrictStr = "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}" - - -class _VPNIPv6(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show bgp vpnv6 unicast vrf {vrf} {target}" - bgp_aspath: StrictStr = "show bgp vpnv6 unicast vrf {vrf} regexp {target}" - bgp_community: StrictStr = "show bgp vpnv6 unicast vrf {vrf} community {target}" - ping: StrictStr = "ping vrf {vrf} {target} count 5 source {source}" - traceroute: StrictStr = "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}" - - -class CiscoXRCommands(CommandGroup): - """Validation model for default cisco_xr commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/common.py b/hyperglass/models/commands/common.py deleted file mode 100644 index 8795d78..0000000 --- a/hyperglass/models/commands/common.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Models common to entire commands module.""" - -# Third Party -from pydantic import StrictStr - -# Local -from ..main import HyperglassModel - - -class CommandSet(HyperglassModel): - """Command set, defined per-AFI.""" - - bgp_route: StrictStr - bgp_aspath: StrictStr - bgp_community: StrictStr - ping: StrictStr - traceroute: StrictStr - - -class CommandGroup(HyperglassModel, extra="allow"): - """Validation model for all commands.""" - - ipv4_default: CommandSet - ipv6_default: CommandSet - ipv4_vpn: CommandSet - ipv6_vpn: CommandSet diff --git a/hyperglass/models/commands/frr.py b/hyperglass/models/commands/frr.py deleted file mode 100644 index 2dde708..0000000 --- a/hyperglass/models/commands/frr.py +++ /dev/null @@ -1,56 +0,0 @@ -"""FRRouting Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Default commands for ipv4 commands.""" - - bgp_community: StrictStr = 'vtysh -c "show bgp ipv4 unicast community {target}"' - bgp_aspath: StrictStr = 'vtysh -c "show bgp ipv4 unicast regexp {target}"' - bgp_route: StrictStr = 'vtysh -c "show bgp ipv4 unicast {target}"' - ping: StrictStr = "ping -4 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -4 -w 1 -q 1 -s {source} {target}" - - -class _IPv6(CommandSet): - """Default commands for ipv6 commands.""" - - bgp_community: StrictStr = 'vtysh -c "show bgp ipv6 unicast community {target}"' - bgp_aspath: StrictStr = 'vtysh -c "show bgp ipv6 unicast regexp {target}"' - bgp_route: StrictStr = 'vtysh -c "show bgp ipv6 unicast {target}"' - ping: StrictStr = "ping -6 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -6 -w 1 -q 1 -s {source} {target}" - - -class _VPNIPv4(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = 'vtysh -c "show bgp vrf {vrf} ipv4 unicast community {target}"' - bgp_aspath: StrictStr = 'vtysh -c "show bgp vrf {vrf} ipv4 unicast regexp {target}"' - bgp_route: StrictStr = 'vtysh -c "show bgp vrf {vrf} ipv4 unicast {target}"' - ping: StrictStr = "ping -4 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -4 -w 1 -q 1 -s {source} {target}" - - -class _VPNIPv6(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = 'vtysh -c "show bgp vrf {vrf} ipv6 unicast community {target}"' - bgp_aspath: StrictStr = 'vtysh -c "show bgp vrf {vrf} ipv6 unicast regexp {target}"' - bgp_route: StrictStr = 'vtysh -c "show bgp vrf {vrf} ipv6 unicast {target}"' - ping: StrictStr = "ping -6 -c 5 -I {source} {target}" - traceroute: StrictStr = "traceroute -6 -w 1 -q 1 -s {source} {target}" - - -class FRRCommands(CommandGroup): - """Validation model for default FRRouting commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/huawei.py b/hyperglass/models/commands/huawei.py deleted file mode 100644 index 480cc2f..0000000 --- a/hyperglass/models/commands/huawei.py +++ /dev/null @@ -1,64 +0,0 @@ -"""Huawei Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Default commands for ipv4 commands.""" - - bgp_community: StrictStr = "display bgp routing-table regular-expression {target}" - bgp_aspath: StrictStr = "display bgp routing-table regular-expression {target}" - bgp_route: StrictStr = "display bgp routing-table {target}" - ping: StrictStr = "ping -c 5 -a {source} {target}" - traceroute: StrictStr = "tracert -q 2 -f 1 -a {source} {target}" - - -class _IPv6(CommandSet): - """Default commands for ipv6 commands.""" - - bgp_community: StrictStr = "display bgp ipv6 routing-table community {target}" - bgp_aspath: StrictStr = "display bgp ipv6 routing-table regular-expression {target}" - bgp_route: StrictStr = "display bgp ipv6 routing-table {target}" - ping: StrictStr = "ping ipv6 -c 5 -a {source} {target}" - traceroute: StrictStr = "tracert ipv6 -q 2 -f 1 -a {source} {target}" - - -class _VPNIPv4(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = ( - "display bgp vpnv4 vpn-instance {vrf} routing-table regular-expression {target}" - ) - bgp_aspath: StrictStr = ( - "display bgp vpnv4 vpn-instance {vrf} routing-table regular-expression {target}" - ) - bgp_route: StrictStr = "display bgp vpnv4 vpn-instance {vrf} routing-table {target}" - ping: StrictStr = "ping -vpn-instance {vrf} -c 5 -a {source} {target}" - traceroute: StrictStr = "tracert -q 2 -f 1 -vpn-instance {vrf} -a {source} {target}" - - -class _VPNIPv6(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = ( - "display bgp vpnv6 vpn-instance {vrf} routing-table regular-expression {target}" - ) - bgp_aspath: StrictStr = ( - "display bgp vpnv6 vpn-instance {vrf} routing-table regular-expression {target}" - ) - bgp_route: StrictStr = "display bgp vpnv6 vpn-instance {vrf} routing-table {target}" - ping: StrictStr = "ping vpnv6 vpn-instance {vrf} -c 5 -a {source} {target}" - traceroute: StrictStr = "tracert -q 2 -f 1 vpn-instance {vrf} -a {source} {target}" - - -class HuaweiCommands(CommandGroup): - """Validation model for default huawei commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/juniper.py b/hyperglass/models/commands/juniper.py deleted file mode 100644 index c4e8c51..0000000 --- a/hyperglass/models/commands/juniper.py +++ /dev/null @@ -1,95 +0,0 @@ -"""Juniper Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Validation model for non-default dual afi commands.""" - - bgp_route: StrictStr = 'show route protocol bgp table inet.0 {target} best detail | except Label | except Label | except "Next hop type" | except Task | except Address | except "Session Id" | except State | except "Next-hop reference" | except destinations | except "Announcement bits"' - bgp_aspath: StrictStr = 'show route protocol bgp table inet.0 aspath-regex "{target}"' - bgp_community: StrictStr = "show route protocol bgp table inet.0 community {target}" - ping: StrictStr = "ping inet {target} count 5 source {source}" - traceroute: StrictStr = "traceroute inet {target} wait 1 source {source}" - - -class _IPv6(CommandSet): - """Validation model for non-default ipv4 commands.""" - - bgp_route: StrictStr = 'show route protocol bgp table inet6.0 {target} best detail | except Label | except Label | except "Next hop type" | except Task | except Address | except "Session Id" | except State | except "Next-hop reference" | except destinations | except "Announcement bits"' - bgp_aspath: StrictStr = 'show route protocol bgp table inet6.0 aspath-regex "{target}"' - bgp_community: StrictStr = "show route protocol bgp table inet6.0 community {target}" - ping: StrictStr = "ping inet6 {target} count 5 source {source}" - traceroute: StrictStr = "traceroute inet6 {target} wait 2 source {source}" - - -class _VPNIPv4(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = 'show route protocol bgp table {vrf}.inet.0 {target} best detail | except Label | except Label | except "Next hop type" | except Task | except Address | except "Session Id" | except State | except "Next-hop reference" | except destinations | except "Announcement bits"' - bgp_aspath: StrictStr = 'show route protocol bgp table {vrf}.inet.0 aspath-regex "{target}"' - bgp_community: StrictStr = "show route protocol bgp table {vrf}.inet.0 community {target}" - ping: StrictStr = "ping inet routing-instance {vrf} {target} count 5 source {source}" - traceroute: StrictStr = "traceroute inet routing-instance {vrf} {target} wait 1 source {source}" - - -class _VPNIPv6(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = 'show route protocol bgp table {vrf}.inet6.0 {target} best detail | except Label | except Label | except "Next hop type" | except Task | except Address | except "Session Id" | except State | except "Next-hop reference" | except destinations | except "Announcement bits"' - bgp_aspath: StrictStr = 'show route protocol bgp table {vrf}.inet6.0 aspath-regex "{target}"' - bgp_community: StrictStr = "show route protocol bgp table {vrf}.inet6.0 community {target}" - ping: StrictStr = "ping inet6 routing-instance {vrf} {target} count 5 source {source}" - traceroute: StrictStr = ( - "traceroute inet6 routing-instance {vrf} {target} wait 2 source {source}" - ) - - -_structured = CommandGroup( - ipv4_default=CommandSet( - bgp_route="show route protocol bgp table inet.0 {target} best detail | display xml", - bgp_aspath='show route protocol bgp table inet.0 aspath-regex "{target}" detail | display xml', - bgp_community="show route protocol bgp table inet.0 community {target} detail | display xml", - ping="ping inet {target} count 5 source {source}", - traceroute="traceroute inet {target} wait 1 source {source}", - ), - ipv6_default=CommandSet( - bgp_route="show route protocol bgp table inet6.0 {target} best detail | display xml", - bgp_aspath='show route protocol bgp table inet6.0 aspath-regex "{target}" detail | display xml', - bgp_community="show route protocol bgp table inet6.0 community {target} detail | display xml", - ping="ping inet6 {target} count 5 source {source}", - traceroute="traceroute inet6 {target} wait 2 source {source}", - ), - ipv4_vpn=CommandSet( - bgp_route="show route protocol bgp table {vrf}.inet.0 {target} best detail | display xml", - bgp_aspath='show route protocol bgp table {vrf}.inet.0 aspath-regex "{target}" detail | display xml', - bgp_community="show route protocol bgp table {vrf}.inet.0 community {target} detail | display xml", - ping="ping inet routing-instance {vrf} {target} count 5 source {source}", - traceroute="traceroute inet routing-instance {vrf} {target} wait 1 source {source}", - ), - ipv6_vpn=CommandSet( - bgp_route="show route protocol bgp table {vrf}.inet6.0 {target} best detail | display xml", - bgp_aspath='show route protocol bgp table {vrf}.inet6.0 aspath-regex "{target}" detail | display xml', - bgp_community="show route protocol bgp table {vrf}.inet6.0 community {target} detail | display xml", - ping="ping inet6 routing-instance {vrf} {target} count 5 source {source}", - traceroute="traceroute inet6 routing-instance {vrf} {target} wait 2 source {source}", - ), -) - - -class JuniperCommands(CommandGroup): - """Validation model for default juniper commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() - - def __init__(self, **kwargs): - """Initialize command group, ensure structured fields are not overridden.""" - super().__init__(**kwargs) - self.structured = _structured diff --git a/hyperglass/models/commands/mikrotik_routeros.py b/hyperglass/models/commands/mikrotik_routeros.py deleted file mode 100644 index ab986f6..0000000 --- a/hyperglass/models/commands/mikrotik_routeros.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Mikrotik RouterOS Commands Model.""" -# Local -from ._mikrotik_base import MikrotikCommands - - -class MikrotikRouterOS(MikrotikCommands): - """Alias for mikrotik_routeros.""" - - pass diff --git a/hyperglass/models/commands/mikrotik_switchos.py b/hyperglass/models/commands/mikrotik_switchos.py deleted file mode 100644 index 4e18c31..0000000 --- a/hyperglass/models/commands/mikrotik_switchos.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Mikrotik SwitchOS Commands Model.""" -# Local -from ._mikrotik_base import MikrotikCommands - - -class MikrotikSwitchOS(MikrotikCommands): - """Alias for mikrotik_switchos.""" - - pass diff --git a/hyperglass/models/commands/nokia_sros.py b/hyperglass/models/commands/nokia_sros.py deleted file mode 100644 index bc8d5b6..0000000 --- a/hyperglass/models/commands/nokia_sros.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Nokia SR-OS Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Default commands for ipv4 commands.""" - - bgp_community: StrictStr = "/show router bgp routes community {target}" - bgp_aspath: StrictStr = "/show router bgp routes aspath-regex {target}" - bgp_route: StrictStr = "/show router bgp routes {target} ipv4 hunt" - ping: StrictStr = "/ping {target} source-address {source}" - traceroute: StrictStr = "/traceroute {target} source-address {source} wait 2 seconds" - - -class _IPv6(CommandSet): - """Default commands for ipv6 commands.""" - - bgp_community: StrictStr = "/show router bgp routes community {target}" - bgp_aspath: StrictStr = "/show router bgp routes aspath-regex {target}" - bgp_route: StrictStr = "/show router bgp routes {target} ipv6 hunt" - ping: StrictStr = "/ping {target} source-address {source}" - traceroute: StrictStr = "/traceroute {target} source-address {source} wait 2 seconds" - - -class _VPNIPv4(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = "/show router bgp routes community {target}" - bgp_aspath: StrictStr = "/show router bgp routes aspath-regex {target}" - bgp_route: StrictStr = "/show router bgp routes {target} vpn-ipv4 hunt" - ping: StrictStr = "/ping {target} source-address {source}" - traceroute: StrictStr = "/traceroute {target} source-address {source} wait 2 seconds" - - -class _VPNIPv6(CommandSet): - """Default commands for dual afi commands.""" - - bgp_community: StrictStr = "/show router bgp routes community {target}" - bgp_aspath: StrictStr = "/show router bgp routes aspath-regex {target}" - bgp_route: StrictStr = "/show router bgp routes {target} vpn-ipv6 hunt" - ping: StrictStr = "/ping {target} source-address {source}" - traceroute: StrictStr = "/traceroute {target} source-address {source} wait 2 seconds" - - -class NokiaSROSCommands(CommandGroup): - """Validation model for default nokia_sros commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/tnsr.py b/hyperglass/models/commands/tnsr.py deleted file mode 100644 index c605b0a..0000000 --- a/hyperglass/models/commands/tnsr.py +++ /dev/null @@ -1,72 +0,0 @@ -"""Netgate TNSR Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Validation model for default VRF IPv4 commands.""" - - bgp_community: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp ipv4 unicast community {target}"' - ) - bgp_aspath: StrictStr = 'dataplane shell sudo vtysh -c "show bgp ipv4 unicast regexp {target}"' - bgp_route: StrictStr = 'dataplane shell sudo vtysh -c "show bgp ipv4 unicast {target}"' - ping: StrictStr = "ping {target} ipv4 source {source} count 5 timeout 1" - traceroute: StrictStr = "traceroute {target} ipv4 source {source} timeout 1 waittime 1" - - -class _IPv6(CommandSet): - """Validation model for default VRF IPv6 commands.""" - - bgp_community: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp ipv6 unicast community {target}"' - ) - bgp_aspath: StrictStr = 'dataplane shell sudo vtysh -c "show bgp ipv6 unicast regexp {target}"' - bgp_route: StrictStr = 'dataplane shell sudo vtysh -c "show bgp ipv6 unicast {target}"' - ping: StrictStr = "ping {target} ipv6 source {source} count 5 timeout 1" - traceroute: StrictStr = "traceroute {target} ipv6 source {source} timeout 1 waittime 1" - - -class _VPNIPv4(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_community: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp vrf {vrf} ipv4 unicast community {target}"' - ) - bgp_aspath: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp vrf {vrf} ipv4 unicast regexp {target}"' - ) - bgp_route: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp vrf {vrf} ipv4 unicast {target}"' - ) - ping: StrictStr = "dataplane shell ping -4 -c 5 -W 1 -I {vrf} -S {source} {target}" - traceroute: StrictStr = "dataplane shell traceroute -4 -w 1 -q 1 -i {vrf} -s {source} {target}" - - -class _VPNIPv6(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_community: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp vrf {vrf} ipv6 unicast community {target}"' - ) - bgp_aspath: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp vrf {vrf} ipv6 unicast regexp {target}"' - ) - bgp_route: StrictStr = ( - 'dataplane shell sudo vtysh -c "show bgp vrf {vrf} ipv6 unicast {target}"' - ) - ping: StrictStr = "dataplane shell ping -6 -c 5 -W 1 -I {vrf} -S {source} {target}" - traceroute: StrictStr = "dataplane shell traceroute -6 -w 1 -q 1 -i {vrf} -s {source} {target}" - - -class TNSRCommands(CommandGroup): - """Validation model for default tnsr commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6() diff --git a/hyperglass/models/commands/vyos.py b/hyperglass/models/commands/vyos.py deleted file mode 100644 index fff5dd9..0000000 --- a/hyperglass/models/commands/vyos.py +++ /dev/null @@ -1,56 +0,0 @@ -"""VyOS Command Model.""" - -# Third Party -from pydantic import StrictStr - -# Local -from .common import CommandSet, CommandGroup - - -class _IPv4(CommandSet): - """Validation model for non-default dual afi commands.""" - - bgp_route: StrictStr = "show ip bgp {target}" - bgp_aspath: StrictStr = 'show ip bgp regexp "{target}"' - bgp_community: StrictStr = "show ip bgp community {target}" - ping: StrictStr = "ping {target} count 5 interface {source}" - traceroute: StrictStr = "mtr -4 -G 1 -c 1 -w -o SAL -a {source} {target}" - - -class _IPv6(CommandSet): - """Validation model for non-default ipv4 commands.""" - - bgp_route: StrictStr = "show ipv6 bgp {target}" - bgp_aspath: StrictStr = 'show ipv6 bgp regexp "{target}"' - bgp_community: StrictStr = "show ipv6 bgp community {target}" - ping: StrictStr = "ping {target} count 5 interface {source}" - traceroute: StrictStr = "mtr -6 -G 1 -c 1 -w -o SAL -a {source} {target}" - - -class _VPNIPv4(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show ip bgp {target}" - bgp_aspath: StrictStr = 'show ip bgp regexp "{target}"' - bgp_community: StrictStr = "show ip bgp community {target}" - ping: StrictStr = "ping {target} count 5 vrf {vrf} interface {source}" - traceroute: StrictStr = "ip vrf exec {vrf} mtr -4 -G 1 -c 1 -w -o SAL -a {source} {target}" - - -class _VPNIPv6(CommandSet): - """Validation model for non-default ipv6 commands.""" - - bgp_route: StrictStr = "show ipv6 bgp {target}" - bgp_aspath: StrictStr = 'show ipv6 bgp regexp "{target}"' - bgp_community: StrictStr = "show ipv6 bgp community {target}" - ping: StrictStr = "ping {target} count 5 interface {source}" - traceroute: StrictStr = "ip vrf exec {vrf} mtr -6 -G 1 -c 1 -w -o SAL -a {source} {target}" - - -class VyosCommands(CommandGroup): - """Validation model for default juniper commands.""" - - ipv4_default: _IPv4 = _IPv4() - ipv6_default: _IPv6 = _IPv6() - ipv4_vpn: _VPNIPv4 = _VPNIPv4() - ipv6_vpn: _VPNIPv6 = _VPNIPv6()