diff --git a/hyperglass/constants.py b/hyperglass/constants.py index 0b4bd60..7087b48 100644 --- a/hyperglass/constants.py +++ b/hyperglass/constants.py @@ -74,12 +74,14 @@ SCRAPE_HELPERS = { DRIVER_MAP = { "arista_eos": "scrapli", + "bird_ssh": "scrapli", "cisco_ios": "scrapli", "cisco_xe": "scrapli", "cisco_xr": "scrapli", "cisco_nxos": "scrapli", "juniper": "scrapli", "tnsr": "scrapli", + "frr_ssh": "scrapli", "frr": "hyperglass_agent", "bird": "hyperglass_agent", } diff --git a/hyperglass/execution/drivers/ssh_scrapli.py b/hyperglass/execution/drivers/ssh_scrapli.py index fafb1d9..7ad2b2c 100644 --- a/hyperglass/execution/drivers/ssh_scrapli.py +++ b/hyperglass/execution/drivers/ssh_scrapli.py @@ -38,9 +38,11 @@ from .ssh import SSHConnection SCRAPLI_DRIVER_MAP = { "arista_eos": AsyncEOSDriver, + "bird_ssh": AsyncGenericDriver, "cisco_ios": AsyncIOSXEDriver, "cisco_nxos": AsyncNXOSDriver, "cisco_xr": AsyncIOSXRDriver, + "frr_ssh": AsyncGenericDriver, "juniper": AsyncJunosDriver, "tnsr": AsyncGenericDriver, } diff --git a/hyperglass/models/commands/__init__.py b/hyperglass/models/commands/__init__.py index 9ca62df..622385d 100644 --- a/hyperglass/models/commands/__init__.py +++ b/hyperglass/models/commands/__init__.py @@ -1,6 +1,7 @@ """Validate command configuration variables.""" # Local +from .frr import FRRCommands from .tnsr import TNSRCommands from .vyos import VyosCommands from ..main import HyperglassModelExtra @@ -14,12 +15,15 @@ from .cisco_nxos import CiscoNXOSCommands from .nokia_sros import NokiaSROSCommands from .mikrotik_routeros import MikrotikRouterOS from .mikrotik_switchos import MikrotikSwitchOS +from .bird import BIRDCommands _NOS_MAP = { "arista": AristaCommands, + "bird_ssh": BIRDCommands, "cisco_ios": CiscoIOSCommands, "cisco_nxos": CiscoNXOSCommands, "cisco_xr": CiscoXRCommands, + "frr_ssh": FRRCommands, "huawei": HuaweiCommands, "juniper": JuniperCommands, "mikrotik_routeros": MikrotikRouterOS, @@ -33,12 +37,14 @@ _NOS_MAP = { class Commands(HyperglassModelExtra): """Base class for command definitions.""" - juniper: CommandGroup = JuniperCommands() arista: CommandGroup = AristaCommands() + bird_ssh: CommandGroup = BIRDCommands() cisco_ios: CommandGroup = CiscoIOSCommands() - cisco_xr: CommandGroup = CiscoXRCommands() cisco_nxos: CommandGroup = CiscoNXOSCommands() + cisco_xr: CommandGroup = CiscoXRCommands() + frr_ssh: CommandGroup = FRRCommands() huawei: CommandGroup = HuaweiCommands() + juniper: CommandGroup = JuniperCommands() mikrotik_routeros: CommandGroup = MikrotikRouterOS() mikrotik_switchos: CommandGroup = MikrotikSwitchOS() nokia_sros: CommandGroup = NokiaSROSCommands() diff --git a/hyperglass/models/commands/bird.py b/hyperglass/models/commands/bird.py new file mode 100644 index 0000000..9a86f0a --- /dev/null +++ b/hyperglass/models/commands/bird.py @@ -0,0 +1,56 @@ +"""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/frr.py b/hyperglass/models/commands/frr.py new file mode 100644 index 0000000..2dde708 --- /dev/null +++ b/hyperglass/models/commands/frr.py @@ -0,0 +1,56 @@ +"""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/config/devices.py b/hyperglass/models/config/devices.py index 0379951..ec2b592 100644 --- a/hyperglass/models/config/devices.py +++ b/hyperglass/models/config/devices.py @@ -50,7 +50,7 @@ class Device(HyperglassModel): credential: Credential proxy: Optional[Proxy] display_name: StrictStr - port: StrictInt + port: StrictInt = 22 ssl: Optional[Ssl] nos: StrictStr commands: Optional[StrictStr]