Python 3.4 - Latest version of PYSNMP ( pip --update )
Having issues setting ifAlias values using PYSNMP library. Hoping that someone might be able to shed light on why I'm getting errors in the second function. I've had other eyes on this who have suggested that i may have run into a bug with the library, but I'd rather get more eyes on this first.
I've also posted to the PYSNMP mailing list as well as stackoverflow on this issue. I will close the loop on all three if I find a resolution.
Verified that this OID is setable using a standard MIB browser ( iReasoning )
This one works just fine. You just need to put a string ‘ new sys contact value ‘ in the function and it’s good.
import pysnmp
from pysnmp.entity.rfc3413.oneliner import cmdgen
def SNMP_SET_SYSCONTACT(syscontact):
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(cmdgen.CommunityData('private'), cmdgen.UdpTransportTarget(('10.101.0.221', 161)),(cmdgen.MibVariable('.1.3.6.1.2.1.1.4.0'), syscontact), lookupNames=False, lookupValues=True)
This one doesn’t work at all.
def SNMP_SET_IFALIAS(ifAlias):
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(cmdgen.CommunityData('private'), cmdgen.UdpTransportTarget(('10.101.0.221', 161)),(cmdgen.MibVariable('1.3.6.1.2.1.31.1.1.1.18.1'), ifAlias), lookupValues=False, lookupNames=False)
The error I'm getting back is
Traceback (most recent call last):
File "<pyshell#632>", line 1, in <module>
SNMP_SET_IFALIAS('Check this out')
File "<pyshell#629>", line 2, in SNMP_SET_IFALIAS
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(cmdgen.CommunityData('private'),cmdgen.UdpTransportTarget(('10.101.0.221', 161)),(cmdgen.MibVariable('1.3.6.1.2.1.31.1.1.1.18.1'), ifAlias),lookupValues=False, lookupNames=False)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 452, in setCmd
kwargs.get('contextName', null)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 314, in setCmd
self.makeVarBinds(varBinds),
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 212, in makeVarBinds
varVal = varName.getMibNode().getSyntax().clone(varVal)
AttributeError: 'MibIdentifier' object has no attribute ‘getSyntax'Happy to provide additional information if required,
@netmanchris