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

Avoid exception on adding ip device with wrong ip/hostname #2713

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/nav/Snmp/pynetsnmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from pynetsnmp import netsnmp
from pynetsnmp.netsnmp import (
Session,
SnmpError as PynetSnmpError,
SNMP_MSG_GETNEXT,
mkoid,
lib,
Expand Down Expand Up @@ -107,7 +108,10 @@
self.timeout = timeout

self.handle = _MySnmpSession(self._build_cmdline())
self.handle.open()
try:
self.handle.open()
except PynetSnmpError:
raise SnmpError

Check warning on line 114 in python/nav/Snmp/pynetsnmp.py

View check run for this annotation

Codecov / codecov/patch

python/nav/Snmp/pynetsnmp.py#L113-L114

Added lines #L113 - L114 were not covered by tests

def _build_cmdline(self):
try:
Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/seeddb/page/netbox/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@

def snmp_type(ip_addr, snmp_ro, snmp_version):
"""Query ip for sysobjectid using form data"""
snmp = Snmp(ip_addr, snmp_ro, snmp_version)
try:
snmp = Snmp(ip_addr, snmp_ro, snmp_version)

Check warning on line 269 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#L269

Added line #L269 was not covered by tests
sysobjectid = snmp.get('.1.3.6.1.2.1.1.2.0')
except SnmpError:
return None
Expand Down
Loading