-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
netbox_cmdb/netbox_cmdb/migrations/0036_deviceinterface.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dcim', '0161_cabling_cleanup'), | ||
('netbox_cmdb', '0035_vlan'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='DeviceInterface', | ||
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=100)), | ||
('enabled', models.BooleanField(default=True)), | ||
('state', models.CharField(default='staging', max_length=50)), | ||
('monitoring_state', models.CharField(default='disabled', max_length=50)), | ||
('autonegotiation', models.BooleanField(default=True)), | ||
('speed', models.PositiveIntegerField(blank=True, null=True)), | ||
('fec', models.CharField(blank=True, max_length=5, null=True)), | ||
('description', models.CharField(blank=True, max_length=100, null=True)), | ||
('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)sdevice', to='dcim.device')), | ||
], | ||
options={ | ||
'unique_together': {('device', 'name')}, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from django.db import models | ||
from netbox_cmdb.choices import AssetStateChoices, AssetMonitoringStateChoices | ||
from netbox.models import ChangeLoggedModel | ||
|
||
FEC_CHOICES = [ | ||
(None, "None"), | ||
("rs", "Reed Solomon"), | ||
("fc", "FireCode"), | ||
] | ||
|
||
|
||
class DeviceInterface(ChangeLoggedModel): | ||
"""A device interface configuration.""" | ||
|
||
name = models.CharField(max_length=100) | ||
enabled = models.BooleanField(default=True) | ||
state = models.CharField( | ||
max_length=50, | ||
choices=AssetStateChoices, | ||
default=AssetStateChoices.STATE_STAGING, | ||
help_text="State of this DeviceInterface", | ||
) | ||
monitoring_state = models.CharField( | ||
max_length=50, | ||
choices=AssetMonitoringStateChoices, | ||
default=AssetMonitoringStateChoices.DISABLED, | ||
help_text="Monitoring state of this DeviceInterface", | ||
) | ||
device = models.ForeignKey( | ||
to="dcim.Device", | ||
on_delete=models.CASCADE, | ||
related_name="%(class)sdevice", | ||
null=False, | ||
blank=False, | ||
) | ||
autonegotiation = models.BooleanField(default=True) | ||
speed = models.PositiveIntegerField( | ||
blank=True, | ||
null=True, | ||
help_text="Interface speed in kb/s", | ||
) | ||
fec = models.CharField( | ||
choices=FEC_CHOICES, | ||
max_length=5, | ||
blank=True, | ||
null=True, | ||
) | ||
description = models.CharField(max_length=100, blank=True, null=True) | ||
|
||
def __str__(self): | ||
return f"{self.device.name}--{self.name}" | ||
|
||
class Meta: | ||
unique_together = ("device", "name") |