Configuration schema

Configuration schema is currently not available in VyOS build - XML schemas are only avaialble in VyOS-1X and once build is created/published, all it remains are compiled chains of node.def files scattered in /opt/vyatta/share/vyatta-cfg/templates/

My need is to pre-validate vyos configuration commands in a browser (js code) before they are pushed to the target VyOS. To do that effectively, we need JSON VyOS Schema so I can validate VyOS JSON configuration.

Best: we agree on JSON Schema for VyOS and package it inside VyOS build
OK: publishing current XML schemas inside VyOS build and convert XML schema to JSON schema on demand
Currently: scan and parse /opt/vyatta/share/vyatta-cfg/templates/ every time config validation is needed, reverse-engineering schema.

Is there a suggested best practice to help with configuration validation? Any future VyOS GUI project will need that.

1 Like

When building vyos-1x package you will get a XML cache definition of all CLI commands.

After build you can check: ./python/build/lib/vyos/xml_ref/pkg_cache/vyos_1x_cache.py or on a running system, vyos.xml_ref package with helper functions.

Some good starters would be:

from vyos.xml_ref import cli_defined
from vyos.xml_ref import default_value

That might give you some live Python code to generate a list of all available commands. Internally we have found a similar issue - see ⚓ T7590 cli: define a helper that generates a list of ALL available op-mode commands to embed in smoketesting maybe both can be handled together.

there are no *.xml_ref on my running Vyos system. I am not looking for schema at the build-time, I need schema at the run time.

admin@backup:~$ show version
Version:          VyOS 2025.06.17-0020-rolling
Release train:    current
Release flavor:   generic

Built by:         [email protected]
Built on:         Tue 17 Jun 2025 00:20 UTC
Build UUID:       aee24877-af3a-4e84-916b-a6c8bff0a8e9
Build commit ID:  3222553a260ae5

Architecture:     x86_64
Boot via:         installed image
System type:      bare metal
Secure Boot:      disabled

Hardware vendor:  Protectli
Hardware model:   FW4B
Hardware S/N:     Default string
Hardware UUID:    03000200-0400-0500-0006-000700080009

Copyright:        VyOS maintainers and contributors

admin@backup:~$ sudo find / -name "*.xml_ref"
admin@backup:~$