Coverage for virtualization/ui/panels.py: 100%
56 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1from django.utils.translation import gettext_lazy as _
3from netbox.ui import attrs, panels
5#
6# Cluster
7#
10class ClusterPanel(panels.ObjectAttributesPanel):
11 name = attrs.TextAttr('name')
12 type = attrs.RelatedObjectAttr('type', linkify=True)
13 status = attrs.ChoiceAttr('status')
14 description = attrs.TextAttr('description')
15 group = attrs.RelatedObjectAttr('group', linkify=True)
16 tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group')
17 scope = attrs.GenericForeignKeyAttr('scope', linkify=True, nested=True, max_depth=3)
20#
21# Virtual machine types
22#
25class VirtualMachineTypePanel(panels.ObjectAttributesPanel):
26 name = attrs.TextAttr('name')
27 default_platform = attrs.NestedObjectAttr('default_platform', linkify=True, max_depth=3)
28 default_vcpus = attrs.TextAttr('default_vcpus', label=_('Default vCPUs'))
29 default_memory = attrs.TemplatedAttr(
30 'default_memory',
31 template_name='virtualization/virtualmachinetype/attrs/default_memory.html',
32 label=_('Default memory')
33 )
34 description = attrs.TextAttr('description')
37#
38# Virtual machines
39#
42class VirtualMachinePanel(panels.ObjectAttributesPanel):
43 name = attrs.TextAttr('name')
44 virtual_machine_type = attrs.RelatedObjectAttr('virtual_machine_type', linkify=True, label=_('Type'))
45 status = attrs.ChoiceAttr('status')
46 start_on_boot = attrs.ChoiceAttr('start_on_boot')
47 role = attrs.NestedObjectAttr('role', linkify=True, max_depth=3, colored=True)
48 platform = attrs.NestedObjectAttr('platform', linkify=True, max_depth=3)
49 description = attrs.TextAttr('description')
50 serial = attrs.TextAttr('serial', label=_('Serial number'), style='font-monospace', copy_button=True)
51 tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group')
52 config_template = attrs.RelatedObjectAttr('config_template', linkify=True)
53 primary_ip4 = attrs.TemplatedAttr(
54 'primary_ip4',
55 label=_('Primary IPv4'),
56 template_name='virtualization/virtualmachine/attrs/ipaddress.html',
57 )
58 primary_ip6 = attrs.TemplatedAttr(
59 'primary_ip6',
60 label=_('Primary IPv6'),
61 template_name='virtualization/virtualmachine/attrs/ipaddress.html',
62 )
65class VirtualMachinePlacementPanel(panels.ObjectAttributesPanel):
66 title = _('Placement')
68 site = attrs.RelatedObjectAttr('site', linkify=True, grouped_by='group')
69 cluster = attrs.RelatedObjectAttr('cluster', linkify=True, grouped_by='group')
70 cluster_type = attrs.RelatedObjectAttr('cluster.type', linkify=True)
71 device = attrs.RelatedObjectAttr('device', linkify=True)
74#
75# Virtual disks
76#
79class VirtualDiskPanel(panels.ObjectAttributesPanel):
80 virtual_machine = attrs.RelatedObjectAttr('virtual_machine', linkify=True, label=_('Virtual Machine'))
81 name = attrs.TextAttr('name')
82 size = attrs.TemplatedAttr('size', template_name='virtualization/virtualdisk/attrs/size.html')
83 description = attrs.TextAttr('description')
86#
87# VM interfaces
88#
91class VMInterfacePanel(panels.ObjectAttributesPanel):
92 virtual_machine = attrs.RelatedObjectAttr('virtual_machine', linkify=True, label=_('Virtual Machine'))
93 name = attrs.TextAttr('name')
94 enabled = attrs.BooleanAttr('enabled')
95 parent = attrs.RelatedObjectAttr('parent_interface', linkify=True)
96 bridge = attrs.RelatedObjectAttr('bridge', linkify=True)
97 description = attrs.TextAttr('description')
98 mtu = attrs.TextAttr('mtu', label=_('MTU'))
99 mode = attrs.ChoiceAttr('mode', label=_('802.1Q Mode'))
100 qinq_svlan = attrs.RelatedObjectAttr('qinq_svlan', linkify=True, label=_('Q-in-Q SVLAN'))
101 tunnel_termination = attrs.RelatedObjectAttr('tunnel_termination.tunnel', linkify=True, label=_('Tunnel'))
104class VMInterfaceAddressingPanel(panels.ObjectAttributesPanel):
105 title = _('Addressing')
107 primary_mac_address = attrs.TextAttr(
108 'primary_mac_address', label=_('MAC Address'), style='font-monospace', copy_button=True
109 )
110 vrf = attrs.RelatedObjectAttr('vrf', linkify=True, label=_('VRF'))
111 vlan_translation_policy = attrs.RelatedObjectAttr(
112 'vlan_translation_policy', linkify=True, label=_('VLAN Translation')
113 )