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

feat: Add PortLayout model #24

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
)
Loading