How to get the result of button request

Hello,

I’ve created some request and tied them to buttons. After pushing “Submit” button I get “Order request was Submitted” message. The request runs as expected. But how to get the result of the request: was it successfull or not?

If you’re submitting an automation request, you could post a notification pop-up to the user with the request status on completion. If it’s an embedded Ansible service that you’re requesting then you should see the results in the service details in "My Services’.

pemcg

1 Like

Thank you for your answer. How can I get that programmaticaly? I neet to access this task result by API.

What type of request & task are you running?

Ansible Tower Job templates and inline methods.
F.e. I have two buttons:

  1. Change VM flavor - inline method, which sets CPU and Mem using vm.set_number_of_cpus and vm.set_memory
  2. Set VM IOPS limit - sets IOPS limit on VM using Ansible Tower Job

Ok, well notifications are fairly straightforward from a Ruby script, and described here. I’d probably suggest running a state machine from your button, where the final state in the state machine is to send the notification. The change VM flavour will be pretty straightforward. For the Tower job template, you need to get the job object and test for job.normalized_live_status to get the status, and then job.raw_stdout will return the raw output from the job.

You might find it easier to use the AnsibleTower/Operations/StateMachines/Job state machine rather than Tower job template methods.

Hope this helps,
pemcg

1 Like