d8134095aba72fd27283fbff55db03ade73de791
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.yamlfile in parent dir and maps the region - Zonal - from the first group of chars in filename up to a
- - Regional - from value of
common.fabricfield inLayerfile - Partitional - from value of
regional.partitionfield inRegionalfile
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
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
$ 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
$ 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
$ 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
cd demo
cargo flamegraph --post-process 'flamelens --echo' --profile profiling -- --devices ".*"
Benchmark
Using Demo:
process_specs time: [1.6096 ms 1.6205 ms 1.6327 ms]
from_spec time: [3.3230 ms 3.3397 ms 3.3575 ms]
Description
Languages
Rust
100%