Commit Graph

183 Commits

Author SHA1 Message Date
Daniel Sheppard
c56a39a168 Fixes: #18449 - Clean up some formatting errors 2025-01-21 10:44:46 -06:00
Jeremy Stretch
343a4af591
Closes #18022: Extend linter (ruff) to enforce line length limit (120 chars) (#18067)
* Enable E501 rule
* Configure ruff formatter
* Reformat migration files to fix line length violations
* Fix various E501 errors
* Move table template code to template_code.py & ignore E501 errors
* Reformat raw SQL
2024-11-21 15:58:11 -05:00
Jeremy Stretch
d2168b107f
Closes #13086: Virtual circuits (#17933)
* WIP

* Add API tests

* Add remaining tests

* Add model docs

* Show virtual circuit connections on interfaces

* Misc cleanup per PR feedback

* Renumber migration

* Support nested terminations for virtual circuit bulk import
2024-11-19 10:58:39 -05:00
bctiemann
353214098b
4867 multiple mac addresses (#17902)
* 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>
2024-11-18 15:11:24 -05:00
Arthur Hanson
9fe6685562
17929 Add Scope Mixins to Prefix (#17930)
* 17929 Add Scope Mixins to Prefix

* 17929 Add Scope Mixins to Prefix

* 17929 fixes for tests

* 17929 merge latest scope changes

* 12596 review changes

* 12596 review changes

* 12596 review changes

* 12596 review changes

* 12596 review changes

* 12596 review changes

* 17929 fix migrations
2024-11-15 14:55:46 -05:00
Arthur Hanson
6dc75d8db1
7699 Add Scope to Cluster (#17848)
* 7699 Add Scope to Cluster

* 7699 Serializer

* 7699 filterset

* 7699 bulk_edit

* 7699 bulk_import

* 7699 model_form

* 7699 graphql, tables

* 7699 fixes

* 7699 fixes

* 7699 fixes

* 7699 fixes

* 7699 fix tests

* 7699 fix graphql tests for clusters reference

* 7699 fix dcim tests

* 7699 fix ipam tests

* 7699 fix tests

* 7699 use mixin for model

* 7699 change mixin name

* 7699 scope form

* 7699 scope form

* 7699 scoped form, fitlerset

* 7699 review changes

* 7699 move ScopedFilterset

* 7699 move CachedScopeMixin

* 7699 review changes

* 7699 review changes

* 7699 refactor mixins

* 7699 _sitegroup -> _site_group

* 7699 update docstring

* Misc cleanup

* Update migrations

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-11-01 14:18:23 -04:00
Jeremy Stretch
8767fd8186
Closes #13428: Q-in-Q VLANs (#17822)
* Initial work on #13428 (QinQ)

* Misc cleanup; add tests for Q-in-Q fields

* Address PR feedback
2024-10-31 14:17:06 -04:00
bctiemann
f74a9a1c76
Fixes: #7336 - VLAN Translation (#17745)
* VLANTranslationPolicy and VLANTranslationRule models and all associated UI classes

* Change VLANTranslationPolicy to a PrimaryModel and make name unique

* Add serializer classes to InterfaceSerializer

* Remake migrations

* Add GraphQL typing

* Skip tagged models in test

* Missing migration

* Remove get_absolute_url methods

* Remove package-lock.json

* Rebuild migration and add constraints and field options

* Rebuild migrations

* Use DynamicModelChoiceField for policy field

* Make vlan_translation_policy fields on filtersets more consistent with existing __name convention

* Add vlan_translation_table to VMInterface detail page

* Add vlan_translation_policy to VMInterfaceSerializer

* Move vlan_translation_policy fields to model and filterset mixins

* Protect in-use policies against deletion

* Add vlan_translation_policy to fields in VMInterfaceSerializer

* Cleanup indentation

* Remove unnecessary ordering column

* Rebuild migrations

* Search methods and registration

* Ensure 'id' column is present by default

* Add graphql types/filters/schema for VLANTranslationRule

* Filterset tests

* View tests

* API and viewset tests (incomplete)

* Add tags to VLANTranslationRuleForm

* Complete viewset tests for VLANTranslationRule

* Make VLANTranslationRule.policy nullable (but still required)

* Revert "Make VLANTranslationRule.policy nullable (but still required)"

This reverts commit 4c1bb437ef.

* Revert nullability

* Explicitly prefetch policy in graphql

* Documentation of new and affected models

* Add note about select_related in graphql

* Rework policy/rule documentation

* Move vlan_translation_policy into 802.1Q Switching fieldset

* Remove redundant InterfaceVLANTranslationTable

* Conditionally include vlan_translation_table in interface.html and vminterface.html

* Add description field to VLANTranslationRule

* Define vlan_translation_table conditionally

* Add policy (name) filter to VLANTranslationRuleFilterSet

* Revert changes to adding-models.md (moved to another PR)

* Dynamic table for linked rules in vlantranslationpolicy.html

* Misc cleanup

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-10-30 17:09:46 -04:00
Jeremy Stretch
256b5dc676 Merge branch 'develop' into feature 2024-10-11 11:29:36 -04:00
Jeremy Stretch
f11dc00fae
Change attr_type from list to str for MultipleChoiceFilter (#17638) 2024-10-03 13:24:00 -04:00
Arthur Hanson
2c68aca344
17195 Add color to PowerOutlet (#17623)
* 17195 Add color to PowerOutlet

* 17195 Add color to PowerOutlet

* Reorder serializer fields

* Misc cleanup

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-10-02 08:51:41 -04:00
Arthur Hanson
8cd0a3215c
16783 Add status field to InventoryItem (#17627)
* 16783 Add status field to InventoryItem

* 16783 fix tests

* 16783 fix tests

* 16783 review changes
2024-09-30 18:26:14 -04:00
Arthur Hanson
829bef041d
11969 remove airflow from racktype (#17324)
* 11969 remove airflow from racktype

* 11969 remove airflow from racktype

* 11969 update docs

* 11969 fix rack edit

* Rename migration

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-08-30 13:30:51 -04:00
Jeremy Stretch
6f7bf5baf4 Merge branch 'develop' into feature 2024-08-29 10:51:38 -04:00
bctiemann
a150e5d561
Fixes: #16905 - Allow filtering on Device Status in InventoryItemTable (#17260)
* Add device_status as filtering option (and configurable column) for InventoryItemTable

* Add device_status to common superclasses for Device Components, and refactor ChoiceFieldColumn to support a "color" callable allowing get_FOO_color behavior to be overridden

* Remove unnecessary 'device_status' in fields

* Add unit tests for device_status
2024-08-29 08:10:30 -04:00
Arthur Hanson
796b9e84af
Closes #10500: Introduce support for nested modules (#16983)
* 10500 add ModularComponentModel

* 10500 add ModularComponentModel

* 10500 add to forms

* 10500 add to serializer, tables

* 10500 template

* 10500 add docs

* 10500 check recursion

* 10500 fix graphql

* 10500 fix conflicting migration from merge

* 10500 token resolution

* 10500 don't return reverse

* 10500 don't return reverse / optimize

* Add ModuleTypeModuleBaysView

* Fix replication of module bays on new modules

* Clean up tables & templates

* Adjust uniqueness constraints

* Correct URL

* Clean up docs

* Fix up serializers

* 10500 add filterset tests

* 10500 add nested validation to Module

* Misc cleanup

* 10500 ModuleBay recursion Test

* 10500 ModuleBay recursion Test

* 10500 ModuleBay recursion Test

* 10500 ModuleBay recursion Test

* Enable MPTT for module bays

* Fix tests

* Fix validation of module token in component names

* Misc cleanup

* Merge migrations

* Fix table ordering

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-08-05 13:13:59 -04:00
Arthur Hanson
d6f2fc7d29
17058 RackType name -> model (#17059)
* 17058 RackType name -> model

* 17058 RackType name -> model

* 17058 fix tests

* 17058 fix tests
2024-08-01 09:06:51 -04:00
Jeremy Stretch
c51e91dddd Closes #17048: Replace all calls to get_user_model() with direct imports of User 2024-08-01 08:17:51 -04:00
Jeremy Stretch
da7d47d3ed Add manufacturer filter for Rack; extend RackFilterForm 2024-07-31 14:06:07 -04:00
Jeremy Stretch
a12fdd6e2d Merge branch 'develop' into feature 2024-07-26 16:39:58 -04:00
Thomas Fargeix
5019a67a61 Fixes 16536 - Fix filtering of device component by device role (#16553)
* Fixes 16536 - Fix filtering of device component by device role

Rename role and role_id fields to device_role and device_role_id in
DeviceComponentFilterSet

* Update tests for DeviceComponentFilterSet

* Use device_role filter name for DeviceComponentFilterSetTests

* Add test_device_role test in InventoryItemTestCase
2024-07-26 16:20:46 -04:00
Arthur Hanson
e62a42286a
11969 airflow (#16967)
* 11960 Add airflow

* 11960 Add airflow

* 11960 fix tests

* 11960 fix racktype form

* 11969 different choices type

* 11969 update docs

* 11969 fix racktype copy

* 11969 fix

* Misc cleanup & reordering of form fields

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-07-25 15:14:02 -04:00
Arthur Hanson
5a6ffde67e
12826 Add Rack Type (#16739)
* 12826 add RackType

* 12826 add forms, filters, tables

* 12826 add to menu

* 12826 remove role

* 12826 add api/serializers

* 12826 add tests and fixes

* 12826 fix tests

* 12826 fix tests

* 12826 fix tests

* 12826 fix tests

* 12826 add device_type to device and instantiation

* 12826 test device creation

* 12826 add slug

* 12826 fix tests

* 12826 fix slug field

* 12826 prevent modification of rack fields if rack_type set

* 12826 update rack fields on rack_type edit

* Misc cleanup

* Update model docs

* Add manufacturer field to RackType

* Add test for mounting_depth

* Rename 'type' to 'form_factor'

* Create base classes for Rack & RackType models, serializers

* Hide RackType-defined fields on RackForm when a rack type is set

* Establish a base filter form for Rack & RackType

* Clean up RackType attr inheritance

* Clean up templates

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-07-16 08:58:22 -04:00
Thomas Fargeix
d39acfd3f2
Fixes 16536 - Fix filtering of device component by device role (#16553)
* Fixes 16536 - Fix filtering of device component by device role

Rename role and role_id fields to device_role and device_role_id in
DeviceComponentFilterSet

* Update tests for DeviceComponentFilterSet

* Use device_role filter name for DeviceComponentFilterSetTests

* Add test_device_role test in InventoryItemTestCase
2024-07-12 09:13:33 -04:00
Jeremy Stretch
02ae91589d Merge branch 'develop' into feature 2024-07-09 15:16:05 -04:00
Julio Oliveira at Encora
c506f60f12
16424 - Allow filtering of Devices by Cluster and Cluster Group (#16674)
* Allow filtering Devices by Cluster and Cluster Group.

* Allow filtering Devices by Cluster and Cluster Group.

* Added tests for cluster and cluster_groups filterset.

* Add missing filter & complete tests

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-06-26 10:13:32 -04:00
Arthur Hanson
c7176e86fc
15410 removed deprecated filters (#16410)
* 15410 removed legacy filters

* 15410 fix tests

* 15410 fix tests
2024-06-07 14:08:30 -04:00
Arthur Hanson
753c4021eb
14948 add has_virtual_device_contexts filter to device (#16209)
* 14948 add has_virtual_device_cnotexts filter to device

* 14948 make singular

* 14948 add test
2024-05-22 11:51:15 -04:00
Jeremy Stretch
a9bb4c5c3e Move choice sets from utilities.choices to netbox.choices 2024-03-22 08:59:52 -04:00
Daniel Sheppard
19f577ccaf
Closes: #13918 - Add facility field (#15456)
* Fixes: #13918 - Add facilities field to Location model.

* Stupidly forgot to `git add`

* Fix errant reference to site.

* Misc cleanup

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-03-18 10:09:50 -04:00
Jeremy Stretch
572efeb987 Ensure all filter labels are translated 2024-03-12 12:14:13 -04:00
Jeremy Stretch
bea32aef71 Declare FilterSet fields as a tuple 2024-03-12 12:08:11 -04:00
Jeremy Stretch
a136030094 Validate filter class for foreign key fields 2024-03-11 14:39:34 -04:00
Jeremy Stretch
b36a70d236 Add missing filters for reverse many-to-many relationships 2024-03-11 14:39:34 -04:00
Jeremy Stretch
6085e0bb0b Test for missing ManyToManyField filters 2024-03-11 14:39:34 -04:00
Jeremy Stretch
5cb7af88d4 Fix remaining tests 2024-03-11 14:39:34 -04:00
Jeremy Stretch
16b422cbac Add missing filters 2024-03-11 14:39:34 -04:00
Jeremy Stretch
d6acc18c29 Closes #15383: Standardize filtering logic for the parents of recursively-nested models 2024-03-11 13:27:57 -04:00
Jeremy Stretch
3ddacf4b88 Merge branch 'develop' into feature 2024-02-21 16:24:23 -05:00
Daniel Sheppard
29f029d480
Fixes: #14058 - Limits platform selection to manufacturer and platforms with no manufacturer (#15183)
* Fixes: #14058 - Limits platform selection to manufacturer and platforms with no manufacturer

* Apply suggestions from code review

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-02-20 09:28:15 -05:00
Jeremy Stretch
d8c6dad9d9 Closes #15099: Remove legacy device_role & device_role_id filters for devices 2024-02-09 15:55:03 -05:00
Jeremy Stretch
224484ebb6
Closes #14434: Add termination object filters for cables (#14617)
* Add termination object filters for cables

* Add tests for new filters
2023-12-28 15:39:14 -05:00
Jeremy Stretch
d5c1cb0ef6 Merge branch 'develop' into feature 2023-12-28 14:20:04 -05:00
Jeremy Stretch
3bacee16bd Closes #14631: Ensure description filters are available on all relevant models 2023-12-28 13:53:16 -05:00
MengYX
359c0cf3a0 Fix typo in filtersets.py
fix typo which causing exception `Cannot resolve keyword 'description_icontains' into field`
2023-12-28 08:47:43 -05:00
Jeremy Stretch
1f2f0860fe Merge branch 'develop' into feature 2023-12-27 16:34:38 -05:00
Jeremy Stretch
8a237561ef Closes #14596: Match against description field when searching for devices 2023-12-27 13:49:39 -05:00
Jeremy Stretch
d2fea4edc4
Closes #14311: Move L2VPN models from ipam to vpn (#14358)
* Move L2VPN and L2VPNTermination models from ipam to vpn

* Move L2VPN resources from ipam to vpn

* Extend migration to update content types

* Misc cleanup
2023-11-28 13:45:00 -05:00
Jeremy Stretch
ac91d4e5e5 Merge branch 'develop' into feature 2023-11-09 16:06:26 -05:00
Artem Kotik
6b89da2233
Closes #13936: Add primary_ip4 and primary_ip6 filters to VirtualMachine and VirtualDeviceContext filtersets (#14203)
* Add primary_ip4 and primary_ip6 filters for VirtualMachine and VirtualDeviceContext filtersets (#13936)

* Add PrimaryIPFilterSet to __all__

---------

Co-authored-by: Artem I. Kotik <artem.i.kotik@ringcentral.com>
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2023-11-09 09:56:43 -05:00