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 95775ea
Show file tree
Hide file tree
Showing 2 changed files with 65 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,
},
),
]
33 changes: 33 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,36 @@ 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,
help_text="The hardware associated with this PortLayout",
)
network_role = models.ForeignKey(
to="dcim.DeviceRole",
related_name="%(class)s_network_role",
on_delete=models.CASCADE,
help_text="The specific network role this port layout is designed to support.",
)
name = models.CharField(max_length=64, help_text="The generic name assigned to the interface.")
label_name = models.CharField(
max_length=64, help_text="The physical label name of the interface on the device."
)
logical_name = models.CharField(
max_length=64, help_text="The logical name used to identify the interface in the system."
)
vendor_name = models.CharField(
max_length=64, help_text="The vendor-specific name of the interface."
)
vendor_short_name = models.CharField(
max_length=64, help_text="The short vendor-specific name of the interface."
)
vendor_long_name = models.CharField(
max_length=64, help_text="The long vendor-specific name of the interface."
)

0 comments on commit 95775ea

Please sign in to comment.