Vm.custom_set(key, value) not adding any custom attribute


I’m following @pemcg 's book, “Mastering Automation in CloudForms 4.2 and ManageIQ Euwe”. I just finished the section “Working With Virtual Machines”. I followed the instructions per the book to add a custom attribute to a VM object, and yet when I run the dialog, no Custom Attributes are ever added to the VM Details pane. Logs show no errors (see below).

By the way @pemcg this book is soooooo helpful, THANK you.

$evm.log(:info, "add_custom_attribute started")
vm = $evm.root['vm']

key   = $evm.root['dialog_key']
value = $evm.root['dialog_value']

vm.custom_set(key, value)
exit MIQ_OK

If you post the link or the code people would not have to a) lookup the book b) search the chapter and c) search for the code in the chapter :wink:

Anyway, the AeMethod runs as the logs show. I am guessing that either key or value are nil, due to a typo, what happens is you add $evm.log(:info, "Setting #{key} = #{value}")?

@buc Thanks for the etiquette tip! I’ll be sure to be more considerate next time.

Thanks for your advice about simply logging the key and value. Turns out I had some silly mistakes. (Forgot the “dialog_” prefix when referencing the key and value, plus I was calling $evm.object instead of $evm.root.) Working through that helped strengthen my understanding of those two objects provided by the automate engine. Thanks for your time - I REALLY appreciate it!!

Glad the book is still useful. If you haven’t already found it there’s also an addendum covering the new automate features (and service dialog editor) in CloudForms 4.6 and ManageIQ Gaprindashvili here


Thanks @pemcg!

@pemcg the book is hugely helpful. I appreciate how detailed it is and how it explains not just how to make stuff happen but how the tool works under the hood. I have been drawing diagrams to understand how it all hooks together. It’s a great book.