mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-17 07:36:44 +01:00
* Create MACAddress model and migrations to convert existing .mac_address fields to standalone objects * Add migrations * All views/filtering working and documentation done; no unit tests yet * Redo migrations following VLAN Translation * Remove mac_address filter fields and add table columns for device/vm * Remove unnecessary "bulk rename" * Fix filterset tests for Device * Fix filterset tests for Interface * Fix tests on single-object forms * Fix serializer tests * Fix filterset tests for VMInterface * Fix filterset tests for Device and VirtualMachine * Move new field check into lookup_map iteration * Fix general MACAddress filter tests * Add GraphQL types/filters/schema * Fix bulk edit/create tests (bulk editing Interfaces will be unsupported because of inheritance from ComponentBulkEditForm) * Make mac_address read_only on InterfaceSerializer/VMInterfaceSerializer * Undo unrelated work * Cleanup unused IPAddress derived stuff * API endpoints * Add serializer objects to interface serializers * Clean up unnecessary bulk create forms/views/routes * Add SearchIndex and adjust indexable fields for Interface and VMInterface * Reorganize MACAddress classes out of association with DeviceComponents * Move MACAddressSerializer * Enforce saving only a single is_primary MACAddress per interface/vminterface * Perform is_primary validation on MACAddress model and just check if one already exists for the interface * Remove form-level validation * Fix check for current is_primary setting when reassigning * Model cleanup * Documentation notes and cleanup * Simplify serializer and add ip_addresses * Add to VMInterfaceSerializer too * Style cleanup * Standardize "MAC Address" instead of "MAC" * Remove unused views * Add is_primary field for bulk edit * HTML cleanup and add copy-to-clipboard button * Remove mac_address from Interface and VMInterface bulk-edit forms * Add device and VM filtering * Use combined assigned_object_parent in table to match structure of IPAddressTable * Add GFK fields to MACAddressSerializer * Reorganize "Addressing" sections to remove from proximity to "Device Components" and related groupings * Clean up migrations * Misc cleanup * Add filterset test * Remove mac_address field from interface forms * Designate primary MAC address via a ForeignKey on the interface models * Add serializer fields for primary_mac_address * Update docs --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
69 lines
1.5 KiB
Python
69 lines
1.5 KiB
Python
from netbox.search import SearchIndex, register_search
|
|
from . import models
|
|
|
|
|
|
@register_search
|
|
class ClusterIndex(SearchIndex):
|
|
model = models.Cluster
|
|
fields = (
|
|
('name', 100),
|
|
('description', 500),
|
|
('comments', 5000),
|
|
)
|
|
display_attrs = ('type', 'group', 'status', 'tenant', 'site', 'description')
|
|
|
|
|
|
@register_search
|
|
class ClusterGroupIndex(SearchIndex):
|
|
model = models.ClusterGroup
|
|
fields = (
|
|
('name', 100),
|
|
('slug', 110),
|
|
('description', 500),
|
|
)
|
|
display_attrs = ('description',)
|
|
|
|
|
|
@register_search
|
|
class ClusterTypeIndex(SearchIndex):
|
|
model = models.ClusterType
|
|
fields = (
|
|
('name', 100),
|
|
('slug', 110),
|
|
('description', 500),
|
|
)
|
|
display_attrs = ('description',)
|
|
|
|
|
|
@register_search
|
|
class VirtualMachineIndex(SearchIndex):
|
|
model = models.VirtualMachine
|
|
fields = (
|
|
('serial', 60),
|
|
('name', 100),
|
|
('description', 500),
|
|
('comments', 5000),
|
|
)
|
|
display_attrs = ('site', 'cluster', 'device', 'tenant', 'platform', 'status', 'serial', 'role', 'description')
|
|
|
|
|
|
@register_search
|
|
class VMInterfaceIndex(SearchIndex):
|
|
model = models.VMInterface
|
|
fields = (
|
|
('name', 100),
|
|
('description', 500),
|
|
('mtu', 2000),
|
|
)
|
|
display_attrs = ('virtual_machine', 'description')
|
|
|
|
|
|
@register_search
|
|
class VirtualDiskIndex(SearchIndex):
|
|
model = models.VirtualDisk
|
|
fields = (
|
|
('name', 100),
|
|
('description', 500),
|
|
)
|
|
display_attrs = ('virtual_machine', 'size', 'description')
|