|
|
@@ -1,7 +1,7 @@
|
|
|
from django import forms
|
|
|
-from django.utils.translation import gettext as _
|
|
|
from django.contrib.auth.models import User
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
+from django.utils.translation import gettext as _
|
|
|
from timezone_field import TimeZoneFormField
|
|
|
|
|
|
from dcim.choices import *
|
|
|
@@ -62,6 +62,7 @@ __all__ = (
|
|
|
'SiteGroupForm',
|
|
|
'VCMemberSelectForm',
|
|
|
'VirtualChassisForm',
|
|
|
+ 'VirtualDeviceContextForm'
|
|
|
)
|
|
|
|
|
|
INTERFACE_MODE_HELP_TEXT = """
|
|
|
@@ -162,14 +163,14 @@ class SiteForm(TenancyForm, NetBoxModelForm):
|
|
|
'time_zone': StaticSelect(),
|
|
|
}
|
|
|
help_texts = {
|
|
|
- 'name': "Full name of the site",
|
|
|
- 'facility': "Data center provider and facility (e.g. Equinix NY7)",
|
|
|
- 'time_zone': "Local time zone",
|
|
|
- 'description': "Short description (will appear in sites list)",
|
|
|
- 'physical_address': "Physical location of the building (e.g. for GPS)",
|
|
|
- 'shipping_address': "If different from the physical address",
|
|
|
- 'latitude': "Latitude in decimal format (xx.yyyyyy)",
|
|
|
- 'longitude': "Longitude in decimal format (xx.yyyyyy)"
|
|
|
+ 'name': _("Full name of the site"),
|
|
|
+ 'facility': _("Data center provider and facility (e.g. Equinix NY7)"),
|
|
|
+ 'time_zone': _("Local time zone"),
|
|
|
+ 'description': _("Short description (will appear in sites list)"),
|
|
|
+ 'physical_address': _("Physical location of the building (e.g. for GPS)"),
|
|
|
+ 'shipping_address': _("If different from the physical address"),
|
|
|
+ 'latitude': _("Latitude in decimal format (xx.yyyyyy)"),
|
|
|
+ 'longitude': _("Longitude in decimal format (xx.yyyyyy)")
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -278,19 +279,20 @@ class RackForm(TenancyForm, NetBoxModelForm):
|
|
|
fields = [
|
|
|
'region', 'site_group', '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', 'comments', 'tags',
|
|
|
+ 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
|
|
]
|
|
|
help_texts = {
|
|
|
- 'site': "The site at which the rack exists",
|
|
|
- 'name': "Organizational rack name",
|
|
|
- 'facility_id': "The unique rack ID assigned by the facility",
|
|
|
- 'u_height': "Height in rack units",
|
|
|
+ 'site': _("The site at which the rack exists"),
|
|
|
+ 'name': _("Organizational rack name"),
|
|
|
+ 'facility_id': _("The unique rack ID assigned by the facility"),
|
|
|
+ 'u_height': _("Height in rack units"),
|
|
|
}
|
|
|
widgets = {
|
|
|
'status': StaticSelect(),
|
|
|
'type': StaticSelect(),
|
|
|
'width': StaticSelect(),
|
|
|
'outer_unit': StaticSelect(),
|
|
|
+ 'weight_unit': StaticSelect(),
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -333,7 +335,7 @@ class RackReservationForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
|
units = NumericArrayField(
|
|
|
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(
|
|
|
queryset=User.objects.order_by(
|
|
|
@@ -341,6 +343,7 @@ class RackReservationForm(TenancyForm, NetBoxModelForm):
|
|
|
),
|
|
|
widget=StaticSelect()
|
|
|
)
|
|
|
+ comments = CommentField()
|
|
|
|
|
|
fieldsets = (
|
|
|
('Reservation', ('region', 'site_group', 'site', 'location', 'rack', 'units', 'user', 'description', 'tags')),
|
|
|
@@ -351,7 +354,7 @@ class RackReservationForm(TenancyForm, NetBoxModelForm):
|
|
|
model = RackReservation
|
|
|
fields = [
|
|
|
'region', 'site_group', 'site', 'location', 'rack', 'units', 'user', 'tenant_group', 'tenant',
|
|
|
- 'description', 'tags',
|
|
|
+ 'description', 'comments', 'tags',
|
|
|
]
|
|
|
|
|
|
|
|
|
@@ -381,11 +384,9 @@ class DeviceTypeForm(NetBoxModelForm):
|
|
|
comments = CommentField()
|
|
|
|
|
|
fieldsets = (
|
|
|
- ('Device Type', (
|
|
|
- 'manufacturer', 'model', 'slug', 'part_number', 'tags',
|
|
|
- )),
|
|
|
+ ('Device Type', ('manufacturer', 'model', 'slug', 'description', 'tags')),
|
|
|
('Chassis', (
|
|
|
- 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
|
|
|
+ 'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit',
|
|
|
)),
|
|
|
('Images', ('front_image', 'rear_image')),
|
|
|
)
|
|
|
@@ -394,7 +395,7 @@ class DeviceTypeForm(NetBoxModelForm):
|
|
|
model = DeviceType
|
|
|
fields = [
|
|
|
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
|
|
|
- 'front_image', 'rear_image', 'comments', 'tags',
|
|
|
+ 'weight', 'weight_unit', 'front_image', 'rear_image', 'description', 'comments', 'tags',
|
|
|
]
|
|
|
widgets = {
|
|
|
'airflow': StaticSelect(),
|
|
|
@@ -404,7 +405,8 @@ class DeviceTypeForm(NetBoxModelForm):
|
|
|
}),
|
|
|
'rear_image': ClearableFileInput(attrs={
|
|
|
'accept': DEVICETYPE_IMAGE_FORMATS
|
|
|
- })
|
|
|
+ }),
|
|
|
+ 'weight_unit': StaticSelect(),
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -415,17 +417,20 @@ class ModuleTypeForm(NetBoxModelForm):
|
|
|
comments = CommentField()
|
|
|
|
|
|
fieldsets = (
|
|
|
- ('Module Type', (
|
|
|
- 'manufacturer', 'model', 'part_number', 'tags',
|
|
|
- )),
|
|
|
+ ('Module Type', ('manufacturer', 'model', 'part_number', 'description', 'tags')),
|
|
|
+ ('Weight', ('weight', 'weight_unit'))
|
|
|
)
|
|
|
|
|
|
class Meta:
|
|
|
model = ModuleType
|
|
|
fields = [
|
|
|
- 'manufacturer', 'model', 'part_number', 'comments', 'tags',
|
|
|
+ 'manufacturer', 'model', 'part_number', 'weight', 'weight_unit', 'description', 'comments', 'tags',
|
|
|
]
|
|
|
|
|
|
+ widgets = {
|
|
|
+ 'weight_unit': StaticSelect(),
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
class DeviceRoleForm(NetBoxModelForm):
|
|
|
slug = SlugField()
|
|
|
@@ -511,7 +516,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
|
position = forms.DecimalField(
|
|
|
required=False,
|
|
|
- help_text="The lowest-numbered unit occupied by the device",
|
|
|
+ help_text=_("The lowest-numbered unit occupied by the device"),
|
|
|
widget=APISelect(
|
|
|
api_url='/api/dcim/racks/{{rack}}/elevation/',
|
|
|
attrs={
|
|
|
@@ -569,13 +574,13 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
)
|
|
|
vc_position = forms.IntegerField(
|
|
|
required=False,
|
|
|
- label='Position',
|
|
|
- help_text="The position in the virtual chassis this device is identified by"
|
|
|
+ label=_('Position'),
|
|
|
+ help_text=_("The position in the virtual chassis this device is identified by")
|
|
|
)
|
|
|
vc_priority = forms.IntegerField(
|
|
|
required=False,
|
|
|
- label='Priority',
|
|
|
- help_text="The priority of the device in the virtual chassis"
|
|
|
+ label=_('Priority'),
|
|
|
+ help_text=_("The priority of the device in the virtual chassis")
|
|
|
)
|
|
|
|
|
|
class Meta:
|
|
|
@@ -584,13 +589,13 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|
|
'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'region', 'site_group', 'site', 'rack',
|
|
|
'location', 'position', 'face', 'status', 'airflow', 'platform', 'primary_ip4', 'primary_ip6',
|
|
|
'cluster_group', 'cluster', 'tenant_group', 'tenant', 'virtual_chassis', 'vc_position', 'vc_priority',
|
|
|
- 'comments', 'tags', 'local_context_data'
|
|
|
+ 'description', 'comments', 'tags', 'local_context_data'
|
|
|
]
|
|
|
help_texts = {
|
|
|
- 'device_role': "The function this device serves",
|
|
|
- 'serial': "Chassis serial number",
|
|
|
- 'local_context_data': "Local config context data overwrites all source contexts in the final rendered "
|
|
|
- "config context",
|
|
|
+ 'device_role': _("The function this device serves"),
|
|
|
+ 'serial': _("Chassis serial number"),
|
|
|
+ 'local_context_data': _("Local config context data overwrites all source contexts in the final rendered "
|
|
|
+ "config context"),
|
|
|
}
|
|
|
widgets = {
|
|
|
'face': StaticSelect(),
|
|
|
@@ -687,18 +692,18 @@ class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
|
|
replicate_components = forms.BooleanField(
|
|
|
required=False,
|
|
|
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(
|
|
|
required=False,
|
|
|
initial=False,
|
|
|
- help_text="Adopt already existing components"
|
|
|
+ help_text=_("Adopt already existing components")
|
|
|
)
|
|
|
|
|
|
fieldsets = (
|
|
|
('Module', (
|
|
|
- 'device', 'module_bay', 'manufacturer', 'module_type', 'tags',
|
|
|
+ 'device', 'module_bay', 'manufacturer', 'module_type', 'status', 'description', 'tags',
|
|
|
)),
|
|
|
('Hardware', (
|
|
|
'serial', 'asset_tag', 'replicate_components', 'adopt_components',
|
|
|
@@ -708,8 +713,8 @@ class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
|
|
class Meta:
|
|
|
model = Module
|
|
|
fields = [
|
|
|
- 'device', 'module_bay', 'manufacturer', 'module_type', 'serial', 'asset_tag', 'tags',
|
|
|
- 'replicate_components', 'adopt_components', 'comments',
|
|
|
+ 'device', 'module_bay', 'manufacturer', 'module_type', 'status', 'serial', 'asset_tag', 'tags',
|
|
|
+ 'replicate_components', 'adopt_components', 'description', 'comments',
|
|
|
]
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
@@ -724,11 +729,13 @@ class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
|
|
|
|
|
|
|
|
class CableForm(TenancyForm, NetBoxModelForm):
|
|
|
+ comments = CommentField()
|
|
|
|
|
|
class Meta:
|
|
|
model = Cable
|
|
|
fields = [
|
|
|
- 'type', 'status', 'tenant_group', 'tenant', 'label', 'color', 'length', 'length_unit', 'tags',
|
|
|
+ 'type', 'status', 'tenant_group', 'tenant', 'label', 'color', 'length', 'length_unit', 'description',
|
|
|
+ 'comments', 'tags',
|
|
|
]
|
|
|
widgets = {
|
|
|
'status': StaticSelect,
|
|
|
@@ -771,15 +778,16 @@ class PowerPanelForm(NetBoxModelForm):
|
|
|
'site_id': '$site'
|
|
|
}
|
|
|
)
|
|
|
+ comments = CommentField()
|
|
|
|
|
|
fieldsets = (
|
|
|
- ('Power Panel', ('region', 'site_group', 'site', 'location', 'name', 'tags')),
|
|
|
+ ('Power Panel', ('region', 'site_group', 'site', 'location', 'name', 'description', 'tags')),
|
|
|
)
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerPanel
|
|
|
fields = [
|
|
|
- 'region', 'site_group', 'site', 'location', 'name', 'tags',
|
|
|
+ 'region', 'site_group', 'site', 'location', 'name', 'description', 'comments', 'tags',
|
|
|
]
|
|
|
|
|
|
|
|
|
@@ -837,15 +845,16 @@ class PowerFeedForm(NetBoxModelForm):
|
|
|
|
|
|
fieldsets = (
|
|
|
('Power Panel', ('region', 'site', 'power_panel')),
|
|
|
- ('Power Feed', ('location', 'rack', 'name', 'status', 'type', 'mark_connected', 'tags')),
|
|
|
+ ('Power Feed', ('location', 'rack', 'name', 'status', 'type', 'description', 'mark_connected', 'tags')),
|
|
|
('Characteristics', ('supply', 'voltage', 'amperage', 'phase', 'max_utilization')),
|
|
|
)
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerFeed
|
|
|
fields = [
|
|
|
- 'region', 'site_group', 'site', 'power_panel', 'location', 'rack', 'name', 'status', 'type', 'mark_connected', 'supply',
|
|
|
- 'phase', 'voltage', 'amperage', 'max_utilization', 'comments', 'tags',
|
|
|
+ 'region', 'site_group', 'site', 'power_panel', 'location', 'rack', 'name', 'status', 'type',
|
|
|
+ 'mark_connected', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization', 'description', 'comments',
|
|
|
+ 'tags',
|
|
|
]
|
|
|
widgets = {
|
|
|
'status': StaticSelect(),
|
|
|
@@ -864,11 +873,12 @@ class VirtualChassisForm(NetBoxModelForm):
|
|
|
queryset=Device.objects.all(),
|
|
|
required=False,
|
|
|
)
|
|
|
+ comments = CommentField()
|
|
|
|
|
|
class Meta:
|
|
|
model = VirtualChassis
|
|
|
fields = [
|
|
|
- 'name', 'domain', 'master', 'tags',
|
|
|
+ 'name', 'domain', 'master', 'description', 'comments', 'tags',
|
|
|
]
|
|
|
widgets = {
|
|
|
'master': SelectWithPK(),
|
|
|
@@ -1316,10 +1326,18 @@ class PowerOutletForm(ModularDeviceComponentForm):
|
|
|
|
|
|
|
|
|
class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
+ vdcs = DynamicModelMultipleChoiceField(
|
|
|
+ queryset=VirtualDeviceContext.objects.all(),
|
|
|
+ required=False,
|
|
|
+ label='Virtual Device Contexts',
|
|
|
+ query_params={
|
|
|
+ 'device_id': '$device',
|
|
|
+ }
|
|
|
+ )
|
|
|
parent = DynamicModelChoiceField(
|
|
|
queryset=Interface.objects.all(),
|
|
|
required=False,
|
|
|
- label='Parent interface',
|
|
|
+ label=_('Parent interface'),
|
|
|
query_params={
|
|
|
'device_id': '$device',
|
|
|
}
|
|
|
@@ -1327,7 +1345,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
bridge = DynamicModelChoiceField(
|
|
|
queryset=Interface.objects.all(),
|
|
|
required=False,
|
|
|
- label='Bridged interface',
|
|
|
+ label=_('Bridged interface'),
|
|
|
query_params={
|
|
|
'device_id': '$device',
|
|
|
}
|
|
|
@@ -1335,7 +1353,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
lag = DynamicModelChoiceField(
|
|
|
queryset=Interface.objects.all(),
|
|
|
required=False,
|
|
|
- label='LAG interface',
|
|
|
+ label=_('LAG interface'),
|
|
|
query_params={
|
|
|
'device_id': '$device',
|
|
|
'type': 'lag',
|
|
|
@@ -1344,12 +1362,12 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
wireless_lan_group = DynamicModelChoiceField(
|
|
|
queryset=WirelessLANGroup.objects.all(),
|
|
|
required=False,
|
|
|
- label='Wireless LAN group'
|
|
|
+ label=_('Wireless LAN group')
|
|
|
)
|
|
|
wireless_lans = DynamicModelMultipleChoiceField(
|
|
|
queryset=WirelessLAN.objects.all(),
|
|
|
required=False,
|
|
|
- label='Wireless LANs',
|
|
|
+ label=_('Wireless LANs'),
|
|
|
query_params={
|
|
|
'group_id': '$wireless_lan_group',
|
|
|
}
|
|
|
@@ -1357,12 +1375,12 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
vlan_group = DynamicModelChoiceField(
|
|
|
queryset=VLANGroup.objects.all(),
|
|
|
required=False,
|
|
|
- label='VLAN group'
|
|
|
+ label=_('VLAN group')
|
|
|
)
|
|
|
untagged_vlan = DynamicModelChoiceField(
|
|
|
queryset=VLAN.objects.all(),
|
|
|
required=False,
|
|
|
- label='Untagged VLAN',
|
|
|
+ label=_('Untagged VLAN'),
|
|
|
query_params={
|
|
|
'group_id': '$vlan_group',
|
|
|
'available_on_device': '$device',
|
|
|
@@ -1371,7 +1389,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
tagged_vlans = DynamicModelMultipleChoiceField(
|
|
|
queryset=VLAN.objects.all(),
|
|
|
required=False,
|
|
|
- label='Tagged VLANs',
|
|
|
+ label=_('Tagged VLANs'),
|
|
|
query_params={
|
|
|
'group_id': '$vlan_group',
|
|
|
'available_on_device': '$device',
|
|
|
@@ -1380,19 +1398,18 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
vrf = DynamicModelChoiceField(
|
|
|
queryset=VRF.objects.all(),
|
|
|
required=False,
|
|
|
- label='VRF'
|
|
|
+ label=_('VRF')
|
|
|
)
|
|
|
-
|
|
|
wwn = forms.CharField(
|
|
|
empty_value=None,
|
|
|
required=False,
|
|
|
- label='WWN'
|
|
|
+ label=_('WWN')
|
|
|
)
|
|
|
|
|
|
fieldsets = (
|
|
|
('Interface', ('device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'description', 'tags')),
|
|
|
('Addressing', ('vrf', 'mac_address', 'wwn')),
|
|
|
- ('Operation', ('mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
|
|
+ ('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')),
|
|
|
@@ -1404,7 +1421,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
class Meta:
|
|
|
model = Interface
|
|
|
fields = [
|
|
|
- 'device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'enabled', 'parent', 'bridge', 'lag',
|
|
|
+ 'device', 'module', 'vdcs', 'name', 'label', 'type', 'speed', 'duplex', 'enabled', 'parent', 'bridge', 'lag',
|
|
|
'mac_address', 'wwn', 'mtu', 'mgmt_only', 'mark_connected', 'description', 'poe_mode', 'poe_type', 'mode',
|
|
|
'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'wireless_lans',
|
|
|
'untagged_vlan', 'tagged_vlans', 'vrf', 'tags',
|
|
|
@@ -1424,8 +1441,8 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
}
|
|
|
help_texts = {
|
|
|
'mode': INTERFACE_MODE_HELP_TEXT,
|
|
|
- 'rf_channel_frequency': "Populated by selected channel (if set)",
|
|
|
- 'rf_channel_width': "Populated by selected channel (if set)",
|
|
|
+ 'rf_channel_frequency': _("Populated by selected channel (if set)"),
|
|
|
+ 'rf_channel_width': _("Populated by selected channel (if set)"),
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1499,8 +1516,8 @@ class DeviceBayForm(DeviceComponentForm):
|
|
|
class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
|
|
|
installed_device = forms.ModelChoiceField(
|
|
|
queryset=Device.objects.all(),
|
|
|
- label='Child Device',
|
|
|
- help_text="Child devices must first be created and assigned to the site/rack of the parent device.",
|
|
|
+ label=_('Child Device'),
|
|
|
+ help_text=_("Child devices must first be created and assigned to the site/rack of the parent device."),
|
|
|
widget=StaticSelect(),
|
|
|
)
|
|
|
|
|
|
@@ -1581,3 +1598,90 @@ class InventoryItemRoleForm(NetBoxModelForm):
|
|
|
fields = [
|
|
|
'name', 'slug', 'color', 'description', 'tags',
|
|
|
]
|
|
|
+
|
|
|
+
|
|
|
+class VirtualDeviceContextForm(TenancyForm, NetBoxModelForm):
|
|
|
+ region = DynamicModelChoiceField(
|
|
|
+ queryset=Region.objects.all(),
|
|
|
+ required=False,
|
|
|
+ initial_params={
|
|
|
+ 'sites': '$site'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ site_group = DynamicModelChoiceField(
|
|
|
+ queryset=SiteGroup.objects.all(),
|
|
|
+ required=False,
|
|
|
+ initial_params={
|
|
|
+ 'sites': '$site'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ site = DynamicModelChoiceField(
|
|
|
+ queryset=Site.objects.all(),
|
|
|
+ required=False,
|
|
|
+ query_params={
|
|
|
+ 'region_id': '$region',
|
|
|
+ 'group_id': '$site_group',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ location = DynamicModelChoiceField(
|
|
|
+ queryset=Location.objects.all(),
|
|
|
+ required=False,
|
|
|
+ query_params={
|
|
|
+ 'site_id': '$site'
|
|
|
+ },
|
|
|
+ initial_params={
|
|
|
+ 'racks': '$rack'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ rack = DynamicModelChoiceField(
|
|
|
+ queryset=Rack.objects.all(),
|
|
|
+ required=False,
|
|
|
+ query_params={
|
|
|
+ 'site_id': '$site',
|
|
|
+ 'location_id': '$location',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ device = DynamicModelChoiceField(
|
|
|
+ queryset=Device.objects.all(),
|
|
|
+ query_params={
|
|
|
+ 'site_id': '$site',
|
|
|
+ 'location_id': '$location',
|
|
|
+ 'rack_id': '$rack',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ primary_ip4 = DynamicModelChoiceField(
|
|
|
+ queryset=IPAddress.objects.all(),
|
|
|
+ label='Primary IPv4',
|
|
|
+ required=False,
|
|
|
+ query_params={
|
|
|
+ 'device_id': '$device',
|
|
|
+ 'family': '4',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ primary_ip6 = DynamicModelChoiceField(
|
|
|
+ queryset=IPAddress.objects.all(),
|
|
|
+ label='Primary IPv6',
|
|
|
+ required=False,
|
|
|
+ query_params={
|
|
|
+ 'device_id': '$device',
|
|
|
+ 'family': '6',
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ fieldsets = (
|
|
|
+ ('Assigned Device', ('region', 'site_group', 'site', 'location', 'rack', 'device')),
|
|
|
+ ('Virtual Device Context', ('name', 'status', 'identifier', 'primary_ip4', 'primary_ip6', 'tags')),
|
|
|
+ ('Tenancy', ('tenant_group', 'tenant'))
|
|
|
+ )
|
|
|
+
|
|
|
+ class Meta:
|
|
|
+ model = VirtualDeviceContext
|
|
|
+ fields = [
|
|
|
+ 'region', 'site_group', 'site', 'location', 'rack', 'device', 'name', 'status', 'identifier',
|
|
|
+ 'primary_ip4', 'primary_ip6', 'tenant_group', 'tenant', 'comments', 'tags'
|
|
|
+ ]
|
|
|
+ widgets = {
|
|
|
+ 'status': StaticSelect(),
|
|
|
+ 'primary_ip4': StaticSelect(),
|
|
|
+ 'primary_ip6': StaticSelect(),
|
|
|
+ }
|