Paramiko sending commands inconsistently to VyOS

Hi all, so I’m using 2 VyOS nodes and attempting to set up a simple BGP peering configuration and utilising Paramiko with Python 3.
The general idea is that both nodes should peer and then one node will advertise a dummy interface to the other via BGP. However, only a few commands are executed or it seems largely inconsistent in which ones will be properly set and I’m certain that this is not specific to the BGP configuration example either, since sometimes the dummy interface will not be set, other times it will be; it seems to be the actual sending/setting of the commands.

An issue I ran into previously was resolved of a similar nature through the use of the config wrapper prefix (/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper) before a command. Although this doesn’t seem to have brought any consistency in the sending of the commands.

The issue being is that if I execute the commands manually on the VyOS routers, it will work. Doing so through my Python code will be rather inconsistent, sometimes it works and other times it doesn’t, I need it to work all the time and I’m confused as to why is it not.

import paramiko

config_prefix = “/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper”

SSH_Connect = paramiko.SSHClient()
SSH_Connect.connect(hostname=‘THE HOST’, username=‘USERNAME’, key_filename=‘MY SSH KEY PATH’)
SSH_Connect.exec_command("{} {}".format(config_prefix, ‘begin’))
SSH_Connect.exec_command("{} commit".format(config_prefix))
stdin, stdout, stderr = SSH_Connect.exec_command("{} {}".format(config_prefix, ‘COMMANDS ARE REPEATED HERE’))
// Other commands to complete configuration are sent with SSH_Connect.exec_…

for line in iter(stdout.readline, “”):

SSH_Connect.exec_command("{} {}".format(config_prefix, “commit”))

The same is performed via code against the other node with the relevant commands being entered.

Edit: I also tried executing the ‘end’ command after I’ve completed by commands before the commit, but this seemed to make it worse so I removed it.

Any help would be greatly appreciated, it has been bugging me for the past few days.

There’s a reason we’ve used pxssh in Paramiko is a great tool, but it doesn’t work in that case, and we couldn’t find out why—it’s a subtle issue.

The vymgmt package hasn’t seen much use, but when we tried, it worked acceptably well.

However, recent rolling release versions include an HTTP API that removes the need for emulating user sessions over SSH altogether. See

Latest images already include a CLI for setting it up. In the simplest case it’s just:

set service https api keys id myapp key somelongapikey