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

Fix scripts so they no longer use Netbox.snmp_version #2429

Merged
merged 5 commits into from
Nov 30, 2022

Conversation

johannaengland
Copy link
Contributor

@johannaengland johannaengland commented Jun 22, 2022

Fixes #2389.

Introduces a new function get_preferred_snmp_management_profile that return the profile with the highest snmp version, which then can be used to get the profiles snmp version or community.

Also replaces the occurrences of netbox.read_only, netbox.read_write and netbox.snmp_version using the new function everywhere expect in ipdevpoll. In ipdevpoll it is not clear yet how to do that since shadow classes are used there, which only copy the attributes, but not functions.

@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #2429 (463bc8e) into master (f34e308) will decrease coverage by 0.01%.
The diff coverage is 68.88%.

❗ Current head 463bc8e differs from pull request most recent head 81f5ff6. Consider uploading reports for the commit 81f5ff6 to get more accurate results

@@            Coverage Diff             @@
##           master    #2429      +/-   ##
==========================================
- Coverage   53.34%   53.33%   -0.02%     
==========================================
  Files         554      554              
  Lines       40315    40349      +34     
==========================================
+ Hits        21507    21520      +13     
- Misses      18808    18829      +21     
Impacted Files Coverage Δ
python/nav/web/portadmin/views.py 14.97% <0.00%> (ø)
python/nav/arnold.py 57.61% <45.45%> (-0.11%) ⬇️
python/nav/portadmin/snmp/base.py 46.85% <78.57%> (+1.60%) ⬆️
python/nav/models/manage.py 71.53% <83.33%> (+0.37%) ⬆️
python/nav/mibs/netswitch_mib.py 70.00% <0.00%> (-30.00%) ⬇️
python/nav/mibs/cisco_memory_pool_mib.py 78.57% <0.00%> (-21.43%) ⬇️
python/nav/mibs/juniper_mib.py 40.17% <0.00%> (-8.04%) ⬇️
python/nav/Snmp/pynetsnmp.py 54.58% <0.00%> (+0.43%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Jun 22, 2022

Test results

     12 files       12 suites   11m 36s ⏱️
3 111 tests 3 015 ✔️   96 💤 0
8 808 runs  8 520 ✔️ 288 💤 0

Results for commit 4f8d90e.

♻️ This comment has been updated with latest results.

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly sound, except for a few questionable bits :)

bin/naventity Outdated Show resolved Hide resolved
python/nav/web/portadmin/views.py Outdated Show resolved Hide resolved
python/nav/portadmin/snmp/base.py Outdated Show resolved Hide resolved
bin/navsnmp Outdated Show resolved Hide resolved
bin/navsnmp Outdated Show resolved Hide resolved
python/nav/arnold.py Outdated Show resolved Hide resolved
python/nav/portadmin/snmp/base.py Outdated Show resolved Hide resolved
python/nav/portadmin/snmp/base.py Outdated Show resolved Hide resolved
@johannaengland johannaengland requested a review from lunkwill42 July 1, 2022 09:24
@johannaengland johannaengland force-pushed the snmp-version branch 3 times, most recently from c4a949b to fb0d969 Compare July 1, 2022 10:31
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New issues introduced (and, still quite hard to figure out what changed since my last review when you force push or rebase your changes - I have to read everything all over again)

bin/naventity Outdated Show resolved Hide resolved
bin/navoidverify Outdated Show resolved Hide resolved
python/nav/arnold.py Outdated Show resolved Hide resolved
python/nav/portadmin/snmp/base.py Outdated Show resolved Hide resolved
bin/navsnmp Outdated Show resolved Hide resolved
python/nav/portadmin/snmp/base.py Outdated Show resolved Hide resolved
@johannaengland johannaengland requested a review from lunkwill42 July 7, 2022 14:21
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is definitely still broken here.

Using data from our lokalnav installation, these are my interactions with the navsnmp command from this PR:

$ navsnmp buick
buick.lab.uninett.no has no valid SNMP configuration in NAV

This is patently false, the lab switch buick does indeed have a valid SNMP profile.

Then there is one device whose name starts with ups, which also has a valid SNMP profile, and yet, I get this:

$ navsnmp ups
Traceback (most recent call last):
  File "/usr/local/bin/navsnmp", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/source/bin/navsnmp", line 98, in <module>
    main()
  File "/source/bin/navsnmp", line 38, in main
    snmp_printer(netbox)
  File "/source/bin/navsnmp", line 74, in snmp_printer
    if profile.snmp_version == 1:
AttributeError: 'NoneType' object has no attribute 'snmp_version'

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things seem to work nicely now - I just have one question/nitpick :)

python/nav/models/manage.py Outdated Show resolved Hide resolved
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well okay then :) Just a bit of rebase magic and you are good to go!

Also add functions to get snmp community or version from it
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@johannaengland johannaengland merged commit d035781 into Uninett:master Nov 30, 2022
@johannaengland johannaengland deleted the snmp-version branch November 30, 2022 09:50
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.

Fix scripts so they no longer use Netbox.snmp_version
2 participants