I have intermittently run in a situation in which the recomposeVapp API will fail when adding a VM with exception “Unable to perform this action. Contact your cloud administrator”. The root cause seems to be a problem accessing the NFS storage, but regardless of the cause, I need to be able to recover from this situation. The problem I have is that the partially-created VM does not belong to Any VAPP, it appears to be orphaned.
I can delete it from the GUI, but cannot find out how to retrieve it from the API, because iterating through all the children VMs in my VApps will not find it. And I cannot re-create a new one, because it will fail due to a duplicate name.
For now, I am addressing this by assigning a temporary name to the VM until the recompose is done; that way at least not have the permanent name stuck against an un-deletable VM. But I would like to have a better solution. Does anyone know if there is a way to VMs which are in the database but not actually created in VCenter (besides the GUI)?
Hi,
You can list all VMs in vCD by executing the following query from REST API Query Service:
GET /api/query?type=adminVM
This should list VMs in all kinds of states. You can also filter by the name of the VM:
GET /api/query?type=adminVM&filter=name==<vm_name>
Regards,
Todor Todorov
Thanks, Todor. Is there an equivalent using the Java SDK? Also, assuming I am an org-level user would this query work to return just VMs within my org?
Hi,
You can use the Java SDK:
QueryService queryService = client.getQueryService();
queryService.queryVmReferences(); // there're several other queryVm* methods in the Query Service class
Calling the query service with an org level user returns only the VMs in his organization that this user has access to.
Regards,
Todor Todorov