Hey folks, for now I am looking at ManageIQ simply for VM inventory of around 20 Vsphere vcenters. I am currently testing one and trying to wrap my head around the API. I notice the API mostly revolves around VM IDs. So how can I easily get the ID of a VM by name, or cut out the step and get basic information on the VM (power state, CPU, memory, vcenter) by VM name?
@cwb124 have you reviewed: http://manageiq.org/docs/reference/latest/api/overview/query
There are few examples that might be exactly what you’re asking about.
I have and I’m not sure that does what I need. According to the doc, this is how I might query by name:
But I get the following error:
“message”: "attribute “name does not exist”,
Name is most certainly an attribute on a VM.
Why is everything so easy as long as you have a VM ID, but how are you supposed to obtain the ID for the VM you want info about?
The syntax is a little different in the downstream CloudForms docs.
Try adding “expand=resources&attributes=name” and dropping the quotes around the filter parameter. Something like this:
I was able to get that to work on CFME 4.2, but I didn’t test it on the upstream.
I got that working, thanks krain.
When I am able to retrieve VM information via the API, I notice the cpu and memory count and some other pieces of info are missing. I see the info in the GUI so the data is available. Where can I find the documents or list of attributes available to return for a VM? Seems like basic info is missing from the simple API call of /api/vms/102
I think you need to add attributes=hardware, i.e.
There are tons of these attributes so we don’t return them by default, all these other attributes are available via virtual attributes, you can see what’s available for the vms collection by doing an HTTP OPTIONS /api/vms
virtual_attributes and relationships can be queried in addition to the base attributes via the attributes parameter:
hope this helps,