From 013fdde8e74acc26b5e3c8d58c5adaa52a29f63e Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sat, 4 Jul 2020 19:30:46 -0700 Subject: [PATCH] add VyOS support --- README.md | 3 +- docs/docs/commands.mdx | 11 ++-- docs/docs/introduction.mdx | 1 + .../configuration/models/commands/__init__.py | 3 + .../configuration/models/commands/vyos.py | 56 +++++++++++++++++++ 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 hyperglass/configuration/models/commands/vyos.py diff --git a/README.md b/README.md index b2fc722..7c10f75 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- +

The network looking glass that tries to make the internet better.


@@ -47,6 +47,7 @@ hyperglass is intended to make implementing a looking glass too easy not to do, - Juniper JunOS - Arista EOS - Huawei + - VyOS - FRRouting - BIRD - Configurable support for any other [supported platform](https://hyperglass.io/docs/platforms) diff --git a/docs/docs/commands.mdx b/docs/docs/commands.mdx index 615106b..eca90bc 100644 --- a/docs/docs/commands.mdx +++ b/docs/docs/commands.mdx @@ -28,6 +28,11 @@ hyperglass comes with built in support for the following platforms: - Juniper JunOS - Arista EOS - Huawei VRP +- VyOS + +::: warning VyOS & VRFs +As of `vyos-1.3-rolling-202007050117` which is the latest release VyOS has been tested with hyperglass, VyOS does not support BGP or other dynamic routing protocols in a VRF. As such, the default BGP commands for VyOS **omit the VRF from the command**. +::: Default commands for each of these network operating systems are built into hyperglass. However, you may override any of them or even add commands for another Network Operating System (NOS), as long as it's [supported](platforms). To define custom commands, add a `commands.yaml` file to your installation directory (`/etc/hyperglass`, `~/hyperglass`). As an example, you could override the default Juniper `bgp_route` command for the default routing table like this: @@ -83,8 +88,7 @@ command_name: You can also define your own arbitrary command groups, and reference them in your `devices.yaml` file. For example, if you wanted define a set of commands for a specific device to use, you could do it like this: -```yaml -# commands.yaml +```yaml title=commands.yaml --- special_commands: ipv4_default: @@ -101,8 +105,7 @@ You must define _all_ commands, even if they're disabled in your [configuration] Then, in the device's definition in `devices.yaml`, reference the command set: -```yaml {5} -# devices.yaml +```yaml {5} title=devices.yaml --- routers: - name: specialrouter01 diff --git a/docs/docs/introduction.mdx b/docs/docs/introduction.mdx index 5afb82a..8a36934 100644 --- a/docs/docs/introduction.mdx +++ b/docs/docs/introduction.mdx @@ -28,6 +28,7 @@ hyperglass was created with the lofty goal of benefiting the internet community - Juniper JunOS - Arista EOS - Huawei + - VyOS - FRRouting - BIRD - Configurable support for any other [supported platform](platforms.mdx) diff --git a/hyperglass/configuration/models/commands/__init__.py b/hyperglass/configuration/models/commands/__init__.py index 69db541..d14dca4 100644 --- a/hyperglass/configuration/models/commands/__init__.py +++ b/hyperglass/configuration/models/commands/__init__.py @@ -2,6 +2,7 @@ # Project from hyperglass.models import HyperglassModelExtra +from hyperglass.configuration.models.commands.vyos import VyosCommands from hyperglass.configuration.models.commands.arista import AristaCommands from hyperglass.configuration.models.commands.common import CommandGroup from hyperglass.configuration.models.commands.huawei import HuaweiCommands @@ -17,6 +18,7 @@ _NOS_MAP = { "cisco_nxos": CiscoNXOSCommands, "arista": AristaCommands, "huawei": HuaweiCommands, + "vyos": VyosCommands, } @@ -29,6 +31,7 @@ class Commands(HyperglassModelExtra): cisco_xr: CommandGroup = CiscoXRCommands() cisco_nxos: CommandGroup = CiscoNXOSCommands() huawei: CommandGroup = HuaweiCommands() + vyos: CommandGroup = VyosCommands() @classmethod def import_params(cls, input_params): diff --git a/hyperglass/configuration/models/commands/vyos.py b/hyperglass/configuration/models/commands/vyos.py new file mode 100644 index 0000000..a02f81c --- /dev/null +++ b/hyperglass/configuration/models/commands/vyos.py @@ -0,0 +1,56 @@ +"""VyOS Command Model.""" + +# Third Party +from pydantic import StrictStr + +# Project +from hyperglass.configuration.models.commands.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()