mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 00:28:16 -06:00
Added form factors for console and console server port instances and templates. Added additional serial form factors
This commit is contained in:
parent
de2a894269
commit
df8a9a2c9a
@ -87,6 +87,9 @@ IFACE_FF_T1 = 4000
|
|||||||
IFACE_FF_E1 = 4010
|
IFACE_FF_E1 = 4010
|
||||||
IFACE_FF_T3 = 4040
|
IFACE_FF_T3 = 4040
|
||||||
IFACE_FF_E3 = 4050
|
IFACE_FF_E3 = 4050
|
||||||
|
IFACE_FF_RJ45_S = 4060
|
||||||
|
IFACE_FF_DE9_S = 4070
|
||||||
|
IFACE_FF_DB25_S = 4080
|
||||||
# Stacking
|
# Stacking
|
||||||
IFACE_FF_STACKWISE = 5000
|
IFACE_FF_STACKWISE = 5000
|
||||||
IFACE_FF_STACKWISE_PLUS = 5050
|
IFACE_FF_STACKWISE_PLUS = 5050
|
||||||
@ -96,6 +99,15 @@ IFACE_FF_JUNIPER_VCP = 5200
|
|||||||
# Other
|
# Other
|
||||||
IFACE_FF_OTHER = 32767
|
IFACE_FF_OTHER = 32767
|
||||||
|
|
||||||
|
# Console
|
||||||
|
IFACE_FF_CON_RJ45 = 6000
|
||||||
|
IFACE_FF_CON_DE9 = 6010
|
||||||
|
IFACE_FF_CON_DB25 = 6020
|
||||||
|
IFACE_FF_CON_USB = 6030
|
||||||
|
IFACE_FF_CON_MCUSB = 6040
|
||||||
|
IFACE_FF_CON_MNUSB = 6050
|
||||||
|
IFACE_FF_CON_KVM = 6060
|
||||||
|
|
||||||
IFACE_FF_CHOICES = [
|
IFACE_FF_CHOICES = [
|
||||||
[
|
[
|
||||||
'Virtual interfaces',
|
'Virtual interfaces',
|
||||||
@ -158,6 +170,9 @@ IFACE_FF_CHOICES = [
|
|||||||
[IFACE_FF_E1, 'E1 (2.048 Mbps)'],
|
[IFACE_FF_E1, 'E1 (2.048 Mbps)'],
|
||||||
[IFACE_FF_T3, 'T3 (45 Mbps)'],
|
[IFACE_FF_T3, 'T3 (45 Mbps)'],
|
||||||
[IFACE_FF_E3, 'E3 (34 Mbps)'],
|
[IFACE_FF_E3, 'E3 (34 Mbps)'],
|
||||||
|
[IFACE_FF_RJ45_S, 'RJ45'],
|
||||||
|
[IFACE_FF_DE9_S, 'DE9'],
|
||||||
|
[IFACE_FF_DB25_S, 'DB25'],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -178,6 +193,31 @@ IFACE_FF_CHOICES = [
|
|||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CONSOLE_FF_CHOICES = [
|
||||||
|
[
|
||||||
|
'Console',
|
||||||
|
[
|
||||||
|
[IFACE_FF_CON_RJ45, 'RJ45 Serial'],
|
||||||
|
[IFACE_FF_CON_DE9, 'DE9 Serial'],
|
||||||
|
[IFACE_FF_CON_DB25, 'DB25 Serial'],
|
||||||
|
[IFACE_FF_CON_USB, 'USB to Serial'],
|
||||||
|
[IFACE_FF_CON_MCUSB, 'Micro USB to Serial'],
|
||||||
|
[IFACE_FF_CON_MNUSB, 'Mini USB to Serial'],
|
||||||
|
[IFACE_FF_CON_KVM, 'KVM'],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]
|
||||||
|
|
||||||
|
CONSOLE_IFACE_TYPES = [
|
||||||
|
IFACE_FF_CON_RJ45,
|
||||||
|
IFACE_FF_CON_DE9,
|
||||||
|
IFACE_FF_CON_DB25,
|
||||||
|
IFACE_FF_CON_USB,
|
||||||
|
IFACE_FF_CON_MCUSB,
|
||||||
|
IFACE_FF_CON_MNUSB,
|
||||||
|
IFACE_FF_CON_KVM,
|
||||||
|
]
|
||||||
|
|
||||||
VIRTUAL_IFACE_TYPES = [
|
VIRTUAL_IFACE_TYPES = [
|
||||||
IFACE_FF_VIRTUAL,
|
IFACE_FF_VIRTUAL,
|
||||||
IFACE_FF_LAG,
|
IFACE_FF_LAG,
|
||||||
|
@ -22,7 +22,7 @@ from virtualization.models import Cluster
|
|||||||
from .constants import (
|
from .constants import (
|
||||||
CONNECTION_STATUS_CHOICES, CONNECTION_STATUS_CONNECTED, IFACE_FF_CHOICES, IFACE_FF_LAG, IFACE_ORDERING_CHOICES,
|
CONNECTION_STATUS_CHOICES, CONNECTION_STATUS_CONNECTED, IFACE_FF_CHOICES, IFACE_FF_LAG, IFACE_ORDERING_CHOICES,
|
||||||
RACK_FACE_CHOICES, RACK_TYPE_CHOICES, RACK_WIDTH_CHOICES, RACK_WIDTH_19IN, RACK_WIDTH_23IN, STATUS_CHOICES,
|
RACK_FACE_CHOICES, RACK_TYPE_CHOICES, RACK_WIDTH_CHOICES, RACK_WIDTH_19IN, RACK_WIDTH_23IN, STATUS_CHOICES,
|
||||||
SUBDEVICE_ROLE_CHILD, SUBDEVICE_ROLE_PARENT, SUBDEVICE_ROLE_CHOICES,
|
SUBDEVICE_ROLE_CHILD, SUBDEVICE_ROLE_PARENT, SUBDEVICE_ROLE_CHOICES, CONSOLE_FF_CHOICES
|
||||||
)
|
)
|
||||||
from .formfields import MACAddressFormField
|
from .formfields import MACAddressFormField
|
||||||
from .models import (
|
from .models import (
|
||||||
@ -545,7 +545,7 @@ class ConsolePortTemplateForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsolePortTemplate
|
model = ConsolePortTemplate
|
||||||
fields = ['device_type', 'name']
|
fields = ['device_type', 'name', 'form_factor']
|
||||||
widgets = {
|
widgets = {
|
||||||
'device_type': forms.HiddenInput(),
|
'device_type': forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
@ -553,13 +553,14 @@ class ConsolePortTemplateForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class ConsolePortTemplateCreateForm(ComponentForm):
|
class ConsolePortTemplateCreateForm(ComponentForm):
|
||||||
name_pattern = ExpandableNameField(label='Name')
|
name_pattern = ExpandableNameField(label='Name')
|
||||||
|
form_factor = forms.ChoiceField(choices=CONSOLE_FF_CHOICES)
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsoleServerPortTemplate
|
model = ConsoleServerPortTemplate
|
||||||
fields = ['device_type', 'name']
|
fields = ['device_type', 'name', 'form_factor']
|
||||||
widgets = {
|
widgets = {
|
||||||
'device_type': forms.HiddenInput(),
|
'device_type': forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
@ -567,6 +568,7 @@ class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class ConsoleServerPortTemplateCreateForm(ComponentForm):
|
class ConsoleServerPortTemplateCreateForm(ComponentForm):
|
||||||
name_pattern = ExpandableNameField(label='Name')
|
name_pattern = ExpandableNameField(label='Name')
|
||||||
|
form_factor = forms.ChoiceField(choices=CONSOLE_FF_CHOICES)
|
||||||
|
|
||||||
|
|
||||||
class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
||||||
@ -1083,7 +1085,7 @@ class ConsolePortForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
fields = ['device', 'name']
|
fields = ['device', 'name', 'form_factor']
|
||||||
widgets = {
|
widgets = {
|
||||||
'device': forms.HiddenInput(),
|
'device': forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
@ -1091,6 +1093,7 @@ class ConsolePortForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class ConsolePortCreateForm(ComponentForm):
|
class ConsolePortCreateForm(ComponentForm):
|
||||||
name_pattern = ExpandableNameField(label='Name')
|
name_pattern = ExpandableNameField(label='Name')
|
||||||
|
form_factor = forms.ChoiceField(choices=CONSOLE_FF_CHOICES)
|
||||||
|
|
||||||
|
|
||||||
class ConsoleConnectionCSVForm(forms.ModelForm):
|
class ConsoleConnectionCSVForm(forms.ModelForm):
|
||||||
@ -1252,7 +1255,7 @@ class ConsoleServerPortForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsoleServerPort
|
model = ConsoleServerPort
|
||||||
fields = ['device', 'name']
|
fields = ['device', 'name', 'form_factor']
|
||||||
widgets = {
|
widgets = {
|
||||||
'device': forms.HiddenInput(),
|
'device': forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
@ -1260,6 +1263,7 @@ class ConsoleServerPortForm(BootstrapMixin, forms.ModelForm):
|
|||||||
|
|
||||||
class ConsoleServerPortCreateForm(ComponentForm):
|
class ConsoleServerPortCreateForm(ComponentForm):
|
||||||
name_pattern = ExpandableNameField(label='Name')
|
name_pattern = ExpandableNameField(label='Name')
|
||||||
|
form_factor = forms.ChoiceField(choices=CONSOLE_FF_CHOICES)
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortConnectionForm(BootstrapMixin, ChainedFieldsMixin, forms.Form):
|
class ConsoleServerPortConnectionForm(BootstrapMixin, ChainedFieldsMixin, forms.Form):
|
||||||
|
@ -641,6 +641,7 @@ class ConsolePortTemplate(models.Model):
|
|||||||
"""
|
"""
|
||||||
device_type = models.ForeignKey('DeviceType', related_name='console_port_templates', on_delete=models.CASCADE)
|
device_type = models.ForeignKey('DeviceType', related_name='console_port_templates', on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
|
form_factor = models.PositiveSmallIntegerField(choices=CONSOLE_FF_CHOICES, default=IFACE_FF_CON_RJ45)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['device_type', 'name']
|
ordering = ['device_type', 'name']
|
||||||
@ -657,6 +658,7 @@ class ConsoleServerPortTemplate(models.Model):
|
|||||||
"""
|
"""
|
||||||
device_type = models.ForeignKey('DeviceType', related_name='cs_port_templates', on_delete=models.CASCADE)
|
device_type = models.ForeignKey('DeviceType', related_name='cs_port_templates', on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
|
form_factor = models.PositiveSmallIntegerField(choices=CONSOLE_FF_CHOICES, default=IFACE_FF_CON_RJ45)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['device_type', 'name']
|
ordering = ['device_type', 'name']
|
||||||
@ -961,11 +963,11 @@ class Device(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
# If this is a new Device, instantiate all of the related components per the DeviceType definition
|
# If this is a new Device, instantiate all of the related components per the DeviceType definition
|
||||||
if is_new:
|
if is_new:
|
||||||
ConsolePort.objects.bulk_create(
|
ConsolePort.objects.bulk_create(
|
||||||
[ConsolePort(device=self, name=template.name) for template in
|
[ConsolePort(device=self, name=template.name, form_factor=template.form_factor) for template in
|
||||||
self.device_type.console_port_templates.all()]
|
self.device_type.console_port_templates.all()]
|
||||||
)
|
)
|
||||||
ConsoleServerPort.objects.bulk_create(
|
ConsoleServerPort.objects.bulk_create(
|
||||||
[ConsoleServerPort(device=self, name=template.name) for template in
|
[ConsoleServerPort(device=self, name=template.name, form_factor=template.form_factor) for template in
|
||||||
self.device_type.cs_port_templates.all()]
|
self.device_type.cs_port_templates.all()]
|
||||||
)
|
)
|
||||||
PowerPort.objects.bulk_create(
|
PowerPort.objects.bulk_create(
|
||||||
@ -1063,6 +1065,7 @@ class ConsolePort(models.Model):
|
|||||||
"""
|
"""
|
||||||
device = models.ForeignKey('Device', related_name='console_ports', on_delete=models.CASCADE)
|
device = models.ForeignKey('Device', related_name='console_ports', on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
|
form_factor = models.PositiveSmallIntegerField(choices=CONSOLE_FF_CHOICES, default=IFACE_FF_CON_RJ45)
|
||||||
cs_port = models.OneToOneField('ConsoleServerPort', related_name='connected_console', on_delete=models.SET_NULL,
|
cs_port = models.OneToOneField('ConsoleServerPort', related_name='connected_console', on_delete=models.SET_NULL,
|
||||||
verbose_name='Console server port', blank=True, null=True)
|
verbose_name='Console server port', blank=True, null=True)
|
||||||
connection_status = models.NullBooleanField(choices=CONNECTION_STATUS_CHOICES, default=CONNECTION_STATUS_CONNECTED)
|
connection_status = models.NullBooleanField(choices=CONNECTION_STATUS_CHOICES, default=CONNECTION_STATUS_CONNECTED)
|
||||||
@ -1113,6 +1116,7 @@ class ConsoleServerPort(models.Model):
|
|||||||
"""
|
"""
|
||||||
device = models.ForeignKey('Device', related_name='cs_ports', on_delete=models.CASCADE)
|
device = models.ForeignKey('Device', related_name='cs_ports', on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
|
form_factor = models.PositiveSmallIntegerField(choices=CONSOLE_FF_CHOICES, default=IFACE_FF_CON_RJ45)
|
||||||
|
|
||||||
objects = ConsoleServerPortManager()
|
objects = ConsoleServerPortManager()
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ class ConsolePortTemplateTable(BaseTable):
|
|||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = ConsolePortTemplate
|
model = ConsolePortTemplate
|
||||||
fields = ('pk', 'name')
|
fields = ('pk', 'name', 'form_factor')
|
||||||
empty_text = "None"
|
empty_text = "None"
|
||||||
|
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ class ConsoleServerPortTemplateTable(BaseTable):
|
|||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = ConsoleServerPortTemplate
|
model = ConsoleServerPortTemplate
|
||||||
fields = ('pk', 'name')
|
fields = ('pk', 'name', 'form_factor')
|
||||||
empty_text = "None"
|
empty_text = "None"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user