tag_assign during VM provisioning
Hello,
I am trying to find a way how to assign a tag to a VM during provisioning.
I copied ManageIQ/Cloud/Provisioning/StateMachines/Provision/default instance to my domain and added new post-provisioning method "AssignTag" to the schema.

I have been trying to create a method that should assign a tag to a VM.
Something like that.
vm = $evm.root['vm']
vm.tag_assign("data_center/london")
but it finishes with error because I don't know a way how to fulfil vm variable.
Could somebody provide a code example.
Many thanks
Karel
Responses
It's really important to understand where you are currently in the process to understand how to reference different objects. vm = $evm.root['vm'] is used to get a VM object from context. As written in there, that should work fine in a VM button, because you trigger it from the vm itself. However, when you work with state machines, remember you first generate a request object, then child task objects that will do the job requested initially with the parameters provided. See how vm = $evm.root['miq_provision'].destination is used in "Example - Customising VM Provisioning" in Chapter 15 of the book to reference the recently created vm. I'm not saying it's gonna work rightaway with that replacement, just advising to go back to the book and review how he references different objects in different stages of the process and use Object Walker to see what happens in every stage.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
