Skip to content

Commit f470d34

Browse files
authored
Ensures the idempotency of the Netbox modules when custom_fields are used. (#839)
1 parent 7cb1589 commit f470d34

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,13 @@ def _update_netbox_object(self, data):
12721272
if serialized_nb_obj.get("vcpus") and data.get("vcpus") and version_pre_30:
12731273
updated_obj["vcpus"] = "{0:.2f}".format(data["vcpus"])
12741274

1275+
if serialized_nb_obj.get("custom_fields"):
1276+
serialized_nb_obj["custom_fields"] = {
1277+
key: value
1278+
for key, value in serialized_nb_obj["custom_fields"].items()
1279+
if value is not None
1280+
}
1281+
12751282
if serialized_nb_obj == updated_obj:
12761283
return serialized_nb_obj, None
12771284
else:

0 commit comments

Comments
 (0)