Bug 1347409 - Service order through API does not auto approve
Summary: Service order through API does not auto approve
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: GA
: 5.7.0
Assignee: abellott
QA Contact: Jan Krocil
URL:
Whiteboard: rest:service
Depends On:
Blocks: 1350903
TreeView+ depends on / blocked
 
Reported: 2016-06-16 18:27 UTC by Fabien Dupont
Modified: 2019-08-06 20:04 UTC (History)
11 users (show)

Fixed In Version: 5.7.0.0
Doc Type: Known Issue
Doc Text:
If a user orders a service through the REST API, they will see that their request stays in the 'Pending' state. Workaround: Copy the following instance to a writeable domain and remove the guard condition: Automate Instance: / ManageIQ / System / Policy / ServiceTemplateProvisionRequest_created guard: ${/#miq_request.process}
Clone Of:
: 1350903 (view as bug list)
Environment:
Last Closed: 2017-01-11 20:09:29 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Fabien Dupont 2016-06-16 18:27:29 UTC
Description of problem:


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


How reproducible: Always


Steps to Reproduce:
1. Order a service through /api/service_catalogs/3/service_templates endpoint with a request object have a requester with auto_approve=true, such as:

content = {
  :action => "order",
  :resource => {
    :href => "http://miq.coe.evenit.info:3000/api/service_catalogs/3/service_templates/2",
    :devops_project_business_unit_id => "428800024",
    :devops_project_name => "api_test2",
    :devops_project_team_development => "development_team_a",
    :devops_project_team_review => "review_team_y",
    :devops_project_team_production => "production_team_1",
  },
  :requester => {
    :user_name => 'admin',
    :auto_approve => true
  },
}

2. The request is created but is pending due to an assertion in /ManageIQ/System/Policy/ServiceTemplateProvisionRequest_created that checks the value of ${/#miq_request.process}. This assertion is always false when deploying from API.

Actual results:
The service orders (without shopping cart) through API are always pending.

Expected results:
The service orders (without shopping cart) through API with auto_approve=true are approved and processed.

Additional info:
Early discussion with ManageIQ team points to this PR: https://github.com/ManageIQ/manageiq/commit/948647176b6dd671062192eae0e45f6220feffb5. But it may not be related.

Comment 3 Greg McCullough 2016-06-17 12:49:30 UTC
Worked with Alberto to track down the issue.  The REST API call creates the request differently then the OpsUI, which works with the new shopping cart logic, is doing it.  They should both use the OpsUI logic.

Code has been tested and once tests are cleaned up we will have a PR available.

Comment 5 CFME Bot 2016-06-17 21:20:52 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/52be816b9ac11515fa31c0ee0e86b166c4a2fa7e

commit 52be816b9ac11515fa31c0ee0e86b166c4a2fa7e
Author:     Alberto Bellotti <abellott>
AuthorDate: Thu Jun 16 17:58:41 2016 -0400
Commit:     Alberto Bellotti <abellott>
CommitDate: Fri Jun 17 16:32:19 2016 -0400

    [api] Fix for service_template order
    
    - Leverages new resource action workflow's submit_request
    - Provides validation
    - Added Service Template validate_order method and orderable? alias
    - Updated rspecs
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1347409

 app/controllers/api_controller/service_orders.rb   |  4 ++
 .../api_controller/service_templates.rb            | 17 +++--
 app/models/service_template.rb                     |  5 ++
 config/api.yml                                     |  2 +
 spec/requests/api/service_catalogs_spec.rb         | 78 ++++++++++++++++++++--
 spec/support/api_spec_helper.rb                    |  4 ++
 6 files changed, 96 insertions(+), 14 deletions(-)

Comment 6 Fabien Dupont 2016-06-18 09:01:39 UTC
Looks good to me. I checked out the commit and my test is ok.

Comment 8 Dave Johnson 2016-06-22 19:31:09 UTC
Taras, lean on Shveta if you need assistance with services.

Comment 10 Satoe Imaishi 2016-06-28 12:53:37 UTC
In fact, it's not backported yet... putting back to ON_DEV.

Comment 11 abellott 2016-06-28 13:17:37 UTC
Odd, PR# 9276 showed backported to darga. I labeled https://github.com/ManageIQ/manageiq/pull/9276 back to darga/yes.


Note You need to log in before you can comment on or make changes to this bug.