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

Make get_enterprise_id more flexible when parsing sysObjectID values #2656

Closed
lunkwill42 opened this issue Aug 9, 2023 · 3 comments · Fixed by #2658
Closed

Make get_enterprise_id more flexible when parsing sysObjectID values #2656

lunkwill42 opened this issue Aug 9, 2023 · 3 comments · Fixed by #2658
Assignees

Comments

@lunkwill42
Copy link
Member

Although #2566 was fixed, there is still the unsolved problem that some installations may still have "broken" sysObjectID values in the NetboxType table.

There are actually two duplicate implementations of get_enterprise_id() - one for models.Netbox and one for shadows.Netbox. Only the first is mentioned in #2566, but both should be fixed:

          This method explicitly only checks for a non-dotted enterprise prefix:

def get_enterprise_id(self):
"""Returns the type's enterprise ID as an integer.
The type's sysobjectid should always start with
SNMPv2-SMI::enterprises (1.3.6.1.4.1). The next OID element will be
an enterprise ID, while the remaining elements will describe the type
specific to the vendor.
"""
prefix = u"1.3.6.1.4.1."
if self.sysobjectid.startswith(prefix):
specific = self.sysobjectid[len(prefix) :]
enterprise = specific.split('.')[0]
return int(enterprise)

Originally posted by @lunkwill42 in #2566 (comment)

@lunkwill42
Copy link
Member Author

An improved version of these methods should use the nav.oids.OID class for OID comparisons and prefix tests..

@hmpf
Copy link
Contributor

hmpf commented Aug 14, 2023

If there are bogus data in the database we should probably fix it in the database as well, for consistency.

@lunkwill42
Copy link
Member Author

If there are bogus data in the database we should probably fix it in the database as well, for consistency.

We did discuss that, but the data itself isn't really bogus - it's just that parts of NAV were very picky about the formatting of the string (it did not accept data with a leading ., even though that is the most common way to write out an OID).

#2658 fixes this so that even said "bogus" data would be parsed just fine.

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 a pull request may close this issue.

3 participants