Files
skyforge/README.md

5.0 KiB

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

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'
Processing templates for '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

Verbose

$ skyforge -d xyz1-ex-edge-r101 --verbose
Skyforge found 9 renderable devices
Matched 1 devices against 'xyz1-ex-edge-r101'
 | ./spec/xyz/ex-edge-r/xyz1-ex-edge-r101.yaml
Processing templates for 'xyz1-ex-edge-r101'
 | ./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
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

Debug

$ skyforge -d xyz1-ex-edge-r101 --debug
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",
}
Processing templates for 'xyz1-ex-edge-r101'
 | ./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 templates for 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

Flamegraph

Assume flamelens is installed, otherwise cargo install flamelens

cd demo
cargo flamegraph --post-process 'flamelens --echo' --profile profiling -- --devices ".*"