PackeTsar / freeztp

An Open-Source Zero-Touch Provisioning System for Cisco IOS.
GNU General Public License v3.0
214 stars 28 forks source link

SNMP Queries Fail - Caused by dependency update #98

Open pschapman opened 1 year ago

pschapman commented 1 year ago

Symptom: Target switch gets default config instead of final configuration. Testing SNMP query with ztp request snmp-test <ip> results in python traceback (shown below).

Cause: Upstream dependency for pysnmp has been updated (pyasn1).

Workaround: Downgrade pyasn1 to version 0.4.8.

pip uninstall pyasn1
pip install pyasn1==0.4.8
ztp service restart

Error Message

root@ubuntu22server:~# ztp request snmp-test 172.27.32.22

Hit CTRL+C to kill the SNMP query test

Querying 172.27.32.22 using community (secretcommunity) and OID ({u'C2960_SERIAL': u'1.3.6.1.2.1.47.1.1.1.1.11.1001', u'C3xx0_SERIAL': u'1.3.6.1.2.1.47.1.1.1.1.11.1000', u'C9x00_SERIAL': u'1.3.6.1.2.1.47.1.1.1.1.11.2000'})

2023-06-08 00:19:54:   snmp_query._query_worker: Attempting SNMP Query

2023-06-08 00:19:54:   snmp_query._query_worker: Attempting SNMP Query

2023-06-08 00:19:54:   snmp_query._query_worker: Attempting SNMP Query

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/bin/ztp", line 787, in _query_worker
    response = self._get_oid(oid)
  File "/usr/bin/ztp", line 807, in _get_oid
    pysnmp.hlapi.ObjectType(pysnmp.hlapi.ObjectIdentity(oid)))
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 113, in getCmd
    snmpEngine.transportDispatcher.runDispatcher()
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher
    raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())))
PySnmpError: poll error: Traceback (most recent call last):
;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher
    use_poll=True, map=self.__sockMap, count=1)
;  File "/usr/lib/python2.7/asyncore.py", line 220, in loop
    poll_fun(timeout, map)
;  File "/usr/lib/python2.7/asyncore.py", line 201, in poll2
    readwrite(obj, flags)
;  File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite
    obj.handle_error()
;  File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite
    obj.handle_read_event()
;  File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read
    self._cbFun(self, transportAddress, incomingMessage)
;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 85, in _cbFun
    self, transportDomain, transportAddress, incomingMessage
;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun
    self, transportDomain, transportAddress, wholeMsg
;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 291, in receiveMessage
    msgVersion = verdec.decodeMessageVersion(wholeMsg)
;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/api/verdec.py", line 17, in decodeMessageVersion
    recursiveFlag=False, substrateFun=lambda a, b, c: (a, b[:c])
;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 2003, in __call__
    for asn1Object in streamingDecoder:
;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 1919, in __iter__
    self._substrate, self._asn1Spec, **self._options):
;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 1781, in __call__
    self, substrateFun, **options):
;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 654, in valueDecoder
    for chunk in substrateFun(asn1Object, substrate, length, options):
;TypeError: <lambda>() takes exactly 3 arguments (4 given)
caused by <type 'exceptions.TypeError'>: <lambda>() takes exactly 3 arguments (4 given)
GSGBen commented 1 year ago

Thanks for the fix!