Using REST API to execute automate method


Hi All,

I’m trying to use the REST API to execute a method I’ve created on a specific VM. If I run the method from a Custom Button I have no problems since:

vm = $evm.root[‘vm’]

Returns a VM object and the commands I later run ( set custom ems attributes, add disks etc) work with no problems on the target vm.

If I try to use the REST API, I can see the method being called, but the vm in the code above is nil, even though I’m setting one of my parameters for my vm name, thus it fails. I See the main difference when calling from a custom button and using the rest API is as follows:

From custom button call in the logs:
Automate_RubyTemplate - Root:<$evm.root> Attribute - object_name: Request
Automate_RubyTemplate - Root:<$evm.root> Attribute - vmdb_object_type: vm

From my REST API call in the logs:
AEMethod tag_vm> Automate_RubyTemplate - Root:<$evm.root> Attribute - object_name: add_disk
Root:<$evm.root> Attribute - vmdb_object_type: automation_task

Question is how do I access the vm object I need from an automation_request?

Thanks in advance


If you send the VM name as a parameter of your request, then you can search your VM by name, with some code like this:

if $evm.root['vm'].nil?
  vm_name = $evm.root['vm_name']
  vm = $evm.vmdb('vm').find_by_name(vm_name)
  vm = $evm.root['vm']


The restAPI provides a lot of filtering capabilities, so that you can extract exactly the VM you wish or returns lists of many.

Such as use the sqlfilter parameter to do a select on an object of your choice
Query by tag, to return a list of objects that match your taxonomy.

In this blog you will see demonstrations of using the restAPI.



Great, this worked for me. Thanks.


Note that sqlfilter is removed due to security issues, but it has been replaced by filter with a new special syntax. @abellotti Do we have documentation on that yet?


There is a short write-up in one of the guides


Will be incorporated in the new v2.0 docs.