fix: add backwards compatible support for mac_address field #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix adds backwards compatible support for specifying interface mac addresses as
mac_address
in the diode apply changeset api fordcim.interface
andvirtualization.vminterface
. In netbox 4.2 there is really a list of mac addresses associated with an interface and one can be specified as the primary. Until this is supported in diode, themac_address
field specified when applying a change set is treated as the specification of the primary mac address for the object being created or updated.caveats
This does not disassociate any mac addresses ... it just ensures that the specified mac address is present and promotes it to the primary mac address. So a changing mac address would leave a set of old mac addresses associated until multiple associations are supported directly. Alternatively we could make the specified mac address the only associated address? Not sure which is better.
etc
This pull request introduces a new method to handle backward compatibility for MAC addresses in interfaces and updates the relevant tests to ensure this functionality works correctly. The most important changes include adding the
_handle_interface_mac_address_compat
method, updating thepost
method to use this new method, and adding new test cases to verify the backward compatibility.Backward Compatibility for MAC Addresses:
netbox_diode_plugin/api/views.py
: Added the_handle_interface_mac_address_compat
method to handle backward compatibility for MAC addresses in interfaces.Updates to the
post
Method:netbox_diode_plugin/api/views.py
: Updated thepost
method to call_handle_interface_mac_address_compat
fordcim.interface
andvirtualization.vminterface
object types.Test Enhancements:
netbox_diode_plugin/tests/test_api_apply_change_set.py
: ImportedVMInterface
andVirtualMachine
models to test backward compatibility.netbox_diode_plugin/tests/test_api_apply_change_set.py
: Added setup forVirtualMachine
instances.netbox_diode_plugin/tests/test_api_apply_change_set.py
: Added test casestest_create_and_update_interface_with_compat_mac_address_field
andtest_create_and_update_vminterface_with_compat_mac_address_field
to verify the backward compatibility for MAC addresses.