I'm trying to programmatically update configuration in EdgeOS using a python script. I'm using fabric as an ssh client. https://docs.fabfile.org/en/latest/index.html
Below "---original question---" describes the problem, but I think I've hit on the source of the issue, but not the solution. Fabric ssh's into the router in non-interactive mode, and as such doesn't get the full bash configuration. The
Код: Выделить всё
configureКод: Выделить всё
showКод: Выделить всё
# If not running interactively, don't do anything [ -z "$PS1" ] && return # enable completion source /etc/bash_completion.d/vyatta-cfg source /etc/bash_completion.d/vyatta-op unset HISTFILE Код: Выделить всё
c.run("source /etc/bash_completion.d/vyatta-cfg")---original question---
what I'd like to do is to create small configuration changes such as:
Код: Выделить всё
configure set interfaces ethernet eth2 vif 20 disable commit save Код: Выделить всё
configureКод: Выделить всё
configureКод: Выделить всё
$ configure [edit] # Код: Выделить всё
from fabric import Connection c = Connection('routerip') c.run("configure") Код: Выделить всё
vbash: configure: command not found Traceback (most recent call last): File "", line 1, in File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/decorator.py", line 231, in fun return caller(func, *(extras + args), **kw) File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/fabric/connection.py", line 23, in opens return method(self, *args, **kwargs) File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/fabric/connection.py", line 763, in run return self._run(self._remote_runner(), command, **kwargs) File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/invoke/context.py", line 113, in _run return runner.run(command, **kwargs) File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/fabric/runners.py", line 83, in run return super().run(command, **kwargs) File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/invoke/runners.py", line 395, in run return self._run_body(command, **kwargs) File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/invoke/runners.py", line 451, in _run_body return self.make_promise() if self._asynchronous else self._finish() File "/Users/me/opt/anaconda3/lib/python3.8/site-packages/invoke/runners.py", line 518, in _finish raise UnexpectedExit(result) invoke.exceptions.UnexpectedExit: Encountered a bad command exit code! Command: 'configure' Exit code: 127 Stdout: already printed Stderr: already printed Источник: https://stackoverflow.com/questions/781 ... hon-fabric
Мобильная версия