Bug 1540250

Summary: internal server error when configuration_script is requested
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Bill Wei <bilwei>
Status: CLOSED CURRENTRELEASE QA Contact: Parthvi Vala <pvala>
Severity: high Docs Contact:
Priority: medium    
Version: 5.9.0CC: cpelland, gmccullo, nansari, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: api:rest:services
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1552271 (view as bug list) Environment:
Last Closed: 2019-02-11 14:03:38 UTC Type: Bug
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:    
Bug Blocks: 1552271    

Description Martin Kourim 2018-01-30 15:48:39 UTC
Description of problem:
When the "configuration_script" attribute is requested the request fails with internal server error:

{
    "error": {
        "kind": "internal_server_error",
        "message": "Association named 'configuration_script' was not found on Service; perhaps you misspelled it?",
        "klass": "ActiveRecord::AssociationNotFoundError"
    }
}

However the attribute is listed under the "relationships", so it should be possible to requested in the same way as all the other attributes.
See
OPTIONS /api/services


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


How reproducible:
100%


Steps to Reproduce:
1. create service, e.g.
POST /api/services
{ "name": "myservice01" }
2. request the "configuration_script" attribute
GET /api/services?expand=resources&attributes=configuration_script

Comment 2 Greg McCullough 2018-01-31 16:08:45 UTC
The virtual_has_one association 'configuration_script' is defined on the base service/service_template, this is required for reporting and possibly the API.

But the required methods are only available on the Ansible Service sub-classes.

I recommend that we create a empty method at the base service class which returns nil.

Comment 4 CFME Bot 2018-01-31 22:22:15 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/a6558c4723d83c2f00df8b26d4b0b7fd96751eaf

commit a6558c4723d83c2f00df8b26d4b0b7fd96751eaf
Author:     Bill Wei <bilwei>
AuthorDate: Wed Jan 31 16:25:33 2018 -0500
Commit:     Bill Wei <bilwei>
CommitDate: Wed Jan 31 16:33:02 2018 -0500

    Implement #configuration_script because of virtual_has_one relationship
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1540250

 app/models/service.rb       | 3 +++
 spec/models/service_spec.rb | 4 ++++
 2 files changed, 7 insertions(+)

Comment 6 Parthvi Vala 2019-01-03 07:23:02 UTC
FIXED. Verified on 5.10.0.30.