|
@@ -27,13 +27,7 @@ from virtualization.models import VirtualMachine
|
|
|
from . import filtersets, forms, tables
|
|
from . import filtersets, forms, tables
|
|
|
from .choices import DeviceFaceChoices
|
|
from .choices import DeviceFaceChoices
|
|
|
from .constants import NONCONNECTABLE_IFACE_TYPES
|
|
from .constants import NONCONNECTABLE_IFACE_TYPES
|
|
|
-from .models import (
|
|
|
|
|
- Cable, CablePath, ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
|
|
|
|
|
- DeviceBayTemplate, DeviceRole, DeviceType, FrontPort, FrontPortTemplate, Interface, InterfaceTemplate,
|
|
|
|
|
- InventoryItem, Manufacturer, Module, ModuleBay, ModuleBayTemplate, ModuleType, PathEndpoint, Platform, PowerFeed,
|
|
|
|
|
- PowerOutlet, PowerOutletTemplate, PowerPanel, PowerPort, PowerPortTemplate, Rack, Location, RackReservation,
|
|
|
|
|
- RackRole, RearPort, RearPortTemplate, Region, Site, SiteGroup, VirtualChassis,
|
|
|
|
|
-)
|
|
|
|
|
|
|
+from .models import *
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceComponentsView(generic.ObjectChildrenView):
|
|
class DeviceComponentsView(generic.ObjectChildrenView):
|
|
@@ -51,10 +45,21 @@ class DeviceComponentsView(generic.ObjectChildrenView):
|
|
|
class DeviceTypeComponentsView(DeviceComponentsView):
|
|
class DeviceTypeComponentsView(DeviceComponentsView):
|
|
|
queryset = DeviceType.objects.all()
|
|
queryset = DeviceType.objects.all()
|
|
|
template_name = 'dcim/devicetype/component_templates.html'
|
|
template_name = 'dcim/devicetype/component_templates.html'
|
|
|
|
|
+ viewname = None # Used for return_url resolution
|
|
|
|
|
|
|
|
def get_children(self, request, parent):
|
|
def get_children(self, request, parent):
|
|
|
return self.child_model.objects.restrict(request.user, 'view').filter(device_type=parent)
|
|
return self.child_model.objects.restrict(request.user, 'view').filter(device_type=parent)
|
|
|
|
|
|
|
|
|
|
+ def get_extra_context(self, request, instance):
|
|
|
|
|
+ if self.viewname:
|
|
|
|
|
+ return_url = reverse(self.viewname, kwargs={'pk': instance.pk})
|
|
|
|
|
+ else:
|
|
|
|
|
+ return_url = instance.get_absolute_url()
|
|
|
|
|
+ return {
|
|
|
|
|
+ 'active_tab': f"{self.child_model._meta.verbose_name_plural.replace(' ', '-')}",
|
|
|
|
|
+ 'return_url': return_url,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class ModuleTypeComponentsView(DeviceComponentsView):
|
|
class ModuleTypeComponentsView(DeviceComponentsView):
|
|
|
queryset = ModuleType.objects.all()
|
|
queryset = ModuleType.objects.all()
|
|
@@ -806,42 +811,49 @@ class DeviceTypeConsolePortsView(DeviceTypeComponentsView):
|
|
|
child_model = ConsolePortTemplate
|
|
child_model = ConsolePortTemplate
|
|
|
table = tables.ConsolePortTemplateTable
|
|
table = tables.ConsolePortTemplateTable
|
|
|
filterset = filtersets.ConsolePortTemplateFilterSet
|
|
filterset = filtersets.ConsolePortTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_consoleports'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypeConsoleServerPortsView(DeviceTypeComponentsView):
|
|
class DeviceTypeConsoleServerPortsView(DeviceTypeComponentsView):
|
|
|
child_model = ConsoleServerPortTemplate
|
|
child_model = ConsoleServerPortTemplate
|
|
|
table = tables.ConsoleServerPortTemplateTable
|
|
table = tables.ConsoleServerPortTemplateTable
|
|
|
filterset = filtersets.ConsoleServerPortTemplateFilterSet
|
|
filterset = filtersets.ConsoleServerPortTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_consoleserverports'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypePowerPortsView(DeviceTypeComponentsView):
|
|
class DeviceTypePowerPortsView(DeviceTypeComponentsView):
|
|
|
child_model = PowerPortTemplate
|
|
child_model = PowerPortTemplate
|
|
|
table = tables.PowerPortTemplateTable
|
|
table = tables.PowerPortTemplateTable
|
|
|
filterset = filtersets.PowerPortTemplateFilterSet
|
|
filterset = filtersets.PowerPortTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_powerports'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypePowerOutletsView(DeviceTypeComponentsView):
|
|
class DeviceTypePowerOutletsView(DeviceTypeComponentsView):
|
|
|
child_model = PowerOutletTemplate
|
|
child_model = PowerOutletTemplate
|
|
|
table = tables.PowerOutletTemplateTable
|
|
table = tables.PowerOutletTemplateTable
|
|
|
filterset = filtersets.PowerOutletTemplateFilterSet
|
|
filterset = filtersets.PowerOutletTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_poweroutlets'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypeInterfacesView(DeviceTypeComponentsView):
|
|
class DeviceTypeInterfacesView(DeviceTypeComponentsView):
|
|
|
child_model = InterfaceTemplate
|
|
child_model = InterfaceTemplate
|
|
|
table = tables.InterfaceTemplateTable
|
|
table = tables.InterfaceTemplateTable
|
|
|
filterset = filtersets.InterfaceTemplateFilterSet
|
|
filterset = filtersets.InterfaceTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_interfaces'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypeFrontPortsView(DeviceTypeComponentsView):
|
|
class DeviceTypeFrontPortsView(DeviceTypeComponentsView):
|
|
|
child_model = FrontPortTemplate
|
|
child_model = FrontPortTemplate
|
|
|
table = tables.FrontPortTemplateTable
|
|
table = tables.FrontPortTemplateTable
|
|
|
filterset = filtersets.FrontPortTemplateFilterSet
|
|
filterset = filtersets.FrontPortTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_frontports'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypeRearPortsView(DeviceTypeComponentsView):
|
|
class DeviceTypeRearPortsView(DeviceTypeComponentsView):
|
|
|
child_model = RearPortTemplate
|
|
child_model = RearPortTemplate
|
|
|
table = tables.RearPortTemplateTable
|
|
table = tables.RearPortTemplateTable
|
|
|
filterset = filtersets.RearPortTemplateFilterSet
|
|
filterset = filtersets.RearPortTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_rearports'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypeModuleBaysView(DeviceTypeComponentsView):
|
|
class DeviceTypeModuleBaysView(DeviceTypeComponentsView):
|
|
@@ -854,6 +866,7 @@ class DeviceTypeDeviceBaysView(DeviceTypeComponentsView):
|
|
|
child_model = DeviceBayTemplate
|
|
child_model = DeviceBayTemplate
|
|
|
table = tables.DeviceBayTemplateTable
|
|
table = tables.DeviceBayTemplateTable
|
|
|
filterset = filtersets.DeviceBayTemplateFilterSet
|
|
filterset = filtersets.DeviceBayTemplateFilterSet
|
|
|
|
|
+ viewname = 'dcim:devicetype_devicebays'
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceTypeEditView(generic.ObjectEditView):
|
|
class DeviceTypeEditView(generic.ObjectEditView):
|