mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
add structured output support
This commit is contained in:
@@ -1,42 +1,56 @@
|
||||
"""Arista Command Model."""
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.configuration.models.commands.common import CommandSet, CommandGroup
|
||||
|
||||
_ipv4_default = {
|
||||
"bgp_route": "show ip bgp {target}",
|
||||
"bgp_aspath": "show ip bgp regexp {target}",
|
||||
"bgp_community": "show ip bgp community {target}",
|
||||
"ping": "ping ip {target} source {source}",
|
||||
"traceroute": "traceroute ip {target} source {source}",
|
||||
}
|
||||
_ipv6_default = {
|
||||
"bgp_route": "show ipv6 bgp {target}",
|
||||
"bgp_aspath": "show ipv6 bgp regexp {target}",
|
||||
"bgp_community": "show ipv6 bgp community {target}",
|
||||
"ping": "ping ipv6 {target} source {source}",
|
||||
"traceroute": "traceroute ipv6 {target} source {source}",
|
||||
}
|
||||
_ipv4_vpn = {
|
||||
"bgp_route": "show ip bgp {target} vrf {vrf}",
|
||||
"bgp_aspath": "show ip bgp regexp {target} vrf {vrf}",
|
||||
"bgp_community": "show ip bgp community {target} vrf {vrf}",
|
||||
"ping": "ping vrf {vrf} ip {target} source {source}",
|
||||
"traceroute": "traceroute vrf {vrf} ip {target} source {source}",
|
||||
}
|
||||
_ipv6_vpn = {
|
||||
"bgp_route": "show ipv6 bgp {target} vrf {vrf}",
|
||||
"bgp_aspath": "show ipv6 bgp regexp {target} vrf {vrf}",
|
||||
"bgp_community": "show ipv6 bgp community {target} vrf {vrf}",
|
||||
"ping": "ping vrf {vrf} ipv6 {target} source {source}",
|
||||
"traceroute": "traceroute vrf {vrf} ipv6 {target} source {source}",
|
||||
}
|
||||
|
||||
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}"
|
||||
|
||||
|
||||
class AristaCommands(CommandGroup):
|
||||
"""Validation model for default arista commands."""
|
||||
|
||||
ipv4_default: CommandSet = CommandSet(**_ipv4_default)
|
||||
ipv6_default: CommandSet = CommandSet(**_ipv6_default)
|
||||
ipv4_vpn: CommandSet = CommandSet(**_ipv4_vpn)
|
||||
ipv6_vpn: CommandSet = CommandSet(**_ipv6_vpn)
|
||||
ipv4_default: _IPv4 = _IPv4()
|
||||
ipv6_default: _IPv6 = _IPv6()
|
||||
ipv4_vpn: _VPNIPv4 = _VPNIPv4()
|
||||
ipv6_vpn: _VPNIPv6 = _VPNIPv6()
|
||||
|
||||
@@ -1,42 +1,62 @@
|
||||
"""Cisco IOS Command Model."""
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.configuration.models.commands.common import CommandSet, CommandGroup
|
||||
|
||||
_ipv4_default = {
|
||||
"bgp_route": "show bgp ipv4 unicast {target} | exclude pathid:|Epoch",
|
||||
"bgp_aspath": 'show bgp ipv4 unicast quote-regexp "{target}"',
|
||||
"bgp_community": "show bgp ipv4 unicast community {target}",
|
||||
"ping": "ping {target} repeat 5 source {source}",
|
||||
"traceroute": "traceroute {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
_ipv6_default = {
|
||||
"bgp_route": "show bgp ipv6 unicast {target} | exclude pathid:|Epoch",
|
||||
"bgp_aspath": 'show bgp ipv6 unicast quote-regexp "{target}"',
|
||||
"bgp_community": "show bgp ipv6 unicast community {target}",
|
||||
"ping": "ping ipv6 {target} repeat 5 source {source}",
|
||||
"traceroute": "traceroute ipv6 {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
_ipv4_vpn = {
|
||||
"bgp_route": "show bgp vpnv4 unicast vrf {vrf} {target}",
|
||||
"bgp_aspath": 'show bgp vpnv4 unicast vrf {vrf} quote-regexp "{target}"',
|
||||
"bgp_community": "show bgp vpnv4 unicast vrf {vrf} community {target}",
|
||||
"ping": "ping vrf {vrf} {target} repeat 5 source {source}",
|
||||
"traceroute": "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
_ipv6_vpn = {
|
||||
"bgp_route": "show bgp vpnv6 unicast vrf {vrf} {target}",
|
||||
"bgp_aspath": 'show bgp vpnv6 unicast vrf {vrf} quote-regexp "{target}"',
|
||||
"bgp_community": "show bgp vpnv6 unicast vrf {vrf} community {target}",
|
||||
"ping": "ping vrf {vrf} {target} repeat 5 source {source}",
|
||||
"traceroute": "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
|
||||
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: CommandSet = CommandSet(**_ipv4_default)
|
||||
ipv6_default: CommandSet = CommandSet(**_ipv6_default)
|
||||
ipv4_vpn: CommandSet = CommandSet(**_ipv4_vpn)
|
||||
ipv6_vpn: CommandSet = CommandSet(**_ipv6_vpn)
|
||||
ipv4_default: _IPv4 = _IPv4()
|
||||
ipv6_default: _IPv6 = _IPv6()
|
||||
ipv4_vpn: _VPNIPv4 = _VPNIPv4()
|
||||
ipv6_vpn: _VPNIPv6 = _VPNIPv6()
|
||||
|
||||
@@ -1,42 +1,56 @@
|
||||
"""Cisco NX-OS Command Model."""
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.configuration.models.commands.common import CommandSet, CommandGroup
|
||||
|
||||
_ipv4_default = {
|
||||
"bgp_route": "show bgp ipv4 unicast {target}",
|
||||
"bgp_aspath": 'show bgp ipv4 unicast regexp "{target}"',
|
||||
"bgp_community": "show bgp ipv4 unicast community {target}",
|
||||
"ping": "ping {target} source {source}",
|
||||
"traceroute": "traceroute {target} source {source}",
|
||||
}
|
||||
_ipv6_default = {
|
||||
"bgp_route": "show bgp ipv6 unicast {target}",
|
||||
"bgp_aspath": 'show bgp ipv6 unicast regexp "{target}"',
|
||||
"bgp_community": "show bgp ipv6 unicast community {target}",
|
||||
"ping": "ping6 {target} source {source}",
|
||||
"traceroute": "traceroute6 {target} source {source}",
|
||||
}
|
||||
_ipv4_vpn = {
|
||||
"bgp_route": "show bgp ipv4 unicast {target} vrf {vrf}",
|
||||
"bgp_aspath": 'show bgp ipv4 unicast regexp "{target}" vrf {vrf}',
|
||||
"bgp_community": "show bgp ipv4 unicast community {target} vrf {vrf}",
|
||||
"ping": "ping {target} source {source} vrf {vrf}",
|
||||
"traceroute": "traceroute {target} source {source} vrf {vrf}",
|
||||
}
|
||||
_ipv6_vpn = {
|
||||
"bgp_route": "show bgp ipv6 unicast {target} vrf {vrf}",
|
||||
"bgp_aspath": 'show bgp ipv6 unicast regexp "{target}" vrf {vrf}',
|
||||
"bgp_community": "show bgp ipv6 unicast community {target} vrf {vrf}",
|
||||
"ping": "ping6 {target} source {source} vrf {vrf}",
|
||||
"traceroute": "traceroute6 {target} source {source} vrf {vrf}",
|
||||
}
|
||||
|
||||
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: CommandSet = CommandSet(**_ipv4_default)
|
||||
ipv6_default: CommandSet = CommandSet(**_ipv6_default)
|
||||
ipv4_vpn: CommandSet = CommandSet(**_ipv4_vpn)
|
||||
ipv6_vpn: CommandSet = CommandSet(**_ipv6_vpn)
|
||||
ipv4_default: _IPv4 = _IPv4()
|
||||
ipv6_default: _IPv6 = _IPv6()
|
||||
ipv4_vpn: _VPNIPv4 = _VPNIPv4()
|
||||
ipv6_vpn: _VPNIPv6 = _VPNIPv6()
|
||||
|
||||
@@ -1,42 +1,56 @@
|
||||
"""Cisco IOS XR Command Model."""
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.configuration.models.commands.common import CommandSet, CommandGroup
|
||||
|
||||
_ipv4_default = {
|
||||
"bgp_route": "show bgp ipv4 unicast {target}",
|
||||
"bgp_aspath": "show bgp ipv4 unicast regexp {target}",
|
||||
"bgp_community": "show bgp ipv4 unicast community {target}",
|
||||
"ping": "ping ipv4 {target} count 5 source {source}",
|
||||
"traceroute": "traceroute ipv4 {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
_ipv6_default = {
|
||||
"bgp_route": "show bgp ipv6 unicast {target}",
|
||||
"bgp_aspath": "show bgp ipv6 unicast regexp {target}",
|
||||
"bgp_community": "show bgp ipv6 unicast community {target}",
|
||||
"ping": "ping ipv6 {target} count 5 source {source}",
|
||||
"traceroute": "traceroute ipv6 {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
_ipv4_vpn = {
|
||||
"bgp_route": "show bgp vpnv4 unicast vrf {vrf} {target}",
|
||||
"bgp_aspath": "show bgp vpnv4 unicast vrf {vrf} regexp {target}",
|
||||
"bgp_community": "show bgp vpnv4 unicast vrf {vrf} community {target}",
|
||||
"ping": "ping vrf {vrf} {target} count 5 source {source}",
|
||||
"traceroute": "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
_ipv6_vpn = {
|
||||
"bgp_route": "show bgp vpnv6 unicast vrf {vrf} {target}",
|
||||
"bgp_aspath": "show bgp vpnv6 unicast vrf {vrf} regexp {target}",
|
||||
"bgp_community": "show bgp vpnv6 unicast vrf {vrf} community {target}",
|
||||
"ping": "ping vrf {vrf} {target} count 5 source {source}",
|
||||
"traceroute": "traceroute vrf {vrf} {target} timeout 1 probe 2 source {source}",
|
||||
}
|
||||
|
||||
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: CommandSet = CommandSet(**_ipv4_default)
|
||||
ipv6_default: CommandSet = CommandSet(**_ipv6_default)
|
||||
ipv4_vpn: CommandSet = CommandSet(**_ipv4_vpn)
|
||||
ipv6_vpn: CommandSet = CommandSet(**_ipv6_vpn)
|
||||
ipv4_default: _IPv4 = _IPv4()
|
||||
ipv6_default: _IPv6 = _IPv6()
|
||||
ipv4_vpn: _VPNIPv4 = _VPNIPv4()
|
||||
ipv6_vpn: _VPNIPv6 = _VPNIPv6()
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
"""Models common to entire commands module."""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.models import HyperglassModel
|
||||
from hyperglass.models import HyperglassModel, HyperglassModelExtra
|
||||
|
||||
|
||||
class CommandSet(HyperglassModel):
|
||||
@@ -19,14 +17,10 @@ class CommandSet(HyperglassModel):
|
||||
traceroute: StrictStr
|
||||
|
||||
|
||||
class CommandGroup(HyperglassModel):
|
||||
class CommandGroup(HyperglassModelExtra):
|
||||
"""Validation model for all commands."""
|
||||
|
||||
ipv4_default: CommandSet
|
||||
ipv6_default: CommandSet
|
||||
ipv4_vpn: CommandSet
|
||||
ipv6_vpn: CommandSet
|
||||
structured: Optional["CommandGroup"]
|
||||
|
||||
|
||||
CommandGroup.update_forward_refs()
|
||||
|
||||
@@ -1,42 +1,56 @@
|
||||
"""Huawei Command Model."""
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.configuration.models.commands.common import CommandSet, CommandGroup
|
||||
|
||||
_ipv4_default = {
|
||||
"bgp_route": "display bgp routing-table {target}",
|
||||
"bgp_aspath": "display bgp routing-table regular-expression {target}",
|
||||
"bgp_community": "display bgp routing-table regular-expression {target}",
|
||||
"ping": "ping -c 5 -a {source} {target}",
|
||||
"traceroute": "tracert -q 2 -f 1 -a {source} {target}",
|
||||
}
|
||||
_ipv6_default = {
|
||||
"bgp_route": "display bgp ipv6 routing-table {target}",
|
||||
"bgp_aspath": "display bgp ipv6 routing-table regular-expression {target}",
|
||||
"bgp_community": "display bgp ipv6 routing-table community {target}",
|
||||
"ping": "ping ipv6 -c 5 -a {source} {target}",
|
||||
"traceroute": "tracert ipv6 -q 2 -f 1 -a {source} {target}",
|
||||
}
|
||||
_ipv4_vpn = {
|
||||
"bgp_route": "display bgp vpnv4 vpn-instance {vrf} routing-table {target}",
|
||||
"bgp_aspath": "display bgp vpnv4 vpn-instance {vrf} routing-table regular-expression {target}",
|
||||
"bgp_community": "display bgp vpnv4 vpn-instance {vrf} routing-table regular-expression {target}",
|
||||
"ping": "ping -vpn-instance {vrf} -c 5 -a {source} {target}",
|
||||
"traceroute": "tracert -q 2 -f 1 -vpn-instance {vrf} -a {source} {target}",
|
||||
}
|
||||
_ipv6_vpn = {
|
||||
"bgp_route": "display bgp vpnv6 vpn-instance {vrf} routing-table {target}",
|
||||
"bgp_aspath": "display bgp vpnv6 vpn-instance {vrf} routing-table regular-expression {target}",
|
||||
"bgp_community": "display bgp vpnv6 vpn-instance {vrf} routing-table regular-expression {target}",
|
||||
"ping": "ping vpnv6 vpn-instance {vrf} -c 5 -a {source} {target}",
|
||||
"traceroute": "tracert -q 2 -f 1 vpn-instance {vrf} -a {source} {target}",
|
||||
}
|
||||
|
||||
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: CommandSet = CommandSet(**_ipv4_default)
|
||||
ipv6_default: CommandSet = CommandSet(**_ipv6_default)
|
||||
ipv4_vpn: CommandSet = CommandSet(**_ipv4_vpn)
|
||||
ipv6_vpn: CommandSet = CommandSet(**_ipv6_vpn)
|
||||
ipv4_default: _IPv4 = _IPv4()
|
||||
ipv6_default: _IPv6 = _IPv6()
|
||||
ipv4_vpn: _VPNIPv4 = _VPNIPv4()
|
||||
ipv6_vpn: _VPNIPv6 = _VPNIPv6()
|
||||
|
||||
@@ -1,63 +1,78 @@
|
||||
"""Juniper Command Model."""
|
||||
|
||||
# Third Party
|
||||
from pydantic import StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.configuration.models.commands.common import CommandSet, CommandGroup
|
||||
|
||||
_ipv4_default = {
|
||||
"bgp_route": 'show route protocol bgp table inet.0 {target} 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": 'show route protocol bgp table inet.0 aspath-regex "{target}"',
|
||||
"bgp_community": "show route protocol bgp table inet.0 community {target}",
|
||||
"ping": "ping inet {target} count 5 source {source}",
|
||||
"traceroute": "traceroute inet {target} wait 1 source {source}",
|
||||
}
|
||||
_ipv6_default = {
|
||||
"bgp_route": 'show route protocol bgp table inet6.0 {target} 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": 'show route protocol bgp table inet6.0 aspath-regex "{target}"',
|
||||
"bgp_community": "show route protocol bgp table inet6.0 community {target}",
|
||||
"ping": "ping inet6 {target} count 5 source {source}",
|
||||
"traceroute": "traceroute inet6 {target} wait 2 source {source}",
|
||||
}
|
||||
_ipv4_vpn = {
|
||||
"bgp_route": 'show route protocol bgp table {vrf}.inet.0 {target} 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": 'show route protocol bgp table {vrf}.inet.0 aspath-regex "{target}"',
|
||||
"bgp_community": "show route protocol bgp table {vrf}.inet.0 community {target}",
|
||||
"ping": "ping inet routing-instance {vrf} {target} count 5 source {source}",
|
||||
"traceroute": "traceroute inet routing-instance {vrf} {target} wait 1 source {source}",
|
||||
}
|
||||
_ipv6_vpn = {
|
||||
"bgp_route": 'show route protocol bgp table {vrf}.inet6.0 {target} 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": 'show route protocol bgp table {vrf}.inet6.0 aspath-regex "{target}"',
|
||||
"bgp_community": "show route protocol bgp table {vrf}.inet6.0 community {target}",
|
||||
"ping": "ping inet6 routing-instance {vrf} {target} count 5 source {source}",
|
||||
"traceroute": "traceroute inet6 routing-instance {vrf} {target} wait 2 source {source}",
|
||||
}
|
||||
|
||||
class _IPv4(CommandSet):
|
||||
"""Validation model for non-default dual afi commands."""
|
||||
|
||||
bgp_route: StrictStr = 'show route protocol bgp table inet.0 {target} 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} 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} 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} 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} detail | display json",
|
||||
bgp_aspath='show route protocol bgp table inet.0 aspath-regex "{target}" | display json',
|
||||
bgp_community="show route protocol bgp table inet.0 community {target} | display json",
|
||||
bgp_route="show route protocol bgp table inet.0 {target} 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} detail | display json",
|
||||
bgp_aspath='show route protocol bgp table inet6.0 aspath-regex "{target}" | display json',
|
||||
bgp_community="show route protocol bgp table inet6.0 community {target} | display json",
|
||||
bgp_route="show route protocol bgp table inet6.0 {target} 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} detail | display json",
|
||||
bgp_aspath='show route protocol bgp table {vrf}.inet.0 aspath-regex "{target}" | display json',
|
||||
bgp_community="show route protocol bgp table {vrf}.inet.0 community {target} | display json",
|
||||
bgp_route="show route protocol bgp table {vrf}.inet.0 {target} 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} detail | display json",
|
||||
bgp_aspath='show route protocol bgp table {vrf}.inet6.0 aspath-regex "{target}" | display json',
|
||||
bgp_community="show route protocol bgp table {vrf}.inet6.0 community {target} | display json",
|
||||
bgp_route="show route protocol bgp table {vrf}.inet6.0 {target} 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 1 source {source}",
|
||||
),
|
||||
@@ -67,8 +82,12 @@ _structured = CommandGroup(
|
||||
class JuniperCommands(CommandGroup):
|
||||
"""Validation model for default juniper commands."""
|
||||
|
||||
ipv4_default: CommandSet = CommandSet(**_ipv4_default)
|
||||
ipv6_default: CommandSet = CommandSet(**_ipv6_default)
|
||||
ipv4_vpn: CommandSet = CommandSet(**_ipv4_vpn)
|
||||
ipv6_vpn: CommandSet = CommandSet(**_ipv6_vpn)
|
||||
structured: CommandGroup = _structured
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user