Skip to content

Commit 418a7ac

Browse files
committed
allow query params parent_object* for services in netbox_utils
- elif parent == "services": is workaround for Netbox 4.3.0 - 4.4.3 - #20554 GET Parent_object_type wrong data type - integer instead of string Just delete parent_object_type and parent_object_id GET is broken anyway
1 parent 22143dc commit 418a7ac

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
bugfixes:
3+
- add parent_object_type and parent_object_id to services ALLOWED_QUERY_PARAMS
4+
minor_changes:
5+
- add workaround to _build_query_params for services and Netbox 4.3.0 - 4.4.3 (wrong parent_object_type data type)

plugins/module_utils/netbox_utils.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,17 @@
567567
"rir": set(["slug"]),
568568
"role": set(["slug"]),
569569
"route_target": set(["name"]),
570-
"services": set(["device", "virtual_machine", "name", "port", "protocol"]),
570+
"services": set(
571+
[
572+
"device",
573+
"virtual_machine",
574+
"name",
575+
"port",
576+
"protocol",
577+
"parent_object_type",
578+
"parent_object_id",
579+
]
580+
),
571581
"service_template": set(["name"]),
572582
"site": set(["slug", "name"]),
573583
"site_group": set(["slug"]),
@@ -1187,6 +1197,15 @@ def _build_query_params(
11871197
query_dict["device_type_id"] = query_dict.pop("device_type")
11881198
else:
11891199
query_dict["devicetype_id"] = query_dict.pop("device_type")
1200+
# TODO workaround for Netbox 4.3.0 - 4.4.3 - #20554
1201+
# Remove 'elif parent == "services":' block after support for
1202+
# Netbox 4.3.0 - 4.4.3 is removed
1203+
elif parent == "services":
1204+
if self._version_check_greater(
1205+
self.version, "4.3", greater_or_equal=True
1206+
) and self._version_check_greater("4.4.4", self.full_version):
1207+
query_dict.pop("parent_object_id", None)
1208+
query_dict.pop("parent_object_type", None)
11901209

11911210
if not query_dict:
11921211
provided_kwargs = child.keys() if child else module_data.keys()

0 commit comments

Comments
 (0)