Page MenuHomeVyOS Platform

More intelligent config loading scripts
Open, LowPublicFEATURE REQUEST

Description

The config loading utilities found in VyOS only supports replacing the whole configuration of a device and adding commands ,

In this ticket I'll describe some wanted features for a new implementation of these scripts.
These features rely on "modifier tags" that changes the beheavior of the default config parser to add features as overwriting a complete config block or delete it entirely

Feature - Full overwrite of the current configuration
This mode should be able to load an old configuration.
The need for implementing this is for a better rollback mechanism that do not need for the router to reboot in order to activate an old config

No example included.

Feature - Merge/Combine:
Combining two configurations into one.. the config lines in both running and the file will be merged into one configuration… eg:
This mode should be the default mode used if nothing else is explicitly selected

config on device: 
interfaces {
    ethernet eth0 {
        hw-id dc:a6:32:00:80:65
    }
}

config loaded from file:

interfaces {
    ethernet eth0 {
        address dhcp
    }
}

Result:

interfaces {
    ethernet eth0 {
+       address dhcp
        hw-id dc:a6:32:00:80:65
    }
}

Feature - replace/overwrite:
Overwrite a block of config, using "tags" inline in the configuration
The placement of the tag and look of it is only for example usage and does not need to be like described in this example:
config on device:

interfaces {
    ethernet eth0 {
        address dhcp
        hw-id dc:a6:32:00:80:65
    }
}

Loaded config from file:

interfaces {
    overwrite: ethernet eth0 {
        address 10.10.10.1/24
        description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65
    }
}

Result:

interfaces {
    overwrite: ethernet eth0 {
-       address dhcp
+       address 10.10.10.1/24
+       description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65
    }
}

Feature - delete/remove:
Deleting a section makes sure the specified section does not exist in the resulting configuration, or it is "reset" to its default values.
For interfaces ethernet eth# this means that the script removed everything but the hw-id parameter. The reason for leaving this parameter is that it breaks more than it solves to remove it. (the field should never be touched trough config loading scripts)
config on device:

interfaces {
    ethernet eth0 {
        address 10.10.10.1/24
        description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65
    }
}

Loaded config from file:

interfaces {
    delete: ethernet eth0
}
Result:
interfaces {
    ethernet eth0 {
-       address 10.10.10.1/24
-       description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65
    }
}

these tags should be usable both on tag-nodes and normal node.. eg.

interfaces {
    delete: ethernet eth0
}

should be working, and:

interfaces {
    ethernet eth0 {
        delete: address 10.10.10.1/24
    }
}

should also be working.. the last one ensures that the address are deleted from the configuration

Feature - Load config relative to terminal config level
a config load shall use the same relative level as the user is in.. if the user has done a edit interfaces it will know that the user is in interfaces, and accept input relative to that.. eg:
sub-mode:

[edit interfaces]
vyos@vyos# load ###

will accept this:

ethernet eth0 {
    address 10.10.10.1/24
    description 'this is a new cool interface'
    hw-id dc:a6:32:00:80:65
}

and render it to this:

interfaces {
    ethernet eth0 {
        address 10.10.10.1/24
        description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65
    }
}

Feature - Accept configuration on stdin:
The configscript should be startable wher the user gets a primitive sort of read-line with the possibility to input a config from the terminal.
this do not need to be a advanced editor, and something like a cat >file.out will be sufficient in terms of functionality.
Before the prompt the user needs to get enough information about a crude usage of the input method and how to break out of it.
An example:

vyos@vyos# load[enter]
# Input your new configuration and end with ctrl+d to load or ctrl+c to abort
[input from user]
interfaces {
    ethernet eth0 {
        address 10.10.10.1/24
        description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65
    }
}
[END: input from user]
[ctrl+d]
# Loading configuration done successful / or a error on what did not load
# with maybe info on how to abort/retry
vyos@vyos#

Handling ethernet hw-id
As we at the current point of time have the hw-id element in each ethernet/wireless interface, it might be best to disallow the config loader to touch the hw-id element in any way.(except of on initial bootup, maybe with a special parameter?).. changing this node changes the physical interface mapping tables, and that should not be allowed without explicit allowance/directives

Allow multiple tags in one loaded configuration
Also, a configuration should be allowed that uses all the prior noted tags in one load. eg something like this:

interfaces {
    ethernet eth0 {
        # This will be merged
        address 10.10.10.1/24
        description 'this is a new cool interface'
    }
    overwrite: ethernet eth1 {
        # This replaced
        address 10.22.23.1/24
        description 'overwritten special interface'
    }
    # And this deleted
    delete: ethernet eth2
}

Use of regex/whildcards in delete statements
This will depend on the way things are implemented, but it would be nice to allow deletion of configurations with wildcards.
Using this will allow for having eg. multiple prefix-lists with a prefix that will be deleted if they are not used. usage example:
Running configuration

interfaces {
    ethernet eth0 {
        # This will be merged
        address 10.10.10.1/24
        description 'this is a new cool interface'
        hw-id dc:a6:32:00:80:65

    }
    ethernet eth1 {
        # This replaced
        address 10.22.23.1/24
        description 'overwritten special interface'
        hw-id dc:a6:32:00:80:66
    }
}

Loaded config from file:

interfaces {
    delete: ethernet eth*
    ethernet eth0 {
        address 10.1.1.1/24
    }
}

Result:

interfaces {
    ethernet eth0 {
-       address 10.10.10.1/24
+       address 10.1.1.1/24
-       description 'this is a new cool interface'
    }
   ethernet eth1 {
-       address 10.22.23.1/24
-       description 'overwritten special interface'
        hw-id dc:a6:32:00:80:66
    }
}

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Feature (new functionality)

Event Timeline

jestabro renamed this task from More inteligent config loading scripts to More intelligent config loading scripts.Mar 30 2021, 12:12 PM
dmbaturin edited projects, added VyOS 1.5 Circinus; removed VyOS 1.4 Sagitta.
dmbaturin set Issue type to Unspecified (please specify).
jestabro changed Issue type from Unspecified (please specify) to Feature (new functionality).Jan 10 2024, 3:35 PM