Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP plugin fix for single attribute failure #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

praveen-ramamoorthi
Copy link

Why I did it
SNMP plugin fails with "UnboundLocalError: local variable 'snmp_location' referenced before assignment" when only community-ro attribute is specified and vice-versa.

Logs :

Ztp json file :

{
  "ztp": {
     "snmp": {
              "community-ro": "private"
     },
     "restart-ztp-no-config": false
   }
}


Error message:
=============
[10646.574330] sonic-ztp[98907]:   self.stderr = io.open(errread, 'rb', bufsize)
[10646.590245] sonic-ztp[98907]: Traceback (most recent call last):
[10646.590321] sonic-ztp[98907]:   File "/usr/lib/ztp/plugins/snmp", line 149, in <module>
[10646.590407] sonic-ztp[98907]:     snmp.main()
[10646.590437] sonic-ztp[98907]:   File "/usr/lib/ztp/plugins/snmp", line 127, in main
[10646.594205] sonic-ztp[98907]:     if  snmp_location is not None:
[10646.594240] sonic-ztp[98907]: UnboundLocalError: local variable 'snmp_location' referenced before assignment

How I did it
Initialized the community_ro and snmp_location variables to None to avoid issue scenario.

How to verify it
Specify snmp_location or community-ro atrribute alone in ztp json file and verified the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant