Has anyone found a way to use the REST API Query Parameter “filter” to match ipaddresses when the ipaddresses contain more than 1 value? Trying to accomplish this so I don’t have to search every VM every time I need to find a VM by IP address programatically.
I can find a VM if it has one value for IP this way:
/api/vms?expand=resources&attributes=name,ipaddresses&filter=ipaddresses=‘10.1.1.1’
would return JSON containing the below, for a VM with 1 IP address:
…“ipaddresses”: [
“10.1.1.1”
]
}…
However when I query for an IP from a VM which contains multiple IP addresses:
/api/vms?expand=resources&attributes=name,ipaddresses&filter=ipaddresses=‘10.1.1.2’
…would return 0 objects, not finding the VM which has 2 IP addresses:
…“ipaddresses”: [
“10.1.1.1”,
“10.1.1.2”
],…
I believe multi-valued ipaddresses are considered an Array, causing 0 objects to be returned. And I cannot find a suitable operator for filtering within Arrays in the list of operators for the Manage IQ API:
http://manageiq.org/docs/reference/latest/api/overview/filtering
A “contains” would work great rather than “=” (which returns no results).
Anyone have any suggestions?