Skip to content

Update netbox_service.py #1421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Conversation

garnser
Copy link

@garnser garnser commented May 22, 2025

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
Copy link
Contributor

@sc68cal sc68cal left a comment

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

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