172 lines
5.1 KiB
Markdown
172 lines
5.1 KiB
Markdown
# skyforge
|
|
|
|
## Brief
|
|
|
|
skyforge was designed to assist in rendering thousands of device configurations across the globe
|
|
|
|
## Assumptions
|
|
|
|
- Partitions are groups of regions
|
|
- Regions are groups of zones
|
|
- Zones are groups of devices
|
|
- Fabrics are groups of layers
|
|
- Layers are groups of common devices and facilitate template mapping
|
|
|
|
## Functionality
|
|
|
|
Skyforge takes a user provided regex pattern, performs a walk on a `./spec` dir,
|
|
and matches a list of devices specifications that do not have the word "common" in their path.
|
|
All group files are labeled with common and mappable from the file itself.
|
|
|
|
For each "device" matched, skyforge then maps to all consituent files:
|
|
|
|
- Layer - from the `common.yaml` file in parent dir and maps the region
|
|
- Zonal - from the first group of chars in filename up to a `-`
|
|
- Regional - from value of `common.fabric` field in `Layer` file
|
|
- Partitional - from value of `regional.partition` field in `Regional` file
|
|
|
|
Once all files are found, a compiled specifcation is built.
|
|
This spec is then passed to Tera as context.
|
|
Tera loads the template files for that layer and renders the configuration files.
|
|
|
|
## Usage
|
|
|
|
from the `skyforge/demo` directory
|
|
|
|
### Help
|
|
|
|
``` bash
|
|
Skyforge Config Generation Engine
|
|
|
|
Usage: skyforge [OPTIONS] --devices <devices>
|
|
|
|
Options:
|
|
-d, --devices <devices> A regular expression pattern
|
|
--debug Print debug information
|
|
-v, --verbose Print verbose information
|
|
-h, --help Print help
|
|
-V, --version Print version
|
|
|
|
Environment:
|
|
SKYFORGE_SPECDIR Directory containing templates
|
|
SKYFORGE_TMPLDIR Directory containing specifications
|
|
SKYFORGE_OUTDIR Directory for command output
|
|
SKYFORGE_LOGDIR Directory for log output
|
|
```
|
|
|
|
### Standard
|
|
|
|
``` bash
|
|
$ skyforge -d xyz1-ex-edge-r101
|
|
Skyforge found 9 renderable devices
|
|
Matched 1 devices against 'xyz1-ex-edge-r101'
|
|
Rendering configs:
|
|
| xyz1-ex-edge-r101
|
|
Writing Output:
|
|
| ./out/xyz1-ex-edge-r101/all.live.junos
|
|
| ./out/xyz1-ex-edge-r101/all.shifted.junos
|
|
| ./out/xyz1-ex-edge-r101/all.init.junos
|
|
Completed Successfully
|
|
```
|
|
|
|
### Verbose
|
|
|
|
``` bash
|
|
$ skyforge -d xyz1-ex-edge-r101 -v
|
|
Skyforge found 9 renderable devices
|
|
Matched 1 devices against 'xyz1-ex-edge-r101'
|
|
| ./spec/xyz/ex-edge-r/xyz1-ex-edge-r101.yaml
|
|
Rendering configs:
|
|
| xyz1-ex-edge-r101
|
|
Writing Output:
|
|
| ./out/xyz1-ex-edge-r101/live/system.junos
|
|
| ./out/xyz1-ex-edge-r101/live/interfaces.junos
|
|
| ./out/xyz1-ex-edge-r101/live/protocols.junos
|
|
| ./out/xyz1-ex-edge-r101/live/policy-options.junos
|
|
| ./out/xyz1-ex-edge-r101/all.live.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/system.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/interfaces.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/protocols.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/policy-options.junos
|
|
| ./out/xyz1-ex-edge-r101/all.shifted.junos
|
|
| ./out/xyz1-ex-edge-r101/init/system.junos
|
|
| ./out/xyz1-ex-edge-r101/init/interfaces.junos
|
|
| ./out/xyz1-ex-edge-r101/init/protocols.junos
|
|
| ./out/xyz1-ex-edge-r101/init/policy-options.junos
|
|
| ./out/xyz1-ex-edge-r101/all.init.junos
|
|
| ./out/xyz1-ex-edge-r101/context.yaml
|
|
Completed Successfully
|
|
```
|
|
|
|
### Debug
|
|
|
|
``` bash
|
|
$ skyforge -d xyz1-ex-edge-r101 -D
|
|
Using tmp dir: /tmp/skyforge-1772096013345
|
|
Removing existing output path: ./out
|
|
Output symlinked: ./out -> /tmp/skyforge-1772096013345
|
|
Skyforge found 9 renderable devices
|
|
Matched 1 devices against 'xyz1-ex-edge-r101'
|
|
| ./spec/xyz/ex-edge-r/xyz1-ex-edge-r101.yaml
|
|
Components {
|
|
partitional: "./spec/common/us.yaml",
|
|
regional: "./spec/xyz/common/ex.yaml",
|
|
common: "./spec/xyz/ex-edge-r/common.yaml",
|
|
zonal: "./spec/xyz/ex-edge-r/xyz1.common.yaml",
|
|
device: "./spec/xyz/ex-edge-r/xyz1-ex-edge-r101.yaml",
|
|
}
|
|
| ./tmpl/ex-edge-r/system.tera
|
|
| ./tmpl/ex-edge-r/interfaces.tera
|
|
| ./tmpl/ex-edge-r/protocols.tera
|
|
| ./tmpl/ex-edge-r/policy-options.tera
|
|
Rendering configs:
|
|
| xyz1-ex-edge-r101
|
|
| system.live
|
|
| interfaces.live
|
|
| protocols.live
|
|
| policy-options.live
|
|
| system.shifted
|
|
| interfaces.shifted
|
|
| protocols.shifted
|
|
| policy-options.shifted
|
|
| system.init
|
|
| interfaces.init
|
|
| protocols.init
|
|
| policy-options.init
|
|
Writing Output:
|
|
| ./out/xyz1-ex-edge-r101/live/system.junos
|
|
| ./out/xyz1-ex-edge-r101/live/interfaces.junos
|
|
| ./out/xyz1-ex-edge-r101/live/protocols.junos
|
|
| ./out/xyz1-ex-edge-r101/live/policy-options.junos
|
|
| ./out/xyz1-ex-edge-r101/all.live.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/system.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/interfaces.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/protocols.junos
|
|
| ./out/xyz1-ex-edge-r101/shifted/policy-options.junos
|
|
| ./out/xyz1-ex-edge-r101/all.shifted.junos
|
|
| ./out/xyz1-ex-edge-r101/init/system.junos
|
|
| ./out/xyz1-ex-edge-r101/init/interfaces.junos
|
|
| ./out/xyz1-ex-edge-r101/init/protocols.junos
|
|
| ./out/xyz1-ex-edge-r101/init/policy-options.junos
|
|
| ./out/xyz1-ex-edge-r101/all.init.junos
|
|
| ./out/xyz1-ex-edge-r101/context.yaml
|
|
Completed Successfully
|
|
```
|
|
|
|
## Flamegraph
|
|
|
|
Assume flamelens is installed, otherwise `cargo install flamelens`
|
|
|
|
``` bash
|
|
cd demo
|
|
cargo flamegraph --post-process 'flamelens --echo' --profile profiling -- --devices ".*"
|
|
```
|
|
|
|
## Benchmark
|
|
|
|
Using Demo:
|
|
|
|
``` bash
|
|
process_specs time: [1.2339 ms 1.2399 ms 1.2463 ms]
|
|
```
|