Description of problem: When we call automate substitution we can only call methods that don't take any arguments. If you call a method that takes arguments, the substitution fails. Version-Release number of selected component (if applicable): 5.5.6 How reproducible: 100% Steps to Reproduce: 1. During provisioning, have the automate model that gets the requesters email 2. my_email = ${/#miq_request.get_option(:email)} 3. Make sure that you have the requesters email properly filled in Actual results: the get_option call fails Expected results: my_email should have the valid email address from the request Additional info:
https://github.com/ManageIQ/manageiq/pull/8941
${/#miq_request.get_option(:owner_email)} Is this being tested with the miq_request object passed into Automation Request. Also is the owner_email present in the request options hash. Can you provide the automation log after the test is run.
Gave value for owner_email in below method def requester_email_address owner_email = "sshveta" email = requester.email || owner_email || $evm.object['to_email_address'] $evm.log(:info, "To email: #{email}") email end Got email. Please check if this verification is good .
Where is the substitution happening, is it defined in the model. Also instead of using the || you should be just using the attribute that stores the substituted value. e.g. Say the requesters email address is requester Change class schema to add a variable called test_email and also a method like check_method that you can call to check test_email = ${/#miq_request.get_option(:email)} check_method = /SomeNamespace/SomeClass/SomeInstance/SomeMethod in the SomeMethod script you would put something like this if $evm.object['test_email'] == 'requester' $evm.log(:info, "Test passed") else raise "email test failed" end
I don't think the request option has :email key instead its called :owner_email. So in the above script the substitution should look like test_email = ${/#miq_request.get_option(:owner_email)}
Getting this in logs : -=========================== [----] I, [2016-11-15T15:04:15.338977 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Following Relationship [miqaedb:/test/test/test#create] [----] I, [2016-11-15T15:04:15.390099 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Updated namespace [miqaedb:/test/test/test#create mfdomain/test] [----] W, [2016-11-15T15:04:15.417890 #2769:5cb14c] WARN -- : Q-task_id([miq_provision_7]) Error during substitution: undefined method `get_option' for nil:NilClass [----] I, [2016-11-15T15:04:15.445892 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Updated namespace [test/test/print_value mfdomain/test] [----] I, [2016-11-15T15:04:15.457056 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Invoking [inline] method [/mfdomain/test/test/print_value] with inputs [{}] [----] I, [2016-11-15T15:04:15.458583 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) <AEMethod [/mfdomain/test/test/print_value]> Starting [----] I, [2016-11-15T15:04:16.195202 #2769:4f72b24] INFO -- : Q-task_id([miq_provision_7]) <AEMethod print_value> TESTTEST [----] I, [2016-11-15T15:04:16.227358 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) <AEMethod [/mfdomain/test/test/print_value]> Ending [----] I, [2016-11-15T15:04:16.227588 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Method exited with rc=MIQ_OK [----] I, [2016-11-15T15:04:16.229449 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Followed Relationship [miqaedb:/test/test/test#create] [----] I, [2016-11-15T15:04:16.229668 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Processed State=[RegisterAD] with Result=[ok] [----] I, [2016-11-15T15:04:16.229864 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Processed State =[RegisterAD] [----] I, [2016-11-15T15:04:16.230194 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) In State=[RegisterAD], invoking [on_exit] method=[update_provision_status(status => 'Registered ActiveDirectory')] [----] I, [2016-11-15T15:04:16.708983 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Updated namespace [Infrastructure/VM/Provisioning/StateMachines/VMProvision_vm/update_provision_status ManageIQ/Infrastructure/VM/Provisioning/StateMachines] [----] I, [2016-11-15T15:04:16.815388 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Invoking [inline] method [/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/VMProvision_VM/update_provision_status] with inputs [{"status"=>"Registered ActiveDirectory"}] [----] I, [2016-11-15T15:04:16.816372 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) <AEMethod [/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/VMProvision_VM/update_provision_status]> Starting [----] I, [2016-11-15T15:04:18.068246 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) <AEMethod [/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/VMProvision_VM/update_provision_status]> Ending [----] I, [2016-11-15T15:04:18.068408 #2769:5cb14c] INFO -- : Q-task_id([miq_provision_7]) Method exited with rc=MIQ_OK
Please check appliance : https://10.8.199.47
Hi, How are you starting the Automation Request, is there an miq_request object being passed into Automate. It seems like there isn't an miq_request object in the workspace.
Hello, I tested this on your environment I needed to make the following changes (1) The logged in user didn't have an email address so I had to set it to a (2) During the substitution we should be using miq_provision instead of miq_request ${/#miq_provision.get_option(:owner_email)} With these 2 changes, I was able to run your test <AEMethod print_value> TESTTEST a [----] I, [2016-11-18T13:56:15.327123 #2795:11cd134] INFO -- : Q-task_id([miq_provision_19]) Invoking [inline] method [/mfdomain/test/test/print_value] with inputs [{}] [----] I, [2016-11-18T13:56:15.327822 #2795:11cd134] INFO -- : Q-task_id([miq_provision_19]) <AEMethod [/mfdomain/test/test/print_value]> Starting [----] I, [2016-11-18T13:56:15.975260 #2795:553fa20] INFO -- : Q-task_id([miq_provision_19]) <AEMethod print_value> TESTTEST a [----] I, [2016-11-18T13:56:15.997660 #2795:11cd134] INFO -- : Q-task_id([miq_provision_19]) <AEMethod [/mfdomain/test/test/print_value]> Ending Thanks, Madhu
Verifying based on above comment. 5.7.0.11-rc1.20161115160629_46cf4f1
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2017-0012.html