Bug 1639413

Summary: When ordering a service via the API the service dialog is not executed
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: APIAssignee: drew uhlmann <duhlmann>
Status: CLOSED ERRATA QA Contact: Parthvi Vala <pvala>
Severity: high Docs Contact:
Priority: high    
Version: 5.9.4CC: dmetzger, obarenbo, prutledg, smallamp, yrudman
Target Milestone: GAKeywords: ZStream
Target Release: 5.9.5   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 5.9.5.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1635673 Environment:
Last Closed: 2018-11-05 14:00:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On: 1635673    
Bug Blocks:    

Comment 2 drew uhlmann 2018-10-15 17:18:04 UTC
https://github.com/ManageIQ/manageiq/pull/18099 is the g specific PR for this...

Comment 3 CFME Bot 2018-10-15 18:37:29 UTC
New commit detected on ManageIQ/manageiq-api/gaprindashvili:

https://github.com/ManageIQ/manageiq-api/commit/28d00c9389c6e4c9a50a1f3882174ae2ec6e7fc0
commit 28d00c9389c6e4c9a50a1f3882174ae2ec6e7fc0
Author:     Brandon Dunne <brandondunne>
AuthorDate: Mon Oct 15 12:40:20 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Mon Oct 15 12:40:20 2018 -0400

    Merge pull request #485 from d-m-u/bz1635673

    Add flag to initialize field default values

    (cherry picked from commit 73eee92f0137aa8546c95e1e25a44e51e901cf90)

    https://bugzilla.redhat.com/show_bug.cgi?id=1639413

 app/controllers/api/mixins/service_templates.rb | 13 +-
 spec/requests/service_catalogs_spec.rb | 25 +-
 spec/requests/service_templates_spec.rb | 23 +-
 3 files changed, 50 insertions(+), 11 deletions(-)

Comment 4 Parthvi Vala 2018-10-29 11:51:35 UTC
FIXED. Verified on 5.9.5.3.20181023135339_256263f.

Steps taken to verify the BZ:
1) Create a new domain, `domain_1`.
2) Create a Method, let's say `method_1`.
3) Create an instance, let's say `instance_1`.
4) Create a Dialog with one static element with some default value, and one dynamic element with the endpoint pointing to `method_1` which returns default value.
5) Create a Catalog, say `catalog_1`.
6) Create a Generic Catalog item under the newly create Catalog, say `catalog_item_1`.
7) Get the `service_catalog` id and `service_template` id.
8) Send the request.

Request: POST https://<ip_address>/api/service_catalogs/1/service_templates/1
Response: {
	"href": "https://<ip_address>/api/service_requests/2",
	"id": "2",
	"description": "Provisioning Service [catalog_item_1] from [catalog_item_1]",
	"approval_state": "pending_approval",
	"type": "ServiceTemplateProvisionRequest",
	"created_on": "2018-10-29T11:21:49Z",
	"updated_on": "2018-10-29T11:21:49Z",
	"requester_id": "1",
	"requester_name": "Administrator",
	"request_type": "clone_to_service",
	"request_state": "pending",
	"message": "Service_Template_Provisioning - Request Created",
	"status": "Ok",
	"options": {
		"dialog": {
			"dialog_static": 2,
			"dialog_dynamic": 7
		},
		"workflow_settings": {
			"resource_action_id": "23",
			"dialog_id": "2"
		},
		"src_id": "1",
		"request_options": {
			"submit_workflow": false,
			"init_defaults": false
		},
		"cart_state": "ordered",
		"requester_group": "EvmGroup-super_administrator"
	},
	"userid": "admin",
	"source_id": "1",
	"source_type": "ServiceTemplate",
	"tenant_id": "1",
	"service_order_id": "2",
	"process": true,
	"service_templates": {
		"count": 0,
		"resources": [],
		"actions": [...]
	}
}



Note:
Find attached `method.rb`, `automation.log`.

Comment 7 Parthvi Vala 2018-10-29 12:02:22 UTC
Edit https://bugzilla.redhat.com/show_bug.cgi?id=1639413#c4 :

I tested with 2 queries, both of which worked fine.

1) POST: https://<ip_address>/api/service_catalogs/:id/service_templates/:id
   Query: { "action": "order"}

2) POST: https://<ip_address>/api/service_catalogs/:id/service_templates/
   Query: { "action" :"order",
            "resources" : {
                   "href" : "https://<ip_address>/api/service_templates/:id"
                    }
          }

Comment 9 errata-xmlrpc 2018-11-05 14:00:33 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/RHSA-2018:3466