forked from mirrors/thatmattlove-hyperglass
update docs & examples
This commit is contained in:
parent
5d39ff054f
commit
847e55098b
38 changed files with 744 additions and 256 deletions
14
.samples/Caddyfile
Normal file
14
.samples/Caddyfile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
lg.example.com:443 {
|
||||
tls person@example.com
|
||||
file_server {
|
||||
root /etc/hyperglass/static/ui
|
||||
index /etc/hyperglass/static/ui/index.html
|
||||
}
|
||||
file_server /custom {
|
||||
root /etc/hyperglass/static/custom
|
||||
}
|
||||
file_server /images {
|
||||
root /etc/hyperglass/static/images
|
||||
}
|
||||
reverse_proxy localhost:8001
|
||||
}
|
||||
15
.samples/hyperglass-docker.service
Normal file
15
.samples/hyperglass-docker.service
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[Unit]
|
||||
Description=hyperglass
|
||||
PartOf=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
WorkingDirectory=/opt/hyperglass
|
||||
EnvironmentFile=/etc/hyperglass/hyperglass.env
|
||||
ExecStart=/usr/bin/docker compose up -d --remove-orphans
|
||||
ExecStop=/usr/bin/docker compose down
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
13
.samples/hyperglass-manual.service
Normal file
13
.samples/hyperglass-manual.service
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=hyperglass
|
||||
After=network.target
|
||||
Requires=redis-server
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
Group=root
|
||||
EnvironmentFile=/etc/hyperglass/hyperglass.env
|
||||
ExecStart=python3 -m hyperglass.console start
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
49
.samples/hyperglass.nginx
Normal file
49
.samples/hyperglass.nginx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name lg.example.com;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
server {
|
||||
listen [::]:443 ssl ipv6only=on;
|
||||
listen 443 ssl;
|
||||
ssl_certificate <path to cert chain>
|
||||
ssl_certificate_key <path to key>
|
||||
|
||||
client_max_body_size 2M;
|
||||
|
||||
server_name lg.example.com;
|
||||
|
||||
root /etc/hyperglass/static;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /ui /ui/$uri =404;
|
||||
index /ui/index.html;
|
||||
}
|
||||
|
||||
location /openapi.json {
|
||||
try_files $uri @proxy_to_app;
|
||||
}
|
||||
|
||||
location /custom/ {
|
||||
try_files $uri $uri/ /custom;
|
||||
}
|
||||
|
||||
location /images/ {
|
||||
try_files $uri $uri/ /images;
|
||||
}
|
||||
|
||||
location /api {
|
||||
try_files $uri @proxy_to_app;
|
||||
}
|
||||
|
||||
location @proxy_to_app {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
proxy_pass http://[::1]:8001;
|
||||
}
|
||||
|
||||
}
|
||||
7
.samples/sample_devices.yaml
Normal file
7
.samples/sample_devices.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
devices:
|
||||
- name: Example Device
|
||||
address: 127.0.0.1
|
||||
credential:
|
||||
username: test
|
||||
password: test
|
||||
platform: juniper
|
||||
|
|
@ -1,4 +1,24 @@
|
|||
import { Callout } from 'nextra-theme-docs';
|
||||
import { Code, Table, Td, Th, Tr } from "nextra/components";
|
||||
import { Callout } from "nextra-theme-docs";
|
||||
import platforms from "~/platforms.json";
|
||||
import { Supported } from "./platforms.mdx";
|
||||
|
||||
export const Platforms = () => (
|
||||
<ul>
|
||||
{platforms.reduce((final, platform) => {
|
||||
if (platform.native) {
|
||||
const element = (
|
||||
<li key={platform.name}>
|
||||
<Supported style={{ display: "inline", marginRight: "0.5rem" }} />
|
||||
{platform.name}
|
||||
</li>
|
||||
);
|
||||
final = [...final, element];
|
||||
}
|
||||
return final;
|
||||
}, [])}
|
||||
</ul>
|
||||
);
|
||||
|
||||
Once you've gotten started with a basic configuration, you'll probably want to customize the look and feel of hyperglass by changing the logo or color scheme. Fortunately, there are _a lot_ ways to customize hyperglass.
|
||||
|
||||
|
|
@ -8,7 +28,7 @@ Once you've gotten started with a basic configuration, you'll probably want to c
|
|||
| :----------- | :------------------------------------------------------------------------- |
|
||||
| `config` | Application-wide configuration such as logging, web UI customization, etc. |
|
||||
| `devices` | Your devices and their associated configurations. |
|
||||
| `directives` | Custom [directives](/configuration/directives-file-reference) (commands). |
|
||||
| `directives` | Custom [directives](configuration/directives.mdx) (commands). |
|
||||
|
||||
<Callout type="info">
|
||||
**File Extensions** <br />
|
||||
|
|
@ -55,3 +75,21 @@ main = {
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Built-in Directives
|
||||
|
||||
hyperglass ships with predefined [directives](configuration/directives.mdx) for the following [platforms](platforms.mdx):
|
||||
|
||||
<Platforms />
|
||||
|
||||
All built in directives require that the following `attrs` be defined on each device using the directive:
|
||||
|
||||
| Attribute | Value |
|
||||
| :-------- | :-------------------------------------------------------- |
|
||||
| `source4` | IPv4 address used to source Ping and Traceroute commands. |
|
||||
| `source6` | IPv6 address used to source Ping and Traceroute commands. |
|
||||
|
||||
<Callout type="warning">
|
||||
If you do not utilize IPv6 in your network, you'll need to create your own directive that only
|
||||
has IPv4 commands.
|
||||
</Callout>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"reference": "Reference",
|
||||
"config": "Config File",
|
||||
"devices": "Devices File",
|
||||
"directives": "Directives File",
|
||||
"examples": "Examples"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ title: Basic Configuration
|
|||
description: Get started with a basic hyperglass configuration
|
||||
---
|
||||
|
||||
import { Callout } from 'nextra-theme-docs';
|
||||
import { Callout } from "nextra-theme-docs";
|
||||
|
||||
To get started, hyperglass only needs to know about your devices.
|
||||
|
||||
<Callout>
|
||||
**Devices** are your routers, switches, or whatever else you want to call the endpoints hyperglass
|
||||
will query for information.
|
||||
**Devices** are your routers, switches, or whatever else you want to call the endpoints
|
||||
hyperglass will query for information.
|
||||
</Callout>
|
||||
|
||||
## Simple Device Configuration
|
||||
|
|
@ -24,6 +24,9 @@ devices:
|
|||
username: <Username hyperglass will use to log into the router>
|
||||
password: <Password hyperglass will use to log into the router>
|
||||
platform: cisco_ios
|
||||
attrs:
|
||||
source4: <IPv4 address from which to source ping & traceroute commands>
|
||||
source6: <IPv4 address from which to source ping & traceroute commands>
|
||||
```
|
||||
|
||||
That's it!
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"config": "Config File",
|
||||
"devices": "Devices File",
|
||||
"directives": "Directives File"
|
||||
}
|
||||
|
|
@ -5,6 +5,64 @@ description: Installing hyperglass
|
|||
|
||||
import { Callout, Tab, Tabs } from 'nextra-theme-docs';
|
||||
|
||||
## Docker
|
||||
<Callout type="info">
|
||||
**Docker is the recommended method for running hyperglass.**
|
||||
</Callout>
|
||||
|
||||
### 1. [Install Docker](https://docs.docker.com/engine/install/)
|
||||
|
||||
### 2. Download hyperglass
|
||||
|
||||
```shell copy
|
||||
mkdir /etc/hyperglass
|
||||
cd /opt
|
||||
git clone https://github.com/thatmattlove/hyperglass/tree/v2.0.0 --depth=1
|
||||
```
|
||||
|
||||
### Quickstart (optional)
|
||||
|
||||
Do this if you just want to see the hyperglass page working with a fake device.
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/sample_devices.yaml /etc/hyperglass/devices.yaml
|
||||
cd /opt/hyperglass
|
||||
docker compose up
|
||||
```
|
||||
|
||||
Navigate to http://localhost:8001
|
||||
|
||||
### 3. Setup Reverse Proxy
|
||||
|
||||
[Caddy](https://caddyserver.com) is recommended, but any reverse proxy ([NGINX](https://www.nginx.com), [Apache2](https://httpd.apache.org)) will work.
|
||||
|
||||
#### Caddy
|
||||
|
||||
[**Install Caddy**](https://caddyserver.com/docs/install)
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/Caddyfile /etc/caddy/Caddyfile
|
||||
```
|
||||
|
||||
Change the `lg.example.com` and `person@example.com` values to match your hyperglass FQDN and email address (the email address is for automatic SSL certificate generation via Let's Encrypt).
|
||||
|
||||
<Callout type="info">
|
||||
If you prefer to use other Let's Encrypt validation methods or your own SSL certificate, modify your `/etc/hyperglass/Caddyfile` in accordance with the [Caddy docs](https://caddyserver.com/docs/caddyfile-tutorial).
|
||||
</Callout>
|
||||
|
||||
Restart the Caddy service: `systemctl restart caddy{:shell}`
|
||||
|
||||
#### NGINX
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/hyperglass.nginx /etc/nginx/sites-available/hyperglass
|
||||
ln -s /etc/nginx/sites-available/hyperglass /etc/nginx/sites-enabled/hyperglass
|
||||
```
|
||||
|
||||
Change the `lg.example.com` value to match your hyperglass FQDN.
|
||||
|
||||
Change the `<path to cert chain>` and `<path to key>` values to match the path to your certificate and private key files.
|
||||
|
||||
## Automatic installation
|
||||
|
||||
If your system runs on:
|
||||
|
|
|
|||
6
docs/pages/installation/_meta.json
Normal file
6
docs/pages/installation/_meta.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"docker": "Using Docker",
|
||||
"manual": "Manual Installation",
|
||||
"environment-variables": "Environment Variables",
|
||||
"reverse-proxy": "Reverse Proxy"
|
||||
}
|
||||
54
docs/pages/installation/docker.mdx
Normal file
54
docs/pages/installation/docker.mdx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
title: Using Docker
|
||||
description: Installing hyperglass with Docker
|
||||
---
|
||||
|
||||
import { Button } from "nextra/components";
|
||||
import { Callout } from "nextra-theme-docs";
|
||||
|
||||
## Docker
|
||||
|
||||
<Callout type="info">**Docker is the recommended method for running hyperglass.**</Callout>
|
||||
|
||||
### 1. Install Docker
|
||||
|
||||
<Button className="nx-my-4 nx-py-2 nx-px-4 nx-font-bold">
|
||||
<a target="_blank" href="https://docs.docker.com/engine/install/">
|
||||
Docker Engine Installation Guide
|
||||
</a>
|
||||
</Button>
|
||||
|
||||
### 2. Download hyperglass
|
||||
|
||||
```shell copy
|
||||
mkdir /etc/hyperglass
|
||||
cd /opt
|
||||
git clone https://github.com/thatmattlove/hyperglass/tree/v2.0.0 --depth=1
|
||||
```
|
||||
|
||||
### Optional: Quickstart
|
||||
|
||||
Do this if you just want to see the hyperglass page working with a fake device.
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/sample_devices.yaml /etc/hyperglass/devices.yaml
|
||||
cd /opt/hyperglass
|
||||
docker compose up
|
||||
```
|
||||
|
||||
Navigate to http://localhost:8001
|
||||
|
||||
### 3. Create a `systemd` service
|
||||
|
||||
<Callout type="info">
|
||||
Before you create and start the hyperglass service, you may want to verify whether or not you
|
||||
intend to change any [environment variables](environment-variables.mdx) and change them first.
|
||||
</Callout>
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/hyperglass-docker.service /etc/hyperglass/hyperglass.service
|
||||
ln -s /etc/hyperglass/hyperglass.service /etc/systemd/system/hyperglass.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable hyperglass
|
||||
systemctl start hyperglass
|
||||
```
|
||||
22
docs/pages/installation/environment-variables.mdx
Normal file
22
docs/pages/installation/environment-variables.mdx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
title: Environment Variables
|
||||
description: hyperglass environment variables
|
||||
---
|
||||
|
||||
There are some configuration variables that must be supplied before hyperglass can start or read its configuration files. Most of the time, you should not need to modify these.
|
||||
|
||||
Environment variables may be overridden at the command line, or by placing them in `${HYPERGLASS_APP_PATH}/hyperglass.env`.
|
||||
|
||||
| Variable Name | Type | Default | Description |
|
||||
| :-------------------------- | :------ | :---------------- | :----------------------------------------------------------------------------------------------------------------- |
|
||||
| `HYPERGLASS_DEBUG` | boolean | `false` | Enable debug logging |
|
||||
| `HYPERGLASS_DEV_MODE` | boolean | `false` | Enable developer mode. This should only be used if you are developing hyperglass under specific circumstances. |
|
||||
| `HYPERGLASS_DISABLE_UI` | boolean | `false` | If set to `true`, the hyperglass UI is not built or served. The only way to access hyperglass is via REST API. |
|
||||
| `HYPERGLASS_APP_PATH` | string | `/etc/hyperglass` | Directory where hyperglass configuration files and static web UI files are contained. |
|
||||
| `HYPERGLASS_REDIS_HOST` | string | `localhost` | Host on which Redis is running. |
|
||||
| `HYPERGLASS_REDIS_PASSWORD` | string | — | Redis password, if any. |
|
||||
| `HYPERGLASS_REDIS_DB` | number | `1` | Redis database number. |
|
||||
| `HYPERGLASS_REDIS_DSN` | string | — | Redis DSN. If supplied, overrides `HYPERGLASS_REDIS_HOST`, `HYPERGLASS_REDIS_DB`, and `HYPERGLASS_REDIS_PASSWORD`. |
|
||||
| `HYPERGLASS_HOST` | string | `[::1]` | Address on which hyperglass listens for requests. |
|
||||
| `HYPERGLASS_PORT` | number | `8001` | TCP port on which hyperglass listens for requests. |
|
||||
| `HYPERGLASS_CA_CERT` | string | — | Path to CA certificate file for validating HTTPS certificates. If not supplied, system CAs are used. |
|
||||
60
docs/pages/installation/manual.mdx
Normal file
60
docs/pages/installation/manual.mdx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
title: Manual Installation
|
||||
description: Installing hyperglass manually
|
||||
---
|
||||
|
||||
import { Callout } from 'nextra-theme-docs';
|
||||
|
||||
## Install Dependencies
|
||||
To install hyperglass manually, you'll need to install the following dependencies:
|
||||
|
||||
1. [Python 3.9, 3.10, 3.11, or 3.12](https://www.python.org/downloads/)
|
||||
2. [NodeJS 18.17 or later](https://nodejs.org/en/download)
|
||||
3. [PNPM 8 or later](https://pnpm.io/installation)
|
||||
4. [Redis 7.2 or later](https://redis.io/download/)
|
||||
|
||||
<Callout type="default">
|
||||
Make sure the Redis server is started.
|
||||
</Callout>
|
||||
|
||||
## Install hyperglass
|
||||
|
||||
Once these dependencies are installed, install hyperglass via PyPI:
|
||||
|
||||
```shell copy
|
||||
pip3 install hyperglass
|
||||
```
|
||||
|
||||
## Create app directory
|
||||
|
||||
<Callout type="info">
|
||||
If you plan on using a different directory, be sure to set the directory you wish to use in your [environment variables](environment-variables.mdx).
|
||||
</Callout>
|
||||
|
||||
```shell copy
|
||||
mkdir /etc/hyperglass
|
||||
```
|
||||
|
||||
## Optional: Quickstart
|
||||
|
||||
Do this if you just want to see the hyperglass page working with default settings and a fake device.
|
||||
|
||||
```shell copy
|
||||
curl -o /etc/hyperglass/devices.yaml https://github.com/thatmattlove/hyperglass/blob/v2.0.0/.samples/sample_devices.yaml
|
||||
hyperglass start
|
||||
```
|
||||
|
||||
## Create a `systemd` service
|
||||
|
||||
```shell copy
|
||||
curl -o /etc/hyperglass/hyperglass.service https://github.com/thatmattlove/hyperglass/blob/v2.0.0/.samples/hyperglass-manual.service
|
||||
ln -s /etc/hyperglass/hyperglass.service /etc/systemd/system/hyperglass.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable hyperglass
|
||||
systemctl start hyperglass
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
If you used a different app directory from the default `/etc/hyperglass`, change the `EnvironmentFile` value in the `hyperglass.service` file.
|
||||
</Callout>
|
||||
|
||||
42
docs/pages/installation/reverse-proxy.mdx
Normal file
42
docs/pages/installation/reverse-proxy.mdx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
title: Reverse Proxy
|
||||
description: Setting up a reverse proxy for hyperglass
|
||||
---
|
||||
|
||||
import { Button } from "nextra/components";
|
||||
import { Callout } from "nextra-theme-docs";
|
||||
|
||||
[Caddy](https://caddyserver.com) is recommended, but any reverse proxy ([NGINX](https://www.nginx.com), [Apache2](https://httpd.apache.org)) will work.
|
||||
|
||||
## Caddy
|
||||
|
||||
<Button className="nx-my-4 nx-py-2 nx-px-4 nx-font-bold">
|
||||
<a target="_blank" href="https://caddyserver.com/docs/install">
|
||||
Install Caddy
|
||||
</a>
|
||||
</Button>
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/Caddyfile /etc/caddy/Caddyfile
|
||||
```
|
||||
|
||||
Change the `lg.example.com` and `person@example.com` values to match your hyperglass FQDN and email address (the email address is for automatic SSL certificate generation via Let's Encrypt).
|
||||
|
||||
<Callout type="info">
|
||||
If you prefer to use other Let's Encrypt validation methods or your own SSL certificate, modify
|
||||
your `/etc/hyperglass/Caddyfile` in accordance with the [Caddy
|
||||
docs](https://caddyserver.com/docs/caddyfile-tutorial).
|
||||
</Callout>
|
||||
|
||||
Restart the Caddy service: `systemctl restart caddy{:shell}`
|
||||
|
||||
## NGINX
|
||||
|
||||
```shell copy
|
||||
cp /opt/hyperglass/.samples/hyperglass.nginx /etc/nginx/sites-available/hyperglass
|
||||
ln -s /etc/nginx/sites-available/hyperglass /etc/nginx/sites-enabled/hyperglass
|
||||
```
|
||||
|
||||
Change the `lg.example.com` value to match your hyperglass FQDN.
|
||||
|
||||
Change the `<path to cert chain>` and `<path to key>` values to match the path to your certificate and private key files.
|
||||
|
|
@ -2,19 +2,32 @@
|
|||
description: Platforms supported by hyperglass
|
||||
---
|
||||
|
||||
import { Code, Table, Td, Th, Tr } from 'nextra/components';
|
||||
import { Callout } from 'nextra-theme-docs';
|
||||
import platforms from '~/platforms.json';
|
||||
import { Code, Table, Td, Th, Tr } from "nextra/components";
|
||||
import { Callout } from "nextra-theme-docs";
|
||||
import platforms from "~/platforms.json";
|
||||
|
||||
export const NotSupported = () => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#edae49" viewBox="0 0 16 16">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="#edae49"
|
||||
viewBox="0 0 16 16"
|
||||
>
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
|
||||
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Supported = () => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#35b246" viewBox="0 0 16 16">
|
||||
export const Supported = (props) => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="#35b246"
|
||||
viewBox="0 0 16 16"
|
||||
{...props}
|
||||
>
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
|
||||
</svg>
|
||||
);
|
||||
|
|
@ -26,12 +39,16 @@ export const Platforms = () => (
|
|||
<Th>Platform Keys</Th>
|
||||
<Th>Natively Supported</Th>
|
||||
</Tr>
|
||||
{platforms.map(([platform, native]) => (
|
||||
<Tr key={platform}>
|
||||
{platforms.map((spec) => (
|
||||
<Tr key={spec.keys.join("--")}>
|
||||
<Td>
|
||||
<Code>{platform}</Code>
|
||||
{spec.keys.map((key) => (
|
||||
<Code className="nx-mx-2" key={key}>
|
||||
{key}
|
||||
</Code>
|
||||
))}
|
||||
</Td>
|
||||
<Td align="center">{native ? <Supported /> : <NotSupported />}</Td>
|
||||
<Td align="center">{spec.native ? <Supported /> : <NotSupported />}</Td>
|
||||
</Tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
|
@ -46,7 +63,7 @@ hyperglass uses [Netmiko](https://github.com/ktbyers/netmiko) to interact with d
|
|||
Just because Netmiko supports a given platform doesn't mean it will automatically work with
|
||||
hyperglass. hyperglass has a limited number of built in directives (listed below). Any platforms
|
||||
other than the ones listed below will require you to [add a custom
|
||||
directive](/configuration/examples/add-your-own-command) for each command you wish to make
|
||||
directive](configuration/examples/add-your-own-command.mdx) for each command you wish to make
|
||||
available.
|
||||
</Callout>
|
||||
|
||||
|
|
@ -57,7 +74,5 @@ hyperglass uses [Netmiko](https://github.com/ktbyers/netmiko) to interact with d
|
|||
## Other Platforms
|
||||
|
||||
| Platform | Key | Natively Supported |
|
||||
| :---------------- | :----- | :-------------------------------------------------------------------------: |
|
||||
| FRRouting | `frr` | <Supported/> |
|
||||
| BIRD | `bird` | <Supported/> |
|
||||
| Any HTTP Endpoint | `http` | [See HTTP Device Docs](/configuration/reference/devices#http-configuration) |
|
||||
| :---------------- | :----- | :------------------------------------------------------------------: |
|
||||
| Any HTTP Endpoint | `http` | [See HTTP Device Docs](configuration/devices.mdx#http-configuration) |
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,14 +1,15 @@
|
|||
import styles from './global.module.css';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useConfig, type DocsThemeConfig } from 'nextra-theme-docs';
|
||||
import faviconFormats from './favicon-formats';
|
||||
import { useRouter } from "next/router";
|
||||
import { type DocsThemeConfig, useConfig } from "nextra-theme-docs";
|
||||
import faviconFormats from "./favicon-formats";
|
||||
import styles from "./global.module.css";
|
||||
|
||||
const NO_INDEX_FOLLOW = process.env.CF_PAGES_BRANCH !== 'main';
|
||||
const NO_INDEX_FOLLOW = process.env.CF_PAGES_BRANCH !== "main";
|
||||
|
||||
const config: DocsThemeConfig = {
|
||||
logo: (
|
||||
<span className={styles.logo}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2759.9 544.87" width={200}>
|
||||
<title>hyperglass</title>
|
||||
<g fill="currentColor">
|
||||
<g>
|
||||
<path
|
||||
|
|
@ -75,41 +76,46 @@ const config: DocsThemeConfig = {
|
|||
const { asPath } = useRouter();
|
||||
const { frontMatter, title } = useConfig();
|
||||
return {
|
||||
titleTemplate: '%s | hyperglass',
|
||||
titleTemplate: "%s | hyperglass",
|
||||
title: frontMatter.title || title,
|
||||
openGraph: {
|
||||
type: 'website',
|
||||
type: "website",
|
||||
url: `https://hyperglass.dev${asPath}`,
|
||||
title: frontMatter.title || title,
|
||||
description: frontMatter.description || 'hyperglass Documentation',
|
||||
description: frontMatter.description || "hyperglass Documentation",
|
||||
images: [
|
||||
{
|
||||
url: 'https://hyperglass.dev/opengraph.jpg',
|
||||
url: "https://hyperglass.dev/opengraph.jpg",
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: 'hyperglass',
|
||||
alt: "hyperglass",
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: { handle: '@thatmattlove', site: '@thatmattlove', cardType: 'summary_large_image' },
|
||||
twitter: {
|
||||
handle: "@thatmattlove",
|
||||
site: "@thatmattlove",
|
||||
cardType: "summary_large_image",
|
||||
},
|
||||
noindex: NO_INDEX_FOLLOW,
|
||||
nofollow: NO_INDEX_FOLLOW,
|
||||
additionalLinkTags: faviconFormats.map(fmt => {
|
||||
additionalLinkTags: faviconFormats.map((fmt) => {
|
||||
const { image_format, dimensions, prefix, rel } = fmt;
|
||||
const [w, h] = dimensions;
|
||||
const href = `/img/${prefix}-${w}x${h}.${image_format}`;
|
||||
return { rel: rel ?? '', href, type: `image/${image_format}` };
|
||||
return { rel: rel ?? "", href, type: `image/${image_format}` };
|
||||
}),
|
||||
};
|
||||
},
|
||||
banner: {
|
||||
dismissible: true,
|
||||
text: '🎉 hyperglass 2.0 is here!',
|
||||
// text: "🎉 hyperglass 2.0 is here!",
|
||||
text: "😬 hyperglass 2.0 and its documentation is still in development!",
|
||||
},
|
||||
feedback: { content: null },
|
||||
footer: { text: `© ${new Date().getFullYear()} hyperglass` },
|
||||
chat: {
|
||||
link: 'https://netdev.chat/',
|
||||
link: "https://netdev.chat/",
|
||||
icon: (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
|
@ -118,12 +124,13 @@ const config: DocsThemeConfig = {
|
|||
height="24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<title>NetDev Chat</title>
|
||||
<path d="M94.12 315.1c0 25.9-21.16 47.06-47.06 47.06S0 341 0 315.1c0-25.9 21.16-47.06 47.06-47.06h47.06v47.06zm23.72 0c0-25.9 21.16-47.06 47.06-47.06s47.06 21.16 47.06 47.06v117.84c0 25.9-21.16 47.06-47.06 47.06s-47.06-21.16-47.06-47.06V315.1zm47.06-188.98c-25.9 0-47.06-21.16-47.06-47.06S139 32 164.9 32s47.06 21.16 47.06 47.06v47.06H164.9zm0 23.72c25.9 0 47.06 21.16 47.06 47.06s-21.16 47.06-47.06 47.06H47.06C21.16 243.96 0 222.8 0 196.9s21.16-47.06 47.06-47.06H164.9zm188.98 47.06c0-25.9 21.16-47.06 47.06-47.06 25.9 0 47.06 21.16 47.06 47.06s-21.16 47.06-47.06 47.06h-47.06V196.9zm-23.72 0c0 25.9-21.16 47.06-47.06 47.06-25.9 0-47.06-21.16-47.06-47.06V79.06c0-25.9 21.16-47.06 47.06-47.06 25.9 0 47.06 21.16 47.06 47.06V196.9zM283.1 385.88c25.9 0 47.06 21.16 47.06 47.06 0 25.9-21.16 47.06-47.06 47.06-25.9 0-47.06-21.16-47.06-47.06v-47.06h47.06zm0-23.72c-25.9 0-47.06-21.16-47.06-47.06 0-25.9 21.16-47.06 47.06-47.06h117.84c25.9 0 47.06 21.16 47.06 47.06 0 25.9-21.16 47.06-47.06 47.06H283.1z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
project: {
|
||||
link: 'https://github.com/thatmattlove/hyperglass',
|
||||
link: "https://github.com/thatmattlove/hyperglass",
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ __all__ = (
|
|||
"AristaBGPCommunityTable",
|
||||
)
|
||||
|
||||
NAME = "Arista EOS"
|
||||
PLATFORMS = ["arista_eos"]
|
||||
|
||||
AristaBGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_arista_eos_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -37,7 +40,7 @@ AristaBGPRoute = BuiltinDirective(
|
|||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
table_output="__hyperglass_arista_eos_bgp_route_table__",
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
AristaBGPASPath = BuiltinDirective(
|
||||
|
|
@ -55,7 +58,7 @@ AristaBGPASPath = BuiltinDirective(
|
|||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
table_output="__hyperglass_arista_eos_bgp_aspath_table__",
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
AristaBGPCommunity = BuiltinDirective(
|
||||
|
|
@ -73,7 +76,7 @@ AristaBGPCommunity = BuiltinDirective(
|
|||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
table_output="__hyperglass_arista_eos_bgp_community_table__",
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -93,7 +96,7 @@ AristaPing = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
AristaTraceroute = BuiltinDirective(
|
||||
|
|
@ -112,7 +115,7 @@ AristaTraceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
# Table Output Directives
|
||||
|
|
@ -133,7 +136,7 @@ AristaBGPRouteTable = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
AristaBGPASPathTable = BuiltinDirective(
|
||||
|
|
@ -150,7 +153,7 @@ AristaBGPASPathTable = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
AristaBGPCommunityTable = BuiltinDirective(
|
||||
|
|
@ -167,5 +170,5 @@ AristaBGPCommunityTable = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["arista_eos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"BIRD_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "BIRD"
|
||||
PLATFORMS = ["bird"]
|
||||
|
||||
BIRD_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_bird_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ BIRD_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["bird"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
BIRD_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -49,7 +52,7 @@ BIRD_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["bird"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
BIRD_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -65,7 +68,7 @@ BIRD_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["bird"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
BIRD_Ping = BuiltinDirective(
|
||||
|
|
@ -84,7 +87,7 @@ BIRD_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["bird"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
BIRD_Traceroute = BuiltinDirective(
|
||||
|
|
@ -103,5 +106,5 @@ BIRD_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["bird"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"CiscoIOS_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "Cisco IOS"
|
||||
PLATFORMS = ["cisco_ios"]
|
||||
|
||||
CiscoIOS_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_cisco_ios_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ CiscoIOS_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_ios"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoIOS_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ CiscoIOS_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["cisco_ios"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoIOS_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ CiscoIOS_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["cisco_ios"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoIOS_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ CiscoIOS_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_ios"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoIOS_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ CiscoIOS_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_ios"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"CiscoNXOS_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "Cisco NX-OS"
|
||||
PLATFORMS = ["cisco_nxos"]
|
||||
|
||||
CiscoNXOS_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_cisco_nxos_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ CiscoNXOS_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_nxos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoNXOS_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ CiscoNXOS_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["cisco_nxos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoNXOS_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ CiscoNXOS_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["cisco_nxos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoNXOS_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ CiscoNXOS_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_nxos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoNXOS_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ CiscoNXOS_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_nxos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"CiscoXR_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "Cisco IOS-XR"
|
||||
PLATFORMS = ["cisco_xr"]
|
||||
|
||||
CiscoXR_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_cisco_xr_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ CiscoXR_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_xr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoXR_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ CiscoXR_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["cisco_xr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoXR_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ CiscoXR_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["cisco_xr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoXR_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ CiscoXR_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_xr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
CiscoXR_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ CiscoXR_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["cisco_xr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"FRRouting_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "FRRouting"
|
||||
PLATFORMS = ["frr"]
|
||||
|
||||
FRRouting_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_frr_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ FRRouting_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["frr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
FRRouting_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ FRRouting_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["frr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
FRRouting_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ FRRouting_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["frr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
FRRouting_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ FRRouting_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["frr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
FRRouting_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ FRRouting_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["frr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"Huawei_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "Huawei VRP"
|
||||
PLATFORMS = ["huawei", "huawei_vrpv8"]
|
||||
|
||||
Huawei_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_huawei_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ Huawei_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["huawei"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Huawei_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ Huawei_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["huawei"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Huawei_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ Huawei_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["huawei"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Huawei_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ Huawei_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["huawei"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Huawei_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ Huawei_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["huawei"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ __all__ = (
|
|||
"JuniperBGPCommunityTable",
|
||||
)
|
||||
|
||||
NAME = "Juniper Junos"
|
||||
PLATFORMS = ["juniper", "juniper_junos"]
|
||||
|
||||
JuniperBGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_juniper_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -37,7 +40,7 @@ JuniperBGPRoute = BuiltinDirective(
|
|||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
table_output="__hyperglass_juniper_bgp_route_table__",
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
JuniperBGPASPath = BuiltinDirective(
|
||||
|
|
@ -55,7 +58,7 @@ JuniperBGPASPath = BuiltinDirective(
|
|||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
table_output="__hyperglass_juniper_bgp_aspath_table__",
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
JuniperBGPCommunity = BuiltinDirective(
|
||||
|
|
@ -73,7 +76,7 @@ JuniperBGPCommunity = BuiltinDirective(
|
|||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
table_output="__hyperglass_juniper_bgp_community_table__",
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -93,7 +96,7 @@ JuniperPing = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
JuniperTraceroute = BuiltinDirective(
|
||||
|
|
@ -112,7 +115,7 @@ JuniperTraceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
# Table Output Directives
|
||||
|
|
@ -133,7 +136,7 @@ JuniperBGPRouteTable = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
JuniperBGPASPathTable = BuiltinDirective(
|
||||
|
|
@ -150,7 +153,7 @@ JuniperBGPASPathTable = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
JuniperBGPCommunityTable = BuiltinDirective(
|
||||
|
|
@ -167,5 +170,5 @@ JuniperBGPCommunityTable = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["juniper"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"Mikrotik_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "Mikrotik"
|
||||
PLATFORMS = ["mikrotik_routeros", "mikrotik_switchos"]
|
||||
|
||||
Mikrotik_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_mikrotik_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ Mikrotik_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["mikrotik_routeros", "mikrotik_switchos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Mikrotik_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ Mikrotik_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["mikrotik_routeros", "mikrotik_switchos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Mikrotik_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ Mikrotik_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["mikrotik_routeros", "mikrotik_switchos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Mikrotik_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ Mikrotik_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["mikrotik_routeros", "mikrotik_switchos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
Mikrotik_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ Mikrotik_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["mikrotik_routeros", "mikrotik_switchos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"NokiaSROS_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "Nokia SR OS"
|
||||
PLATFORMS = ["nokia_sros"]
|
||||
|
||||
NokiaSROS_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_nokia_sros_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ NokiaSROS_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["nokia_sros"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
NokiaSROS_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -49,7 +52,7 @@ NokiaSROS_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["nokia_sros"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
NokiaSROS_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -65,7 +68,7 @@ NokiaSROS_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["nokia_sros"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
NokiaSROS_Ping = BuiltinDirective(
|
||||
|
|
@ -84,7 +87,7 @@ NokiaSROS_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["nokia_sros"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
NokiaSROS_Traceroute = BuiltinDirective(
|
||||
|
|
@ -103,5 +106,5 @@ NokiaSROS_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["nokia_sros"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"OpenBGPD_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "OpenBGPD"
|
||||
PLATFORMS = ["openbgpd"]
|
||||
|
||||
OpenBGPD_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_openbgpd_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ OpenBGPD_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["openbgpd"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
OpenBGPD_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ OpenBGPD_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["openbgpd"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
OpenBGPD_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ OpenBGPD_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["openbgpd"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
OpenBGPD_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ OpenBGPD_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["openbgpd"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
OpenBGPD_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ OpenBGPD_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["openbgpd"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"TNSR_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "TNSR"
|
||||
PLATFORMS = ["tnsr"]
|
||||
|
||||
TNSR_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_tnsr_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ TNSR_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["tnsr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
TNSR_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ TNSR_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["tnsr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
TNSR_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ TNSR_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["tnsr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
TNSR_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ TNSR_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["tnsr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
TNSR_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ TNSR_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["tnsr"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ __all__ = (
|
|||
"VyOS_Traceroute",
|
||||
)
|
||||
|
||||
NAME = "VyOS"
|
||||
PLATFORMS = ["vyos"]
|
||||
|
||||
VyOS_BGPRoute = BuiltinDirective(
|
||||
id="__hyperglass_vyos_bgp_route__",
|
||||
name="BGP Route",
|
||||
|
|
@ -33,7 +36,7 @@ VyOS_BGPRoute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["vyos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
VyOS_BGPASPath = BuiltinDirective(
|
||||
|
|
@ -50,7 +53,7 @@ VyOS_BGPASPath = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="AS Path Regular Expression"),
|
||||
platforms=["vyos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
VyOS_BGPCommunity = BuiltinDirective(
|
||||
|
|
@ -67,7 +70,7 @@ VyOS_BGPCommunity = BuiltinDirective(
|
|||
)
|
||||
],
|
||||
field=Text(description="BGP Community String"),
|
||||
platforms=["vyos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
VyOS_Ping = BuiltinDirective(
|
||||
|
|
@ -86,7 +89,7 @@ VyOS_Ping = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["vyos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
||||
VyOS_Traceroute = BuiltinDirective(
|
||||
|
|
@ -105,5 +108,5 @@ VyOS_Traceroute = BuiltinDirective(
|
|||
),
|
||||
],
|
||||
field=Text(description="IP Address, Prefix, or Hostname"),
|
||||
platforms=["vyos"],
|
||||
platforms=PLATFORMS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,37 @@
|
|||
|
||||
# Standard Library
|
||||
import json
|
||||
import typing as t
|
||||
from pathlib import Path
|
||||
from importlib.util import module_from_spec, spec_from_file_location
|
||||
|
||||
|
||||
class PlatformSpec(t.TypedDict):
|
||||
"""Definition for each platform."""
|
||||
|
||||
name: str
|
||||
keys: t.Tuple[str, ...]
|
||||
native: bool
|
||||
|
||||
|
||||
def get_directive_variable(path: Path, variable: str) -> t.Any:
|
||||
"""Read a variable from a directive file."""
|
||||
|
||||
name, _ = path.name.split(".")
|
||||
spec = spec_from_file_location(name, location=path)
|
||||
module = module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
exports = tuple(getattr(module, e, None) for e in dir(module) if e == variable)
|
||||
if len(exports) < 1:
|
||||
raise RuntimeError(f"'{path!s} exists', but it is missing a variable named '{variable}'")
|
||||
|
||||
value, *_ = exports
|
||||
return value
|
||||
|
||||
|
||||
def create_platform_list() -> str:
|
||||
"""Create a list of platforms as a typescript file for use by the docs."""
|
||||
"""Create a list of platforms as a JSON file for use by the docs."""
|
||||
# Third Party
|
||||
from netmiko.ssh_dispatcher import CLASS_MAPPER # type: ignore
|
||||
|
||||
|
|
@ -17,11 +43,34 @@ def create_platform_list() -> str:
|
|||
|
||||
builtin_directives = project_root / "hyperglass" / "defaults" / "directives"
|
||||
|
||||
names = [f.stem for f in builtin_directives.iterdir() if not f.name.startswith("_")]
|
||||
platforms: t.Tuple[PlatformSpec] = ()
|
||||
|
||||
platforms = [[p, p in names] for p in CLASS_MAPPER.keys()]
|
||||
keys = []
|
||||
|
||||
for path in builtin_directives.iterdir():
|
||||
if not path.name.startswith("_"):
|
||||
name = get_directive_variable(path, "NAME")
|
||||
if not isinstance(name, str):
|
||||
raise RuntimeError("'NAME' variable is missing or invalid in '{!s}'".format(path))
|
||||
_platforms = get_directive_variable(path, "PLATFORMS")
|
||||
if not isinstance(_platforms, t.Tuple, t.List):
|
||||
raise RuntimeError(
|
||||
"'PLATFORMS' variable is missing or invalid in '{!s}'".format(path)
|
||||
)
|
||||
spec: PlatformSpec = {"name": name, "keys": _platforms, "native": True}
|
||||
platforms += (spec,)
|
||||
keys = [*keys, *_platforms]
|
||||
|
||||
for key in CLASS_MAPPER.keys():
|
||||
if key not in keys:
|
||||
spec: PlatformSpec = {"name": "", "keys": (key,), "native": False}
|
||||
platforms += (spec,)
|
||||
|
||||
sorted_platforms = list(platforms)
|
||||
sorted_platforms.sort(key=lambda x: x["keys"][0])
|
||||
sorted_platforms.sort(key=lambda x: not x["native"])
|
||||
|
||||
with file_.open("w+") as opened_file:
|
||||
json.dump(platforms, opened_file)
|
||||
json.dump(sorted_platforms, opened_file)
|
||||
|
||||
return f"Wrote platforms to {file_!s}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue