Bug 1376825 - [RFE] Template API should have provider field
Summary: [RFE] Template API should have provider field
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: 5.7.0
Assignee: Šimon Lukašík
QA Contact: Dave Johnson
URL:
Whiteboard: rest:template
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-16 14:02 UTC by Leo Khomenko
Modified: 2016-09-20 04:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-09-19 06:57:49 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)

Description Leo Khomenko 2016-09-16 14:02:08 UTC
Description of problem:if two or more providers added( RHOS7-GA,rhos6-ga-ssl etc) which have template with the same name (eg - cirros) 
[RESTAPI] GET https://10.8.199.11/api/templates {'filter[]': ["name='cirros'"]}
will give only 1 result, so it's possible to pick template on wrong provider and provision it there. so provider filter could help to solve this (UI template table has this)


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

How reproducible:always


Steps to Reproduce:
1.add 2 providers with the same template name
2.try to get whole list of templates matching your filter

Actual results:it depends on the order in which providers were added - which template you will get


Expected results:get list of templates if there're more than one template matching your filter


Additional info: example of the template we currently have - 
{"href":"https://10.8.199.11/api/templates/1017","id":1017,"vendor":"openstack","name":"cirros","location":"unknown","created_on":"2016-09-15T13:54:10Z","updated_on":"2016-09-15T13:54:10Z","guid":"e10c0a68-7b4b-11e6-a7ea-fa163ee9704b","ems_id":9,"uid_ems":"71469f86-aec6-416c-98b4-b11918709ef3","power_state":"never","state_changed_on":"2016-09-15T13:54:10Z","template":true,"miq_group_id":1,"type":"ManageIQ::Providers::Openstack::CloudManager::Template","ems_ref":"71469f86-aec6-416c-98b4-b11918709ef3","cloud":true,"cloud_tenant_id":3,"raw_power_state":"never","publicly_available":true,"tenant_id":1,"actions":[{"name":"set_ownership","method":"post","href":"https://10.8.199.11/api/templates/1017"},{"name":"delete","method":"delete","href":"https://10.8.199.11/api/templates/1017"}]} 
It's hard to guess, on which provider is it

Comment 2 Šimon Lukašík 2016-09-19 06:57:49 UTC
The provider of the template can be queried by appending 

    &attributes=ext_management_system

to the URL. For example, my testing URL was

    http://localhost:3000/api/templates?filter[]=name="miq-nightly-201609012000"&expand=resources&attributes=ext_management_system
 
That way you get full visibility into what is the template's provider.

I am closing this as not-a-bug. While we could add extra special field for users to query the provider name, we try not to. Every user has slightly different usecase and we soon the defaults would blow-up any limit. We try to provide sane default and offer great customization by querying interface as described in chapter

    1.4. Query Specification

in 

    https://access.redhat.com/documentation/en/red-hat-cloudforms/4.1/red-hat-cloudforms-rest-api/red-hat-cloudforms-rest-api


Lastly, this got my attention

> [RESTAPI] GET https://10.8.199.11/api/templates {'filter[]': ["name='cirros'"]}
> will give only 1 result, 

If you have two templates of the same name, you should have received two results from the API. I did, when I recreated described situation.


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