-
Notifications
You must be signed in to change notification settings - Fork 1
File Output
This page explains how dot2net generates and controls output files.
File output in dot2net is controlled by two key concepts:
| Concept | Role |
|---|---|
| FileDefinition | Defines file properties (name, path, output location) |
| ConfigTemplate.file | Associates a template with a file for output |
FileDefinitions declare output files with their properties:
file:
- name: frr.conf
path: /etc/frr/frr.conf # Container path (for bind mounts)
- name: startup
output: root # Output to lab root directory
name_suffix: .startup # Results in "r1.startup", "r2.startup"| Field | Description | Default |
|---|---|---|
name |
File identifier (referenced by ConfigTemplate.file) | Required |
path |
Target path inside container (used for bind mounts) | "" |
scope |
network or node - determines file generation scope |
node |
output |
root or node - output directory location |
Inferred from scope |
name_prefix |
Prefix for output filename | "" |
name_suffix |
Suffix for output filename | "" |
The output field controls where files are placed:
output_directory/
├── topo.yaml # scope: network (always in root)
├── r1.startup # scope: node, output: root
├── r2.startup # scope: node, output: root
├── r1/
│ └── frr.conf # scope: node, output: node (default)
└── r2/
└── frr.conf
Examples:
file:
# Traditional: node config in subdirectory
- name: frr.conf
path: /etc/frr/frr.conf
# output: node (default for node scope)
# Kathara-style: startup files in root with node name
- name: startup
output: root
name_suffix: .startup
# Results: r1.startup, r2.startup in root
# Network-scope file (always in root)
- name: topo.yaml
scope: networkWhen name_prefix or name_suffix is set, the filename is constructed as:
{name_prefix}{object_name}{name_suffix}
| Configuration | Object | Result |
|---|---|---|
name_suffix: .startup |
r1 | r1.startup |
name_prefix: config_ |
r1 | config_r1 |
name_prefix: init_, name_suffix: .sh |
r1 | init_r1.sh |
If neither prefix nor suffix is set, the name field is used as the filename.
A ConfigTemplate generates output to a file when it has a file attribute:
nodeclass:
- name: router
config:
- name: frr_config
file: frr.conf # Output to this file
template:
- "hostname {{ .name }}"
- "!"A file is generated for an object only if:
- The object has a ConfigTemplate with matching
fileattribute - The ConfigTemplate conditions are satisfied (required_params, class conditions, etc.)
This means different nodes can generate different sets of files based on their class configurations.
The path field specifies the target path inside containers. When using modules like Containerlab or TiNET, files with path defined are automatically added to bind mount configurations.
file:
- name: frr.conf
path: /etc/frr/frr.conf # Mounted as: r1/frr.conf:/etc/frr/frr.confOnly files that a node actually generates (based on class configuration) are included in bind mounts. See Module System for details.
- YAML Configuration - Files Configuration
- Module System - How modules use file definitions
- Template System - Template syntax for file content