[PR #17902] [MERGED] 4867 multiple mac addresses #15223

Closed
opened 2025-12-30 00:20:42 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17902
Author: @bctiemann
Created: 10/30/2024
Status: Merged
Merged: 11/18/2024
Merged by: @jeremystretch

Base: featureHead: 4867-multiple-mac-addresses


📝 Commits (10+)

  • 44b6270 Create MACAddress model and migrations to convert existing .mac_address fields to standalone objects
  • e0b1c1a Add migrations
  • eed926c Merge branch 'feature' into 4867-multiple-mac-addresses
  • b8572dc All views/filtering working and documentation done; no unit tests yet
  • 5849f8d Merge branch 'feature' into 4867-multiple-mac-addresses
  • 03bc2f3 Redo migrations following VLAN Translation
  • eec59cf Remove mac_address filter fields and add table columns for device/vm
  • 0fc5157 Remove unnecessary "bulk rename"
  • de4cafe Fix filterset tests for Device
  • f64c941 Fix filterset tests for Interface

📊 Changes

46 files changed (+1156 additions, -173 deletions)

View changed files

📝 docs/models/dcim/interface.md (+5 -2)
docs/models/dcim/macaddress.md (+11 -0)
📝 docs/models/virtualization/vminterface.md (+5 -2)
📝 netbox/dcim/api/serializers_/device_components.py (+12 -13)
📝 netbox/dcim/api/serializers_/devices.py (+31 -2)
📝 netbox/dcim/api/urls.py (+3 -0)
📝 netbox/dcim/api/views.py (+10 -0)
📝 netbox/dcim/constants.py (+10 -0)
📝 netbox/dcim/filtersets.py (+99 -3)
📝 netbox/dcim/forms/bulk_edit.py (+27 -7)
📝 netbox/dcim/forms/bulk_import.py (+87 -2)
📝 netbox/dcim/forms/common.py (+11 -5)
📝 netbox/dcim/forms/filtersets.py (+30 -1)
📝 netbox/dcim/forms/model_forms.py (+76 -5)
📝 netbox/dcim/graphql/filters.py (+7 -0)
📝 netbox/dcim/graphql/schema.py (+3 -0)
📝 netbox/dcim/graphql/types.py (+19 -1)
netbox/dcim/migrations/0199_macaddress.py (+36 -0)
netbox/dcim/migrations/0200_populate_mac_addresses.py (+52 -0)
📝 netbox/dcim/models/device_components.py (+28 -6)

...and 26 more files

📄 Description

Closes: #4867

This PR changes the mac_address of an Interface or VMInterface from a simple model field to a many-to-one relationship with a new MACAddress model. This allows many MAC addresses to be associated with a single Interface or VMInterface (with one optionally designated is_primary).

The "MAC Addresses" pageset is grouped under Devices -> Device Components.

Interfaces and VMInterfaces now show an inline table for creation of associated MACAddress objects:

Screenshot 2024-11-05 at 1 43 19 PM

There is a data migration which converts existing mac_address values to concrete MACAddress objects. There is also now a mac_address property on both Interface and VMInterface which reflects the value of the primary (or only) MACAddress associated with the interface, preserving backward compatibility for querying and display.

Filtering by mac_address works as before, acting on the related object's mac_address field.

Note: bulk create of Interfaces and VMInterfaces via POST will create associated MACAddress objects; but bulk edit of those same objects with mac_address specified in the payload is not supported. This is consistent with preexisting unit test coverage of bulk create and edit operations in test_views.py modules; however this is an area for potential future refinement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/17902 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 10/30/2024 **Status:** ✅ Merged **Merged:** 11/18/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `4867-multiple-mac-addresses` --- ### 📝 Commits (10+) - [`44b6270`](https://github.com/netbox-community/netbox/commit/44b627064c4b1bce84148b2bed0cbf1b9624916c) Create MACAddress model and migrations to convert existing .mac_address fields to standalone objects - [`e0b1c1a`](https://github.com/netbox-community/netbox/commit/e0b1c1a8ad1729b109a88e5e6eb21b1cd950b2be) Add migrations - [`eed926c`](https://github.com/netbox-community/netbox/commit/eed926ca7354e817e27bb7ac7c27825a6a5a2462) Merge branch 'feature' into 4867-multiple-mac-addresses - [`b8572dc`](https://github.com/netbox-community/netbox/commit/b8572dc33f8aec9af28a6a8acccf0720927bd85f) All views/filtering working and documentation done; no unit tests yet - [`5849f8d`](https://github.com/netbox-community/netbox/commit/5849f8d2dc66608ef484923f1d63c21fb14f92fb) Merge branch 'feature' into 4867-multiple-mac-addresses - [`03bc2f3`](https://github.com/netbox-community/netbox/commit/03bc2f3a32225e0d2551869c02a78d9d0590d320) Redo migrations following VLAN Translation - [`eec59cf`](https://github.com/netbox-community/netbox/commit/eec59cfd612ac79829bc3d690c579a7546bd867a) Remove mac_address filter fields and add table columns for device/vm - [`0fc5157`](https://github.com/netbox-community/netbox/commit/0fc5157f3b1c0a2a732feac63a592e7d080c7326) Remove unnecessary "bulk rename" - [`de4cafe`](https://github.com/netbox-community/netbox/commit/de4cafe5d0cc670908f4e218e0b29b7e3520129b) Fix filterset tests for Device - [`f64c941`](https://github.com/netbox-community/netbox/commit/f64c941f65e485fccdbaef29af11b5bb474cd66c) Fix filterset tests for Interface ### 📊 Changes **46 files changed** (+1156 additions, -173 deletions) <details> <summary>View changed files</summary> 📝 `docs/models/dcim/interface.md` (+5 -2) ➕ `docs/models/dcim/macaddress.md` (+11 -0) 📝 `docs/models/virtualization/vminterface.md` (+5 -2) 📝 `netbox/dcim/api/serializers_/device_components.py` (+12 -13) 📝 `netbox/dcim/api/serializers_/devices.py` (+31 -2) 📝 `netbox/dcim/api/urls.py` (+3 -0) 📝 `netbox/dcim/api/views.py` (+10 -0) 📝 `netbox/dcim/constants.py` (+10 -0) 📝 `netbox/dcim/filtersets.py` (+99 -3) 📝 `netbox/dcim/forms/bulk_edit.py` (+27 -7) 📝 `netbox/dcim/forms/bulk_import.py` (+87 -2) 📝 `netbox/dcim/forms/common.py` (+11 -5) 📝 `netbox/dcim/forms/filtersets.py` (+30 -1) 📝 `netbox/dcim/forms/model_forms.py` (+76 -5) 📝 `netbox/dcim/graphql/filters.py` (+7 -0) 📝 `netbox/dcim/graphql/schema.py` (+3 -0) 📝 `netbox/dcim/graphql/types.py` (+19 -1) ➕ `netbox/dcim/migrations/0199_macaddress.py` (+36 -0) ➕ `netbox/dcim/migrations/0200_populate_mac_addresses.py` (+52 -0) 📝 `netbox/dcim/models/device_components.py` (+28 -6) _...and 26 more files_ </details> ### 📄 Description ### Closes: #4867 This PR changes the `mac_address` of an Interface or VMInterface from a simple model field to a many-to-one relationship with a new `MACAddress` model. This allows many MAC addresses to be associated with a single Interface or VMInterface (with one optionally designated `is_primary`). The "MAC Addresses" pageset is grouped under Devices -> Device Components. Interfaces and VMInterfaces now show an inline table for creation of associated MACAddress objects: <img width="1073" alt="Screenshot 2024-11-05 at 1 43 19 PM" src="https://github.com/user-attachments/assets/d6ba6fa1-c43f-4f14-92b3-021973e18f1c"> There is a data migration which converts existing `mac_address` values to concrete `MACAddress` objects. There is also now a `mac_address` property on both `Interface` and `VMInterface` which reflects the value of the primary (or only) `MACAddress` associated with the interface, preserving backward compatibility for querying and display. Filtering by `mac_address` works as before, acting on the related object's `mac_address` field. Note: bulk create of Interfaces and VMInterfaces via POST will create associated MACAddress objects; but bulk edit of those same objects with `mac_address` specified in the payload is not supported. This is consistent with preexisting unit test coverage of bulk create and edit operations in `test_views.py` modules; however this is an area for potential future refinement. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:20:42 +01:00
adam closed this issue 2025-12-30 00:20:42 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15223