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
pull/57762/head
Mikhail Yohman 6 years ago committed by Sloane Hertel
parent a50b3d7695
commit d07d394779

@ -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…
Cancel
Save