Skip to content

Commit

Permalink
Update is_snmp and snmp_version properties
Browse files Browse the repository at this point in the history
These need to reflect the existence of the new SNMPv3 profile type.
  • Loading branch information
lunkwill42 committed Nov 2, 2023
1 parent 7e71add commit 7f9b82f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/nav/models/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,18 @@ def __str__(self):

@property
def is_snmp(self):
return self.protocol == self.PROTOCOL_SNMP
return self.protocol in (self.PROTOCOL_SNMP, self.PROTOCOL_SNMPV3)

@property
def snmp_version(self):
"""Returns the configured SNMP version as an integer"""
if self.is_snmp:
if self.protocol == self.PROTOCOL_SNMP:
value = self.configuration['version']
if value == "2c":
return 2
return int(value)
elif self.protocol == self.PROTOCOL_SNMPV3:
return 3

Check warning on line 168 in python/nav/models/manage.py

View check run for this annotation

Codecov / codecov/patch

python/nav/models/manage.py#L167-L168

Added lines #L167 - L168 were not covered by tests

raise ValueError(
"Getting snmp protocol version for non-snmp management profile"
Expand Down

0 comments on commit 7f9b82f

Please sign in to comment.