Page MenuHomeVyOS Platform

Add VyOS programming library for operational level commands
Closed, ResolvedPublicFEATURE REQUEST

Description

This task deals with a "small" design concept about adding a library for accessing the running configuration from operational level.

By the time of this writing, every time I was facing the issue - to query the current configuration if I can execute an op-mode command or not, I found myself in ending up with a bash script calling cli-shell-api and then mangle the results.

"bad" example:

bash
if cli-shell-api existsActive service ssh; then
    sudo systemctl restart ssh.service
else
    echo "Service SSH not configured"
fi

As time progresses and we might have more complex op-mode scripts we should provide a programming library in Python which at the very least supports:

  • check if a cli node is available or not similar to vyos.config.Config.exists()
  • return the value(s) of CLI nodes and multi-nodes same as vyos.config.Config.exists()
  • execute arbitrary "other" op-mode commands, like "renew dhcp interface eth0"

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
Unspecified (please specify)

Event Timeline

c-po created this task.

Sorry, I have a question, why are there different codes for operation mode fetch configuration tree and configuration mode fetch configuration tree? Is it because of the uncertainty of the mode of action in the user's actions (such as the possibility of abruptly terminating the command)?

jestabro changed the task status from Open to Needs testing.Mar 21 2021, 8:47 PM
jestabro triaged this task as Normal priority.

@jack9603301 It is not a matter of different codes, but rather what python libraries have been provided so far: the focus has been on abstracting the config session, in several directions, and previously there had not been a use case for reading config settings from op mode.

jestabro moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.
c-po set Issue type to Unspecified (please specify).