A Python library for managing VyOS routers
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
vymgmt Added support for pxxsh timeout Jan 31, 2019
README.md Add links to PyPI and ReadTheDocs. Sep 6, 2016
setup.py Proper license headers and metadata. Sep 6, 2016



A python library for executing commands on VyOS systems.

Generic methods should also work with any of the Vyatta descendants (EdgeOS, Brocade vRouter).

The library is compatible with both python2 and python3.

It is released under the MIT license.

How it works

VyMGMT uses pexpect.pxssh library to login to VyOS and execute commands there. This approach has its downsides, but it's better than nothing.

Why is it better than using pxssh or another expect library directly? To make life easier for the user, it provides methods such as set(), delete(), and commit() that detect errors and raise appropriate exceptions when an error occurs.

API reference

...is kept on ReadTheDocs. http://vymgmt.readthedocs.io


The easiest way is to install from PyPI (https://pypi.python.org/pypi):

pip install vymgmt

Alternatively you can run the setup.py script to install it locally.

Usage example

import vymgmt

vyos = vymgmt.Router('', 'vyos', password='vyos', port=22)


vyos.set("protocols static route next-hop")
vyos.delete("system options reboot-on-panic")


If something goes wrong, an exception is raised and the original error message from VyOS is included in its error string:

>>> vyos.set("system foobar true")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../vymgmt/router.py", line 216, in set
    raise ConfigError(output)
vymgmt.router.ConfigError:  set system foobar true

  Configuration path: system [foobar] is not valid
  Set failed


If you want to execute a command that is not yet supported explicitly, you can use run_op_mode_command() and run_conf_mode_command() methods that take a full command and execute it on the other side.


All methods raise a VyOSError exception if you try to use them when the Router object is in a wrong state, such as trying to run configure() before logging in, or trying to run set() before configure().

If something goes wrong on the other side, ConfigError or its subclass CommitError is raised. One special case, ConfigLocked (a subclass of CommitError) is raised when commit fails because there is another commit in progress. It's made a special case because it's the only commit error that can be recovered from easily (just wait a bit and retry).

By default, exit() will not let you exit and will raise a VyOSError is there are uncommited or unsaved changes. You can override it with exit(force=True).


This library was originally written by Hochikong (hochikong@foxmail.com (preferred), or michellehzg@gmail.com), and is now maintained by the VyOS project.