Skip to content

Commit

Permalink
feat: Add PortLayout model
Browse files Browse the repository at this point in the history
  • Loading branch information
djothi committed Dec 16, 2024
1 parent 75273f1 commit 8a4edcd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
32 changes: 32 additions & 0 deletions netbox_cmdb/netbox_cmdb/migrations/0041_portlayout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('dcim', '0161_cabling_cleanup'),
('netbox_cmdb', '0040_snmpcommunity_snmp'),
]

operations = [
migrations.CreateModel(
name='PortLayout',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True, null=True)),
('last_updated', models.DateTimeField(auto_now=True, null=True)),
('name', models.CharField(max_length=64)),
('label_name', models.CharField(max_length=64)),
('logical_name', models.CharField(max_length=64)),
('vendor_name', models.CharField(max_length=64)),
('vendor_short_name', models.CharField(max_length=64)),
('vendor_long_name', models.CharField(max_length=64)),
('device_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_device_type', to='dcim.devicetype')),
('network_role', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_network_role', to='dcim.devicerole')),
],
options={
'abstract': False,
},
),
]
17 changes: 17 additions & 0 deletions netbox_cmdb/netbox_cmdb/models/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,20 @@ def save(self, *args, **kwargs):

class Meta:
unique_together = ("index", "parent_interface")


class PortLayout(ChangeLoggedModel):
"""A port layout configuration on a Network device."""

device_type = models.ForeignKey(
to="dcim.DeviceType", related_name="%(class)s_device_type", on_delete=models.CASCADE
)
network_role = models.ForeignKey(
to="dcim.DeviceRole", related_name="%(class)s_network_role", on_delete=models.CASCADE
)
name = models.CharField(max_length=64)
label_name = models.CharField(max_length=64)
logical_name = models.CharField(max_length=64)
vendor_name = models.CharField(max_length=64)
vendor_short_name = models.CharField(max_length=64)
vendor_long_name = models.CharField(max_length=64)

0 comments on commit 8a4edcd

Please sign in to comment.