|
@@ -1,7 +1,7 @@
|
|
|
from django import forms
|
|
from django import forms
|
|
|
-from django.contrib.auth.models import User
|
|
|
|
|
|
|
+from django.contrib.auth import get_user_model
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
-from django.utils.translation import gettext as _
|
|
|
|
|
|
|
+from django.utils.translation import gettext_lazy as _
|
|
|
from timezone_field import TimeZoneFormField
|
|
from timezone_field import TimeZoneFormField
|
|
|
|
|
|
|
|
from dcim.choices import *
|
|
from dcim.choices import *
|
|
@@ -70,13 +70,14 @@ __all__ = (
|
|
|
|
|
|
|
|
class RegionForm(NetBoxModelForm):
|
|
class RegionForm(NetBoxModelForm):
|
|
|
parent = DynamicModelChoiceField(
|
|
parent = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Parent'),
|
|
|
queryset=Region.objects.all(),
|
|
queryset=Region.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Region', (
|
|
|
|
|
|
|
+ (_('Region'), (
|
|
|
'parent', 'name', 'slug', 'description', 'tags',
|
|
'parent', 'name', 'slug', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -90,13 +91,14 @@ class RegionForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class SiteGroupForm(NetBoxModelForm):
|
|
class SiteGroupForm(NetBoxModelForm):
|
|
|
parent = DynamicModelChoiceField(
|
|
parent = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Parent'),
|
|
|
queryset=SiteGroup.objects.all(),
|
|
queryset=SiteGroup.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Site Group', (
|
|
|
|
|
|
|
+ (_('Site Group'), (
|
|
|
'parent', 'name', 'slug', 'description', 'tags',
|
|
'parent', 'name', 'slug', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -110,10 +112,12 @@ class SiteGroupForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class SiteForm(TenancyForm, NetBoxModelForm):
|
|
class SiteForm(TenancyForm, NetBoxModelForm):
|
|
|
region = DynamicModelChoiceField(
|
|
region = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Region'),
|
|
|
queryset=Region.objects.all(),
|
|
queryset=Region.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
group = DynamicModelChoiceField(
|
|
group = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Group'),
|
|
|
queryset=SiteGroup.objects.all(),
|
|
queryset=SiteGroup.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
@@ -124,17 +128,18 @@ class SiteForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
)
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
time_zone = TimeZoneFormField(
|
|
time_zone = TimeZoneFormField(
|
|
|
|
|
+ label=_('Time zone'),
|
|
|
choices=add_blank_choice(TimeZoneFormField().choices),
|
|
choices=add_blank_choice(TimeZoneFormField().choices),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Site', (
|
|
|
|
|
|
|
+ (_('Site'), (
|
|
|
'name', 'slug', 'status', 'region', 'group', 'facility', 'asns', 'time_zone', 'description', 'tags',
|
|
'name', 'slug', 'status', 'region', 'group', 'facility', 'asns', 'time_zone', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
- ('Tenancy', ('tenant_group', 'tenant')),
|
|
|
|
|
- ('Contact Info', ('physical_address', 'shipping_address', 'latitude', 'longitude')),
|
|
|
|
|
|
|
+ (_('Tenancy'), ('tenant_group', 'tenant')),
|
|
|
|
|
+ (_('Contact Info'), ('physical_address', 'shipping_address', 'latitude', 'longitude')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -159,10 +164,12 @@ class SiteForm(TenancyForm, NetBoxModelForm):
|
|
|
|
|
|
|
|
class LocationForm(TenancyForm, NetBoxModelForm):
|
|
class LocationForm(TenancyForm, NetBoxModelForm):
|
|
|
site = DynamicModelChoiceField(
|
|
site = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Site'),
|
|
|
queryset=Site.objects.all(),
|
|
queryset=Site.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
parent = DynamicModelChoiceField(
|
|
parent = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Parent'),
|
|
|
queryset=Location.objects.all(),
|
|
queryset=Location.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -172,8 +179,8 @@ class LocationForm(TenancyForm, NetBoxModelForm):
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Location', ('site', 'parent', 'name', 'slug', 'status', 'description', 'tags')),
|
|
|
|
|
- ('Tenancy', ('tenant_group', 'tenant')),
|
|
|
|
|
|
|
+ (_('Location'), ('site', 'parent', 'name', 'slug', 'status', 'description', 'tags')),
|
|
|
|
|
+ (_('Tenancy'), ('tenant_group', 'tenant')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -187,7 +194,7 @@ class RackRoleForm(NetBoxModelForm):
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Rack Role', (
|
|
|
|
|
|
|
+ (_('Rack Role'), (
|
|
|
'name', 'slug', 'color', 'description', 'tags',
|
|
'name', 'slug', 'color', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -201,10 +208,12 @@ class RackRoleForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class RackForm(TenancyForm, NetBoxModelForm):
|
|
class RackForm(TenancyForm, NetBoxModelForm):
|
|
|
site = DynamicModelChoiceField(
|
|
site = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Site'),
|
|
|
queryset=Site.objects.all(),
|
|
queryset=Site.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
location = DynamicModelChoiceField(
|
|
location = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Location'),
|
|
|
queryset=Location.objects.all(),
|
|
queryset=Location.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -212,6 +221,7 @@ class RackForm(TenancyForm, NetBoxModelForm):
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
role = DynamicModelChoiceField(
|
|
role = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Role'),
|
|
|
queryset=RackRole.objects.all(),
|
|
queryset=RackRole.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
@@ -221,30 +231,33 @@ class RackForm(TenancyForm, NetBoxModelForm):
|
|
|
model = Rack
|
|
model = Rack
|
|
|
fields = [
|
|
fields = [
|
|
|
'site', 'location', 'name', 'facility_id', 'tenant_group', 'tenant', 'status', 'role', 'serial',
|
|
'site', 'location', 'name', 'facility_id', 'tenant_group', 'tenant', 'status', 'role', 'serial',
|
|
|
- 'asset_tag', 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit',
|
|
|
|
|
- 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
|
|
|
|
|
|
+ 'asset_tag', 'type', 'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth',
|
|
|
|
|
+ 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
class RackReservationForm(TenancyForm, NetBoxModelForm):
|
|
class RackReservationForm(TenancyForm, NetBoxModelForm):
|
|
|
rack = DynamicModelChoiceField(
|
|
rack = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Rack'),
|
|
|
queryset=Rack.objects.all(),
|
|
queryset=Rack.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
units = NumericArrayField(
|
|
units = NumericArrayField(
|
|
|
|
|
+ label=_('Units'),
|
|
|
base_field=forms.IntegerField(),
|
|
base_field=forms.IntegerField(),
|
|
|
help_text=_("Comma-separated list of numeric unit IDs. A range may be specified using a hyphen.")
|
|
help_text=_("Comma-separated list of numeric unit IDs. A range may be specified using a hyphen.")
|
|
|
)
|
|
)
|
|
|
user = forms.ModelChoiceField(
|
|
user = forms.ModelChoiceField(
|
|
|
- queryset=User.objects.order_by(
|
|
|
|
|
|
|
+ label=_('User'),
|
|
|
|
|
+ queryset=get_user_model().objects.order_by(
|
|
|
'username'
|
|
'username'
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Reservation', ('rack', 'units', 'user', 'description', 'tags')),
|
|
|
|
|
- ('Tenancy', ('tenant_group', 'tenant')),
|
|
|
|
|
|
|
+ (_('Reservation'), ('rack', 'units', 'user', 'description', 'tags')),
|
|
|
|
|
+ (_('Tenancy'), ('tenant_group', 'tenant')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -258,7 +271,7 @@ class ManufacturerForm(NetBoxModelForm):
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Manufacturer', (
|
|
|
|
|
|
|
+ (_('Manufacturer'), (
|
|
|
'name', 'slug', 'description', 'tags',
|
|
'name', 'slug', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -272,23 +285,26 @@ class ManufacturerForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class DeviceTypeForm(NetBoxModelForm):
|
|
class DeviceTypeForm(NetBoxModelForm):
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
manufacturer = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Manufacturer'),
|
|
|
queryset=Manufacturer.objects.all()
|
|
queryset=Manufacturer.objects.all()
|
|
|
)
|
|
)
|
|
|
default_platform = DynamicModelChoiceField(
|
|
default_platform = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Default platform'),
|
|
|
queryset=Platform.objects.all(),
|
|
queryset=Platform.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
slug = SlugField(
|
|
slug = SlugField(
|
|
|
|
|
+ label=_('Slug'),
|
|
|
slug_source='model'
|
|
slug_source='model'
|
|
|
)
|
|
)
|
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Device Type', ('manufacturer', 'model', 'slug', 'default_platform', 'description', 'tags')),
|
|
|
|
|
- ('Chassis', (
|
|
|
|
|
|
|
+ (_('Device Type'), ('manufacturer', 'model', 'slug', 'default_platform', 'description', 'tags')),
|
|
|
|
|
+ (_('Chassis'), (
|
|
|
'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit',
|
|
'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit',
|
|
|
)),
|
|
)),
|
|
|
- ('Images', ('front_image', 'rear_image')),
|
|
|
|
|
|
|
+ (_('Images'), ('front_image', 'rear_image')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -310,13 +326,14 @@ class DeviceTypeForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class ModuleTypeForm(NetBoxModelForm):
|
|
class ModuleTypeForm(NetBoxModelForm):
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
manufacturer = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Manufacturer'),
|
|
|
queryset=Manufacturer.objects.all()
|
|
queryset=Manufacturer.objects.all()
|
|
|
)
|
|
)
|
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Module Type', ('manufacturer', 'model', 'part_number', 'description', 'tags')),
|
|
|
|
|
- ('Weight', ('weight', 'weight_unit'))
|
|
|
|
|
|
|
+ (_('Module Type'), ('manufacturer', 'model', 'part_number', 'description', 'tags')),
|
|
|
|
|
+ (_('Weight'), ('weight', 'weight_unit'))
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -328,13 +345,14 @@ class ModuleTypeForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class DeviceRoleForm(NetBoxModelForm):
|
|
class DeviceRoleForm(NetBoxModelForm):
|
|
|
config_template = DynamicModelChoiceField(
|
|
config_template = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Config template'),
|
|
|
queryset=ConfigTemplate.objects.all(),
|
|
queryset=ConfigTemplate.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Device Role', (
|
|
|
|
|
|
|
+ (_('Device Role'), (
|
|
|
'name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags',
|
|
'name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -348,39 +366,39 @@ class DeviceRoleForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class PlatformForm(NetBoxModelForm):
|
|
class PlatformForm(NetBoxModelForm):
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
manufacturer = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Manufacturer'),
|
|
|
queryset=Manufacturer.objects.all(),
|
|
queryset=Manufacturer.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
config_template = DynamicModelChoiceField(
|
|
config_template = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Config template'),
|
|
|
queryset=ConfigTemplate.objects.all(),
|
|
queryset=ConfigTemplate.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
slug = SlugField(
|
|
slug = SlugField(
|
|
|
|
|
+ label=_('Slug'),
|
|
|
max_length=64
|
|
max_length=64
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Platform', (
|
|
|
|
|
- 'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags',
|
|
|
|
|
- )),
|
|
|
|
|
|
|
+ (_('Platform'), ('name', 'slug', 'manufacturer', 'config_template', 'description', 'tags')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = Platform
|
|
model = Platform
|
|
|
fields = [
|
|
fields = [
|
|
|
- 'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags',
|
|
|
|
|
|
|
+ 'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags',
|
|
|
]
|
|
]
|
|
|
- widgets = {
|
|
|
|
|
- 'napalm_args': forms.Textarea(),
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
site = DynamicModelChoiceField(
|
|
site = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Site'),
|
|
|
queryset=Site.objects.all(),
|
|
queryset=Site.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
location = DynamicModelChoiceField(
|
|
location = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Location'),
|
|
|
queryset=Location.objects.all(),
|
|
queryset=Location.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -391,6 +409,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
rack = DynamicModelChoiceField(
|
|
rack = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Rack'),
|
|
|
queryset=Rack.objects.all(),
|
|
queryset=Rack.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -399,6 +418,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
position = forms.DecimalField(
|
|
position = forms.DecimalField(
|
|
|
|
|
+ label=_('Position'),
|
|
|
required=False,
|
|
required=False,
|
|
|
help_text=_("The lowest-numbered unit occupied by the device"),
|
|
help_text=_("The lowest-numbered unit occupied by the device"),
|
|
|
localize=True,
|
|
localize=True,
|
|
@@ -411,17 +431,21 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
device_type = DynamicModelChoiceField(
|
|
device_type = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device type'),
|
|
|
queryset=DeviceType.objects.all(),
|
|
queryset=DeviceType.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
- device_role = DynamicModelChoiceField(
|
|
|
|
|
|
|
+ role = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device role'),
|
|
|
queryset=DeviceRole.objects.all()
|
|
queryset=DeviceRole.objects.all()
|
|
|
)
|
|
)
|
|
|
platform = DynamicModelChoiceField(
|
|
platform = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Platform'),
|
|
|
queryset=Platform.objects.all(),
|
|
queryset=Platform.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
cluster = DynamicModelChoiceField(
|
|
cluster = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Cluster'),
|
|
|
queryset=Cluster.objects.all(),
|
|
queryset=Cluster.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
selector=True
|
|
selector=True
|
|
@@ -432,6 +456,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
label=''
|
|
label=''
|
|
|
)
|
|
)
|
|
|
virtual_chassis = DynamicModelChoiceField(
|
|
virtual_chassis = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Virtual chassis'),
|
|
|
queryset=VirtualChassis.objects.all(),
|
|
queryset=VirtualChassis.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
selector=True
|
|
selector=True
|
|
@@ -447,6 +472,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
help_text=_("The priority of the device in the virtual chassis")
|
|
help_text=_("The priority of the device in the virtual chassis")
|
|
|
)
|
|
)
|
|
|
config_template = DynamicModelChoiceField(
|
|
config_template = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Config template'),
|
|
|
queryset=ConfigTemplate.objects.all(),
|
|
queryset=ConfigTemplate.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
@@ -454,10 +480,10 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = Device
|
|
model = Device
|
|
|
fields = [
|
|
fields = [
|
|
|
- 'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'site', 'rack', 'location', 'position', 'face',
|
|
|
|
|
- 'status', 'airflow', 'platform', 'primary_ip4', 'primary_ip6', 'cluster', 'tenant_group', 'tenant',
|
|
|
|
|
- 'virtual_chassis', 'vc_position', 'vc_priority', 'description', 'config_template', 'comments', 'tags',
|
|
|
|
|
- 'local_context_data'
|
|
|
|
|
|
|
+ 'name', 'role', 'device_type', 'serial', 'asset_tag', 'site', 'rack', 'location', 'position', 'face',
|
|
|
|
|
+ 'latitude', 'longitude', 'status', 'airflow', 'platform', 'primary_ip4', 'primary_ip6', 'oob_ip', 'cluster',
|
|
|
|
|
+ 'tenant_group', 'tenant', 'virtual_chassis', 'vc_position', 'vc_priority', 'description', 'config_template',
|
|
|
|
|
+ 'comments', 'tags', 'local_context_data',
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
def __init__(self, *args, **kwargs):
|
|
@@ -466,6 +492,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
if self.instance.pk:
|
|
if self.instance.pk:
|
|
|
|
|
|
|
|
# Compile list of choices for primary IPv4 and IPv6 addresses
|
|
# Compile list of choices for primary IPv4 and IPv6 addresses
|
|
|
|
|
+ oob_ip_choices = [(None, '---------')]
|
|
|
for family in [4, 6]:
|
|
for family in [4, 6]:
|
|
|
ip_choices = [(None, '---------')]
|
|
ip_choices = [(None, '---------')]
|
|
|
|
|
|
|
@@ -481,6 +508,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
if interface_ips:
|
|
if interface_ips:
|
|
|
ip_list = [(ip.id, f'{ip.address} ({ip.assigned_object})') for ip in interface_ips]
|
|
ip_list = [(ip.id, f'{ip.address} ({ip.assigned_object})') for ip in interface_ips]
|
|
|
ip_choices.append(('Interface IPs', ip_list))
|
|
ip_choices.append(('Interface IPs', ip_list))
|
|
|
|
|
+ oob_ip_choices.extend(ip_list)
|
|
|
# Collect NAT IPs
|
|
# Collect NAT IPs
|
|
|
nat_ips = IPAddress.objects.prefetch_related('nat_inside').filter(
|
|
nat_ips = IPAddress.objects.prefetch_related('nat_inside').filter(
|
|
|
address__family=family,
|
|
address__family=family,
|
|
@@ -491,6 +519,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
ip_list = [(ip.id, f'{ip.address} (NAT)') for ip in nat_ips]
|
|
ip_list = [(ip.id, f'{ip.address} (NAT)') for ip in nat_ips]
|
|
|
ip_choices.append(('NAT IPs', ip_list))
|
|
ip_choices.append(('NAT IPs', ip_list))
|
|
|
self.fields['primary_ip{}'.format(family)].choices = ip_choices
|
|
self.fields['primary_ip{}'.format(family)].choices = ip_choices
|
|
|
|
|
+ self.fields['oob_ip'].choices = oob_ip_choices
|
|
|
|
|
|
|
|
# If editing an existing device, exclude it from the list of occupied rack units. This ensures that a device
|
|
# If editing an existing device, exclude it from the list of occupied rack units. This ensures that a device
|
|
|
# can be flipped from one face to another.
|
|
# can be flipped from one face to another.
|
|
@@ -510,6 +539,8 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
self.fields['primary_ip4'].widget.attrs['readonly'] = True
|
|
self.fields['primary_ip4'].widget.attrs['readonly'] = True
|
|
|
self.fields['primary_ip6'].choices = []
|
|
self.fields['primary_ip6'].choices = []
|
|
|
self.fields['primary_ip6'].widget.attrs['readonly'] = True
|
|
self.fields['primary_ip6'].widget.attrs['readonly'] = True
|
|
|
|
|
+ self.fields['oob_ip'].choices = []
|
|
|
|
|
+ self.fields['oob_ip'].widget.attrs['readonly'] = True
|
|
|
|
|
|
|
|
# Rack position
|
|
# Rack position
|
|
|
position = self.data.get('position') or self.initial.get('position')
|
|
position = self.data.get('position') or self.initial.get('position')
|
|
@@ -519,36 +550,41 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
|
|
|
|
|
class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
|
class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
|
|
device = DynamicModelChoiceField(
|
|
device = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device'),
|
|
|
queryset=Device.objects.all(),
|
|
queryset=Device.objects.all(),
|
|
|
initial_params={
|
|
initial_params={
|
|
|
'modulebays': '$module_bay'
|
|
'modulebays': '$module_bay'
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
module_bay = DynamicModelChoiceField(
|
|
module_bay = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Module bay'),
|
|
|
queryset=ModuleBay.objects.all(),
|
|
queryset=ModuleBay.objects.all(),
|
|
|
query_params={
|
|
query_params={
|
|
|
'device_id': '$device'
|
|
'device_id': '$device'
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
module_type = DynamicModelChoiceField(
|
|
module_type = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Module type'),
|
|
|
queryset=ModuleType.objects.all(),
|
|
queryset=ModuleType.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
replicate_components = forms.BooleanField(
|
|
replicate_components = forms.BooleanField(
|
|
|
|
|
+ label=_('Replicate components'),
|
|
|
required=False,
|
|
required=False,
|
|
|
initial=True,
|
|
initial=True,
|
|
|
help_text=_("Automatically populate components associated with this module type")
|
|
help_text=_("Automatically populate components associated with this module type")
|
|
|
)
|
|
)
|
|
|
adopt_components = forms.BooleanField(
|
|
adopt_components = forms.BooleanField(
|
|
|
|
|
+ label=_('Adopt components'),
|
|
|
required=False,
|
|
required=False,
|
|
|
initial=False,
|
|
initial=False,
|
|
|
help_text=_("Adopt already existing components")
|
|
help_text=_("Adopt already existing components")
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Module', ('device', 'module_bay', 'module_type', 'status', 'description', 'tags')),
|
|
|
|
|
- ('Hardware', (
|
|
|
|
|
|
|
+ (_('Module'), ('device', 'module_bay', 'module_type', 'status', 'description', 'tags')),
|
|
|
|
|
+ (_('Hardware'), (
|
|
|
'serial', 'asset_tag', 'replicate_components', 'adopt_components',
|
|
'serial', 'asset_tag', 'replicate_components', 'adopt_components',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -582,17 +618,19 @@ class CableForm(TenancyForm, NetBoxModelForm):
|
|
|
]
|
|
]
|
|
|
error_messages = {
|
|
error_messages = {
|
|
|
'length': {
|
|
'length': {
|
|
|
- 'max_value': 'Maximum length is 32767 (any unit)'
|
|
|
|
|
|
|
+ 'max_value': _('Maximum length is 32767 (any unit)')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
class PowerPanelForm(NetBoxModelForm):
|
|
class PowerPanelForm(NetBoxModelForm):
|
|
|
site = DynamicModelChoiceField(
|
|
site = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Site'),
|
|
|
queryset=Site.objects.all(),
|
|
queryset=Site.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
location = DynamicModelChoiceField(
|
|
location = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Location'),
|
|
|
queryset=Location.objects.all(),
|
|
queryset=Location.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -612,12 +650,14 @@ class PowerPanelForm(NetBoxModelForm):
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
-class PowerFeedForm(NetBoxModelForm):
|
|
|
|
|
|
|
+class PowerFeedForm(TenancyForm, NetBoxModelForm):
|
|
|
power_panel = DynamicModelChoiceField(
|
|
power_panel = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Power panel'),
|
|
|
queryset=PowerPanel.objects.all(),
|
|
queryset=PowerPanel.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
rack = DynamicModelChoiceField(
|
|
rack = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Rack'),
|
|
|
queryset=Rack.objects.all(),
|
|
queryset=Rack.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
selector=True
|
|
selector=True
|
|
@@ -625,15 +665,16 @@ class PowerFeedForm(NetBoxModelForm):
|
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Power Feed', ('power_panel', 'rack', 'name', 'status', 'type', 'description', 'mark_connected', 'tags')),
|
|
|
|
|
- ('Characteristics', ('supply', 'voltage', 'amperage', 'phase', 'max_utilization')),
|
|
|
|
|
|
|
+ (_('Power Feed'), ('power_panel', 'rack', 'name', 'status', 'type', 'description', 'mark_connected', 'tags')),
|
|
|
|
|
+ (_('Characteristics'), ('supply', 'voltage', 'amperage', 'phase', 'max_utilization')),
|
|
|
|
|
+ (_('Tenancy'), ('tenant_group', 'tenant')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = PowerFeed
|
|
model = PowerFeed
|
|
|
fields = [
|
|
fields = [
|
|
|
'power_panel', 'rack', 'name', 'status', 'type', 'mark_connected', 'supply', 'phase', 'voltage', 'amperage',
|
|
'power_panel', 'rack', 'name', 'status', 'type', 'mark_connected', 'supply', 'phase', 'voltage', 'amperage',
|
|
|
- 'max_utilization', 'description', 'comments', 'tags',
|
|
|
|
|
|
|
+ 'max_utilization', 'tenant_group', 'tenant', 'description', 'comments', 'tags'
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@@ -643,6 +684,7 @@ class PowerFeedForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class VirtualChassisForm(NetBoxModelForm):
|
|
class VirtualChassisForm(NetBoxModelForm):
|
|
|
master = forms.ModelChoiceField(
|
|
master = forms.ModelChoiceField(
|
|
|
|
|
+ label=_('Master'),
|
|
|
queryset=Device.objects.all(),
|
|
queryset=Device.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
)
|
|
)
|
|
@@ -706,6 +748,7 @@ class DeviceVCMembershipForm(forms.ModelForm):
|
|
|
|
|
|
|
|
class VCMemberSelectForm(BootstrapMixin, forms.Form):
|
|
class VCMemberSelectForm(BootstrapMixin, forms.Form):
|
|
|
device = DynamicModelChoiceField(
|
|
device = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device'),
|
|
|
queryset=Device.objects.all(),
|
|
queryset=Device.objects.all(),
|
|
|
query_params={
|
|
query_params={
|
|
|
'virtual_chassis_id': 'null',
|
|
'virtual_chassis_id': 'null',
|
|
@@ -728,6 +771,7 @@ class VCMemberSelectForm(BootstrapMixin, forms.Form):
|
|
|
|
|
|
|
|
class ComponentTemplateForm(BootstrapMixin, forms.ModelForm):
|
|
class ComponentTemplateForm(BootstrapMixin, forms.ModelForm):
|
|
|
device_type = DynamicModelChoiceField(
|
|
device_type = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device type'),
|
|
|
queryset=DeviceType.objects.all()
|
|
queryset=DeviceType.objects.all()
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -741,10 +785,12 @@ class ComponentTemplateForm(BootstrapMixin, forms.ModelForm):
|
|
|
|
|
|
|
|
class ModularComponentTemplateForm(ComponentTemplateForm):
|
|
class ModularComponentTemplateForm(ComponentTemplateForm):
|
|
|
device_type = DynamicModelChoiceField(
|
|
device_type = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device type'),
|
|
|
queryset=DeviceType.objects.all().all(),
|
|
queryset=DeviceType.objects.all().all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
module_type = DynamicModelChoiceField(
|
|
module_type = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Module type'),
|
|
|
queryset=ModuleType.objects.all(),
|
|
queryset=ModuleType.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
@@ -797,6 +843,7 @@ class PowerPortTemplateForm(ModularComponentTemplateForm):
|
|
|
|
|
|
|
|
class PowerOutletTemplateForm(ModularComponentTemplateForm):
|
|
class PowerOutletTemplateForm(ModularComponentTemplateForm):
|
|
|
power_port = DynamicModelChoiceField(
|
|
power_port = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Power port'),
|
|
|
queryset=PowerPortTemplate.objects.all(),
|
|
queryset=PowerPortTemplate.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -817,6 +864,7 @@ class PowerOutletTemplateForm(ModularComponentTemplateForm):
|
|
|
|
|
|
|
|
class InterfaceTemplateForm(ModularComponentTemplateForm):
|
|
class InterfaceTemplateForm(ModularComponentTemplateForm):
|
|
|
bridge = DynamicModelChoiceField(
|
|
bridge = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Bridge'),
|
|
|
queryset=InterfaceTemplate.objects.all(),
|
|
queryset=InterfaceTemplate.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -827,18 +875,20 @@ class InterfaceTemplateForm(ModularComponentTemplateForm):
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
(None, ('device_type', 'module_type', 'name', 'label', 'type', 'enabled', 'mgmt_only', 'description', 'bridge')),
|
|
(None, ('device_type', 'module_type', 'name', 'label', 'type', 'enabled', 'mgmt_only', 'description', 'bridge')),
|
|
|
- ('PoE', ('poe_mode', 'poe_type'))
|
|
|
|
|
|
|
+ (_('PoE'), ('poe_mode', 'poe_type')),
|
|
|
|
|
+ (_('Wireless'), ('rf_role',)),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = InterfaceTemplate
|
|
model = InterfaceTemplate
|
|
|
fields = [
|
|
fields = [
|
|
|
- 'device_type', 'module_type', 'name', 'label', 'type', 'mgmt_only', 'enabled', 'description', 'poe_mode', 'poe_type', 'bridge',
|
|
|
|
|
|
|
+ 'device_type', 'module_type', 'name', 'label', 'type', 'mgmt_only', 'enabled', 'description', 'poe_mode', 'poe_type', 'bridge', 'rf_role',
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
class FrontPortTemplateForm(ModularComponentTemplateForm):
|
|
class FrontPortTemplateForm(ModularComponentTemplateForm):
|
|
|
rear_port = DynamicModelChoiceField(
|
|
rear_port = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Rear port'),
|
|
|
queryset=RearPortTemplate.objects.all(),
|
|
queryset=RearPortTemplate.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -900,6 +950,7 @@ class DeviceBayTemplateForm(ComponentTemplateForm):
|
|
|
|
|
|
|
|
class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
|
parent = DynamicModelChoiceField(
|
|
parent = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Parent'),
|
|
|
queryset=InventoryItemTemplate.objects.all(),
|
|
queryset=InventoryItemTemplate.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -907,10 +958,12 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
role = DynamicModelChoiceField(
|
|
role = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Role'),
|
|
|
queryset=InventoryItemRole.objects.all(),
|
|
queryset=InventoryItemRole.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
manufacturer = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Manufacturer'),
|
|
|
queryset=Manufacturer.objects.all(),
|
|
queryset=Manufacturer.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
@@ -946,6 +999,7 @@ class InventoryItemTemplateForm(ComponentTemplateForm):
|
|
|
|
|
|
|
|
class DeviceComponentForm(NetBoxModelForm):
|
|
class DeviceComponentForm(NetBoxModelForm):
|
|
|
device = DynamicModelChoiceField(
|
|
device = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device'),
|
|
|
queryset=Device.objects.all(),
|
|
queryset=Device.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
@@ -960,6 +1014,7 @@ class DeviceComponentForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class ModularDeviceComponentForm(DeviceComponentForm):
|
|
class ModularDeviceComponentForm(DeviceComponentForm):
|
|
|
module = DynamicModelChoiceField(
|
|
module = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Module'),
|
|
|
queryset=Module.objects.all(),
|
|
queryset=Module.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -1016,6 +1071,7 @@ class PowerPortForm(ModularDeviceComponentForm):
|
|
|
|
|
|
|
|
class PowerOutletForm(ModularDeviceComponentForm):
|
|
class PowerOutletForm(ModularDeviceComponentForm):
|
|
|
power_port = DynamicModelChoiceField(
|
|
power_port = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Power port'),
|
|
|
queryset=PowerPort.objects.all(),
|
|
queryset=PowerPort.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -1042,7 +1098,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
vdcs = DynamicModelMultipleChoiceField(
|
|
vdcs = DynamicModelMultipleChoiceField(
|
|
|
queryset=VirtualDeviceContext.objects.all(),
|
|
queryset=VirtualDeviceContext.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
- label='Virtual Device Contexts',
|
|
|
|
|
|
|
+ label=_('Virtual device contexts'),
|
|
|
initial_params={
|
|
initial_params={
|
|
|
'interfaces': '$parent',
|
|
'interfaces': '$parent',
|
|
|
},
|
|
},
|
|
@@ -1055,7 +1111,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
required=False,
|
|
required=False,
|
|
|
label=_('Parent interface'),
|
|
label=_('Parent interface'),
|
|
|
query_params={
|
|
query_params={
|
|
|
- 'device_id': '$device',
|
|
|
|
|
|
|
+ 'virtual_chassis_member_id': '$device',
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
bridge = DynamicModelChoiceField(
|
|
bridge = DynamicModelChoiceField(
|
|
@@ -1063,7 +1119,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
required=False,
|
|
required=False,
|
|
|
label=_('Bridged interface'),
|
|
label=_('Bridged interface'),
|
|
|
query_params={
|
|
query_params={
|
|
|
- 'device_id': '$device',
|
|
|
|
|
|
|
+ 'virtual_chassis_member_id': '$device',
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
lag = DynamicModelChoiceField(
|
|
lag = DynamicModelChoiceField(
|
|
@@ -1071,7 +1127,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
required=False,
|
|
required=False,
|
|
|
label=_('LAG interface'),
|
|
label=_('LAG interface'),
|
|
|
query_params={
|
|
query_params={
|
|
|
- 'device_id': '$device',
|
|
|
|
|
|
|
+ 'virtual_chassis_member_id': '$device',
|
|
|
'type': 'lag',
|
|
'type': 'lag',
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
@@ -1123,13 +1179,13 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Interface', ('device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'description', 'tags')),
|
|
|
|
|
- ('Addressing', ('vrf', 'mac_address', 'wwn')),
|
|
|
|
|
- ('Operation', ('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
|
|
|
|
- ('Related Interfaces', ('parent', 'bridge', 'lag')),
|
|
|
|
|
- ('PoE', ('poe_mode', 'poe_type')),
|
|
|
|
|
- ('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
|
|
|
|
- ('Wireless', (
|
|
|
|
|
|
|
+ (_('Interface'), ('device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'description', 'tags')),
|
|
|
|
|
+ (_('Addressing'), ('vrf', 'mac_address', 'wwn')),
|
|
|
|
|
+ (_('Operation'), ('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
|
|
|
|
+ (_('Related Interfaces'), ('parent', 'bridge', 'lag')),
|
|
|
|
|
+ (_('PoE'), ('poe_mode', 'poe_type')),
|
|
|
|
|
+ (_('802.1Q Switching'), ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
|
|
|
|
+ (_('Wireless'), (
|
|
|
'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'wireless_lan_group', 'wireless_lans',
|
|
'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'wireless_lan_group', 'wireless_lans',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -1235,6 +1291,7 @@ class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
|
|
|
|
|
|
|
|
class InventoryItemForm(DeviceComponentForm):
|
|
class InventoryItemForm(DeviceComponentForm):
|
|
|
parent = DynamicModelChoiceField(
|
|
parent = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Parent'),
|
|
|
queryset=InventoryItem.objects.all(),
|
|
queryset=InventoryItem.objects.all(),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
@@ -1242,10 +1299,12 @@ class InventoryItemForm(DeviceComponentForm):
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
role = DynamicModelChoiceField(
|
|
role = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Role'),
|
|
|
queryset=InventoryItemRole.objects.all(),
|
|
queryset=InventoryItemRole.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
manufacturer = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Manufacturer'),
|
|
|
queryset=Manufacturer.objects.all(),
|
|
queryset=Manufacturer.objects.all(),
|
|
|
required=False
|
|
required=False
|
|
|
)
|
|
)
|
|
@@ -1309,8 +1368,8 @@ class InventoryItemForm(DeviceComponentForm):
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Inventory Item', ('device', 'parent', 'name', 'label', 'role', 'description', 'tags')),
|
|
|
|
|
- ('Hardware', ('manufacturer', 'part_id', 'serial', 'asset_tag')),
|
|
|
|
|
|
|
+ (_('Inventory Item'), ('device', 'parent', 'name', 'label', 'role', 'description', 'tags')),
|
|
|
|
|
+ (_('Hardware'), ('manufacturer', 'part_id', 'serial', 'asset_tag')),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -1361,7 +1420,7 @@ class InventoryItemForm(DeviceComponentForm):
|
|
|
) if self.cleaned_data[field]
|
|
) if self.cleaned_data[field]
|
|
|
]
|
|
]
|
|
|
if len(selected_objects) > 1:
|
|
if len(selected_objects) > 1:
|
|
|
- raise forms.ValidationError("An InventoryItem can only be assigned to a single component.")
|
|
|
|
|
|
|
+ raise forms.ValidationError(_("An InventoryItem can only be assigned to a single component."))
|
|
|
elif selected_objects:
|
|
elif selected_objects:
|
|
|
self.instance.component = self.cleaned_data[selected_objects[0]]
|
|
self.instance.component = self.cleaned_data[selected_objects[0]]
|
|
|
else:
|
|
else:
|
|
@@ -1375,7 +1434,7 @@ class InventoryItemRoleForm(NetBoxModelForm):
|
|
|
slug = SlugField()
|
|
slug = SlugField()
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Inventory Item Role', (
|
|
|
|
|
|
|
+ (_('Inventory Item Role'), (
|
|
|
'name', 'slug', 'color', 'description', 'tags',
|
|
'name', 'slug', 'color', 'description', 'tags',
|
|
|
)),
|
|
)),
|
|
|
)
|
|
)
|
|
@@ -1389,12 +1448,13 @@ class InventoryItemRoleForm(NetBoxModelForm):
|
|
|
|
|
|
|
|
class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
|
class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
|
|
device = DynamicModelChoiceField(
|
|
device = DynamicModelChoiceField(
|
|
|
|
|
+ label=_('Device'),
|
|
|
queryset=Device.objects.all(),
|
|
queryset=Device.objects.all(),
|
|
|
selector=True
|
|
selector=True
|
|
|
)
|
|
)
|
|
|
primary_ip4 = DynamicModelChoiceField(
|
|
primary_ip4 = DynamicModelChoiceField(
|
|
|
queryset=IPAddress.objects.all(),
|
|
queryset=IPAddress.objects.all(),
|
|
|
- label='Primary IPv4',
|
|
|
|
|
|
|
+ label=_('Primary IPv4'),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
|
'device_id': '$device',
|
|
'device_id': '$device',
|
|
@@ -1403,7 +1463,7 @@ class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
)
|
|
|
primary_ip6 = DynamicModelChoiceField(
|
|
primary_ip6 = DynamicModelChoiceField(
|
|
|
queryset=IPAddress.objects.all(),
|
|
queryset=IPAddress.objects.all(),
|
|
|
- label='Primary IPv6',
|
|
|
|
|
|
|
+ label=_('Primary IPv6'),
|
|
|
required=False,
|
|
required=False,
|
|
|
query_params={
|
|
query_params={
|
|
|
'device_id': '$device',
|
|
'device_id': '$device',
|
|
@@ -1412,8 +1472,8 @@ class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
fieldsets = (
|
|
fieldsets = (
|
|
|
- ('Virtual Device Context', ('device', 'name', 'status', 'identifier', 'primary_ip4', 'primary_ip6', 'tags')),
|
|
|
|
|
- ('Tenancy', ('tenant_group', 'tenant'))
|
|
|
|
|
|
|
+ (_('Virtual Device Context'), ('device', 'name', 'status', 'identifier', 'primary_ip4', 'primary_ip6', 'tags')),
|
|
|
|
|
+ (_('Tenancy'), ('tenant_group', 'tenant'))
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|