Bug 1229818

Summary: CFME 5.4 beta - There seems to be no way of approving an Automation Task in state "Pending Approval"
Product: Red Hat CloudForms Management Engine Reporter: Peter McGowan <pmcgowan>
Component: APIAssignee: abellott
Status: CLOSED ERRATA QA Contact: Taras Lehinevych <tlehinev>
Severity: medium Docs Contact:
Priority: high    
Version: 5.4.0CC: cpelland, dajohnso, gtanzill, jhardy, mkanoor, obarenbo, simaishi, tfitzger, tlehinev
Target Milestone: GA   
Target Release: 5.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: rest:automate:retest
Fixed In Version: 5.6.0.8 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-29 14:56:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Peter McGowan 2015-06-09 17:21:55 UTC
Description of problem:
If I submit an automation request through the RESTful API as a non-admin user, the task is submitted correctly and goes into state 'Pending Approval". As an admin user in the WebUI I can see this task under Automate -> Requests, but there seems to be no way of approving it.

Version-Release number of selected component (if applicable):
5.4.0.4.20150528174021_88cc76c

How reproducible:
Every time

Steps to Reproduce:
1. Submit a an automation task through the RESTful API, specifying a non-admin user:

  post_params = {
    :version => '1.1',
    :uri_parts => {
      :namespace => namespace,
      :class => 'Methods',
      :instance => instance
    },
    :parameters => parameter_hash,
    :requester => {
      :auto_approve => false
    }
  }.to_json
  query = "/api/automation_requests"
  rest_return = RestClient::Request.execute(method: :post, url: url + query, :user => username, \
                :password => password, :headers => {:accept => :json}, :payload => post_params, verify_ssl: false)




Actual results:
The request goes into a "Pending Approval", but there seems to be no way of approving it.

Expected results:
An admin user should be able to see any request marked as Pending Approval, and approve any request.


Additional info:
If I change the :auto_approve => false to :auto_approve => true, I get a 500 Internal Server error back from CloudForms, but the request still seems to be submitted

Comment 2 abellott 2015-10-19 18:55:28 UTC
gmccullo not sure this is API related. I see the problem at hand, created an InspectME automation request, request submitted, in the Automate->Requests page, I see the request details with Approval State "Pending Approval", yet no way to approve as admin. Is there a special entitlement to have to do this or is it to be approved a different way ?  Thanks.

Comment 3 Peter McGowan 2016-02-09 07:21:06 UTC
Interestingly, I created an automation request approval workflow and documented here:

https://pemcg.gitbooks.io/introduction-to-cloudforms-automation/content/chapter21/automation_request_approval.html. 

When an approver receives an email containing a line such as:

"To view this Request go to: https://192.168.1.245/miq_request/show/1000000000125"

They can click on the URI and actually get the ability to approve the automation request; all works as expected. For some reason we just can't approve when we go through Automate -> Requests in the WebUI.

Comment 9 CFME Bot 2016-05-23 22:00:47 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/ccac5fb79c6655bb4c29469000dc36fdbae023d6

commit ccac5fb79c6655bb4c29469000dc36fdbae023d6
Author:     Alberto Bellotti <abellott>
AuthorDate: Fri May 20 12:50:42 2016 -0400
Commit:     Alberto Bellotti <abellott>
CommitDate: Fri May 20 15:46:39 2016 -0400

    [api] Adding support for Automation Request approve/deny
    
    - Support approving or denying automation requests
      on multiple requests when targeting /api/automation_requests
      or single request when targeting /api/automation_requests/:id
    - support action "approve"
    - support action "deny"
    - updated spec/requests/api/automation_requests_spec.rb
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1229818

 .../api_controller/automation_requests.rb          | 22 ++++++++
 config/api.yml                                     | 10 ++++
 spec/requests/api/automation_requests_spec.rb      | 62 ++++++++++++++++++++++
 3 files changed, 94 insertions(+)

Comment 10 Oleg Barenboim 2016-05-24 02:32:50 UTC
Backported to Darga branch.

Comment 11 Taras Lehinevych 2016-06-15 12:13:59 UTC
Verified in 5.6.0.10-rc2.1

Comment 13 errata-xmlrpc 2016-06-29 14:56:35 UTC
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://access.redhat.com/errata/RHBA-2016:1348