Skip to content

Update netbox_service.py - #1421

Open
garnser wants to merge 1 commit into
netbox-community:develfrom
garnser:devel
Open

garnser wants to merge 1 commit into
netbox-community:develfrom
garnser:devel

Conversation

@garnser

@garnser garnser commented May 22, 2025

Copy link
Copy Markdown

Add support for parent_object_type and parent_object_id in netbox_service.py

Related Issue

New Behavior

  • Extends the NetBox Service module with two new required parameters introduced in NetBox 4.3:
Parameter Type Required Since
parent_object_type str yes 3.22
parent_object_id int yes 3.22
  • Allows users to bind a service directly to any NetBox object type (device, VM interface, IP address, etc.) by specifying its type and primary‑key ID.

Contrast to Current Behavior

  • Prior to NetBox 4.3 the API accepted device, virtual_machine, or similar fixed keys.
  • Without these new fields, the module now fails with “A parent object (type & id) must be specified” errors when talking to NetBox ≥ 4.3.

Discussion: Benefits and Drawbacks

Benefits

  • Restores full compatibility with the current NetBox API.
  • Change is additive, so it remains harmless for NetBox ≤ 4.2 (fields are ignored by the API).

Drawbacks

  • Slightly expands the module interface; playbooks must supply the new params when upgrading to NetBox 4.3+.

Changes to the Documentation

Proposed Release Note Entry

* **netbox_service** – add required NetBox 4.3 fields
  * new parameters: `parent_object_type` (str), `parent_object_id` (int)

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.

Add fields for parent_object_type and parent_object_id since this is required as of Netbox 4.3

@sc68cal sc68cal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to handle the case where the NetBox server is a 4.1 or 4.2 version, similar to how we handle other API comparability issues.

You have made these required fields but they are not valid in older versions. This needs to be addressed

@yodzeb

yodzeb commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

Hi,

Just seen this PR for the same issue i was facing.
I made #1427 for fixing, which i think might be more user-friendly without exposing low-level parameters to the ansible module user.

wdyt ?

@StoffelCPR

Copy link
Copy Markdown
Contributor

As #1427 was merged I guess this can be closed? Or used to fix the inventory module with services (#1430)

This branch has not been deployed

No deployments
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.

4 participants