Bugfix: Creating two IPs in single run of netbox_ip_address (#56550)
* Found bug, fixed by moving the serialization of objects out of try while creating objects * Added changelog to document fix
This commit is contained in:
parent
a50b3d7695
commit
d07d394779
2 changed files with 9 additions and 2 deletions
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
bugfixes:
|
||||
- >
|
||||
netbox_ip_address - Fixed issue where it would create duplicate IP addresses when trying to serialize the IP address object
|
||||
which doesn't have the ``.serialize()`` method. This should also prevent future duplicate objects being created if they don't
|
||||
have the ``.serialize()`` method as well.
|
|
@ -197,10 +197,11 @@ def create_netbox_object(nb_endpoint, data, check_mode):
|
|||
if check_mode:
|
||||
serialized_nb_obj = data
|
||||
else:
|
||||
nb_obj = nb_endpoint.create(data)
|
||||
try:
|
||||
serialized_nb_obj = nb_endpoint.create(data).serialize()
|
||||
serialized_nb_obj = nb_obj.serialize()
|
||||
except AttributeError:
|
||||
serialized_nb_obj = nb_endpoint.create(data)
|
||||
serialized_nb_obj = nb_obj
|
||||
|
||||
diff = _build_diff(before={"state": "absent"}, after={"state": "present"})
|
||||
return serialized_nb_obj, diff
|
||||
|
|
Loading…
Reference in a new issue