Allow netbox_ip_address module to accept raw json values as assigned objects to deal with duplicate objects
ISSUE TYPE
- Feature Idea
SUMMARY
Allow netbox.netbox.netbox_ip_address module to accept raw json values for assigned_object.
As of right now, any VMs or devices listed as an assigned object to an IP address has to be a string. If there are multiple devices/VMs with the same name, there is no way to differentiate between the multiple objects. An error will occur:
"msg": "More than one result returned for virtual_machine"
STEPS TO REPRODUCE
The netbox.netbox.netbox_vm_interface module is able to handle duplicate virtual machines correctly by accepting raw json values as part of the VM query. By specifying other relevant info such as VM cluster in the json, the API is able to find the correct VM even if there are multiple VMs with the same name. e.g:
netbox.netbox.netbox_vm_interface:
...
data:
# explicitly specify the cluster in case there are multiple VMs with same name
virtual_machine: {"name": "<vm_name>", "cluster": "<cluster_name>"}
It would be great if netbox.netbox.netbox_ip_address (and any other relevant modules) had this same functionality as netbox.netbox.netbox_vm_interface.
Does this solve your issue? passing in dictionaries.
The only caveat to this is that the accepted key/value pairs for dictionaries must follow the fields in ALLOWED_QUERY_PARAMS constant. I've been thinking of incorporating logic into sub dictionaries to allow users to specify their own query_params such as you can do at the top level of each module using query_params
Hey @FragmentedPacket ,
That doesn't work for netbox.netbox.netbox_ip_address :(
The data.assigned_object.virtual_machine parameter is parsed as a string in this module and converts my dictionary into a string.
On the other hand, I've been able to successfully pass in dictionaries with the netbox.netbox.netbox_vm_interface module as the virtual_machine parameter accepts raw input and does not force a string type.
See ip_address vs vm_interface
