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

Add OUI model #2896

Merged
merged 11 commits into from
Sep 4, 2024
Merged

Add OUI model #2896

merged 11 commits into from
Sep 4, 2024

Conversation

stveit
Copy link
Contributor

@stveit stveit commented May 2, 2024

Closes #2957

@stveit stveit self-assigned this May 2, 2024
@stveit stveit force-pushed the feature/mac-to-vendor-model branch from c5a0e39 to c70b45f Compare May 2, 2024 11:44
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.36%. Comparing base (0a90566) to head (0029ccb).
Report is 598 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2896      +/-   ##
==========================================
+ Coverage   56.35%   56.36%   +0.01%     
==========================================
  Files         603      604       +1     
  Lines       43862    43858       -4     
  Branches       48       48              
==========================================
+ Hits        24719    24722       +3     
+ Misses      19131    19124       -7     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented May 2, 2024

Test results

     12 files       12 suites   11m 41s ⏱️
3 324 tests 3 324 ✔️ 0 💤 0
9 447 runs  9 447 ✔️ 0 💤 0

Results for commit 1b333b0.

♻️ This comment has been updated with latest results.

@stveit stveit force-pushed the feature/mac-to-vendor-model branch 2 times, most recently from 076cde1 to 0aea33b Compare May 3, 2024 09:28
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.

I think you should consider the option to store the OUI prefix as a regular PostgreSQL macaddr data type, which has several benefits when it comes to indexing, sorting, joining in pure SQL etc.

Just ensure that the last three bytes are always zero (this could also be accomplished by a constraint on the table. The built-in trunc function can also truncate mac address values).

See https://www.postgresql.org/docs/13/datatype-net-types.html and https://www.postgresql.org/docs/13/functions-net.html

@stveit
Copy link
Contributor Author

stveit commented May 3, 2024

Made some changes according to your suggestions

lunkwill42

This comment was marked as duplicate.

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.

Looks ok to me. We would usually put the model in nav.models.manage, since the database object is placed in the manage namespace - but we could really stand to split up this giant module anyway, so let's roll with it.

My only nitpick is the naming of the SQL change file itself. It should follow the established pattern of corresponding with the major.minor of the NAV release we expect it to land in, so it should either be prefixed sc.05.10. or sc.05.11....

@CLAassistant
Copy link

CLAassistant commented Jul 30, 2024

CLA assistant check
All committers have signed the CLA.

@stveit stveit force-pushed the feature/mac-to-vendor-model branch from 53e0791 to 987d886 Compare July 30, 2024 09:48
@stveit stveit force-pushed the feature/mac-to-vendor-model branch from 987d886 to ec34f17 Compare August 8, 2024 12:46
johannaengland

This comment was marked as resolved.

changelog.d/+2896.added.md Outdated Show resolved Hide resolved
python/nav/models/oui.py Outdated Show resolved Hide resolved
stveit and others added 2 commits August 14, 2024 13:52
Co-authored-by: Johanna England <[email protected]>
Co-authored-by: Johanna England <[email protected]>
@stveit
Copy link
Contributor Author

stveit commented Aug 14, 2024

Why do you do the validation of the last three bytes being zero on the SQL level and not earlier how you validated the length before?

We got it super free this way with absolute minimal code and maximum speed. Better to do it with postgres code thats made to do this stuff super fast than manually with slow python code.

The max length might not be necessary tbh since postgres MACADDR type should only allow a valid mac address anyways

@johannaengland
Copy link
Contributor

Why do you do the validation of the last three bytes being zero on the SQL level and not earlier how you validated the length before?

We got it super free this way with absolute minimal code and maximum speed. Better to do it with postgres code thats made to do this stuff super fast than manually with slow python code.

The max length might not be necessary tbh since postgres MACADDR type should only allow a valid mac address anyways

I noticed the comment by @lunkwill42 too late, which is why I hid this comment 😅

@lunkwill42 lunkwill42 self-requested a review August 22, 2024 10:29
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.

Short and sweet!

python/nav/models/oui.py Outdated Show resolved Hide resolved
@stveit stveit merged commit cba5a18 into Uninett:master Sep 4, 2024
12 checks passed
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.

Add new database model to store OUI data
4 participants