Skip to content

Conversation

@bnerickson
Copy link

Allow dict parameter query for primary_mac_address in netbox_vm_interface module

  • Allow dict parameter query for primary_mac_address in netbox_vm_interface (str->raw)
  • Add integration tests for adding primary_mac_address to vminterface by id
  • Add changelog fragment
  • A few syntax, spelling, ordering fixes I can remove if requested

Related Issue

#1509

New Behavior

This PR adds the ability to query for a primary_mac_address by ID for vm interfaces. Example of new behavior:

  - name: Update virtual bridge interfaces in netbox (primary_mac_address)
    netbox.netbox.netbox_vm_interface:
      netbox_url: "https://netbox.local"
      netbox_token: "{{ netbox_api_token }}"
      state: present
      data:
        virtual_machine: VM_1
        name: "br0"
        primary_mac_address: 
          id: "71"

This PR also addresses a potential bug. The primary_mac_address was not specified under QUERY_TYPES in netbox_utils.py and as a result querys by ID would also result in matching mac addresses whose value contains the ID number (so if the MAC is 00:01:02:03:42:43 and the ID of another MAC address object is 42, then the query would return both a fail.

Contrast to Current Behavior

Currently, a primary_mac_address may only be assigned by its value.

  - name: Update virtual bridge interfaces in netbox (primary_mac_address)
    netbox.netbox.netbox_vm_interface:
      netbox_url: "https://netbox.local"
      netbox_token: "{{ netbox_api_token }}"
      state: present
      data:
        virtual_machine: VM_1
        name: "br0"
        primary_mac_address: "00:01:02:03:42:43"

Discussion: Benefits and Drawbacks

This is also related to #1413 as-well-as the PR submitted to fix that issue #1464 where duplicate mac addresses meant assigning a primary_mac_address to device interfaces was not always possible. This PR adds that same functionality to vm interfaces. The original behavior of specifying a primary_mac_address by value is still supported.

Proposed Release Note Entry

Allow dict parameter query for primary_mac_address in netbox_vm_interface module.

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

…face

* Allow dict parameter query for primary_mac_address in netbox_vm_interface (str->raw)
* Add integration tests for adding primary_mac_address to vminterface by id
* Add changelog fragment
* A few syntax, spelling, ordering fixes I can remove if requested
@sc68cal
Copy link
Contributor

sc68cal commented Jan 15, 2026

Great, I'll take a look when I get a chance

@sc68cal
Copy link
Contributor

sc68cal commented Jan 17, 2026

I hate doing this but I think the additional cleanups you did need to be pulled out of this and a separate PR since they are not part of the main subject of the PR. Unfortunately because they are combined in the same commit as opposed to being a separate commit I am not able to filter it out. Thank you for doing them, if we could just cherry-pick that commit into a separate branch and a PR, so that I can focus on just the main issue in this PR that would be great. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants