Skip to content

Commit

Permalink
Use get_snmp_session_for_profile for write test
Browse files Browse the repository at this point in the history
This just makes the SeedDB write profile test work by delegating
SNMP session establishment to the new get_snmp_session_for_profile
function.
  • Loading branch information
lunkwill42 committed Nov 10, 2023
1 parent 00fcb66 commit 55c77b8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/nav/web/seeddb/page/netbox/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ def get_snmp_read_only_variables(ip_address: str, profile: ManagementProfile):


def snmp_write_test(ip, profile):
"""Test that snmp write works"""
"""Tests that an SNMP profile really has write access.
Tests by fetching sysLocation.0 and setting the same value. This will fail if
the device only allows writing to other parts of its mib view.
"""

testresult = {
'error_message': '',
Expand All @@ -198,11 +202,7 @@ def snmp_write_test(ip, profile):
syslocation = '1.3.6.1.2.1.1.6.0'
value = ''
try:
snmp = Snmp(
ip,
profile.configuration.get("community"),
profile.configuration.get("version"),
)
snmp = get_snmp_session_for_profile(profile)(ip)

Check warning on line 205 in python/nav/web/seeddb/page/netbox/edit.py

View check run for this annotation

Codecov / codecov/patch

python/nav/web/seeddb/page/netbox/edit.py#L205

Added line #L205 was not covered by tests
value = safestring(snmp.get(syslocation))
snmp.set(syslocation, 's', value.encode('utf-8'))
except SnmpError as error:
Expand Down

0 comments on commit 55c77b8

Please sign in to comment.