Skip to content

Commit

Permalink
Add OUI model
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed May 2, 2024
1 parent a2be786 commit c5a0e39
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions python/nav/models/oui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.forms import CharField
from django.db import models
from django.core.exceptions import ValidationError
from django.core.validators import MinLengthValidator

from nav.models.fields import VarcharField


class OUI(models.Model):
"""Defines an OUI and the name of the vendor the OUI belongs to"""

vendor = VarcharField()
oui = models.CharField(
max_length=6, unique=True, validators=[MinLengthValidator(6)]
)

def __str__(self):
return self.oui

class Meta(object):
db_table = 'oui'
5 changes: 5 additions & 0 deletions python/nav/models/sql/changes/sc.05.08.0001.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE oui (
id SERIAL PRIMARY KEY,
vendor VARCHAR NOT NULL,
oui CHAR(6) NOT NULL UNIQUE
);

0 comments on commit c5a0e39

Please sign in to comment.