I am trying fabric to fetch few inputs from cisco Nexus switch and output displaying disconnecting with error
error:
c:\Python27>Scripts\fab.exe -f D:\Python-scripts\nexus-fabric.py sh -H 10.10.10.10 -u admin
[10.10.10.10] Executing task 'sh'
[10.10.10.10] run: terminal length 0
[10.10.10.10] Login password for 'admin':
[10.10.10.10] out: gl_set_term_size: NULL arguments(s).
[10.10.10.10] out:
[10.10.10.10] run: show interface brief
[10.10.10.10] out:
[10.10.10.10] out: ------------------------------------------------------- ------------------------
[10.10.10.10] out: Interface Vsan Admin Admin Status SFP Oper Oper Port
[10.10.10.10] out: Mode Trunk Mode Speed Channel
[10.10.10.10] out: Mode (Gbps)
[10.10.10.10] out: -------------------------------------------------------------------------------
[10.10.10.10] out: fc2/1 4094 auto on sfpAbsent -- -- --
[10.10.10.10] out:
Fatal error: run() received nonzero return code -1 while executing!
Requested: show interface brief
Executed: show interface brief
Aborting.
Disconnecting from 10.10.10.10... done.
code:
from fabric.api import run
def sh():
run("terminal length 0",shell=False)
run("show interface brief",shell=False
I used Pass option still it is failing:
from fabric.api import run
from fabric.api import settings
from fabric.api import warn_only
def sh():
try:
run("show running-config",shell=False)
run("show interface brief",shell=False)
except:
pass
If we run one command i used get output without issues but if i use two run commands second command is terminating with below error
Fatal error: run() received nonzero return code -1 while executing!
I have tried exception as suggested but i am getting below is code and error:
from fabric.api import env,run
from fabric.operations import sudo
class FabricException(Exception):
pass
env.abort_exception = FabricException
# ... set up the rest of the environment...
def sh():
try:
run("show interface brief",shell=False)
run("show running-config",shell=False)
except FabricException:
pass # This is expected, we can continue.
If Please help
Fabric version :
c:\Python27>Scripts\fab.exe --version
Fabric 1.13.1
Paramiko 2.1.2
Python 2.7
please help