Bug 1195180

Summary: API and WebUI Inconsistent full hostgroup naming
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: APIAssignee: orabin
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.7CC: bbuckingham, bkearney, cwelton, jcallaha, orabin, peter.vreman
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/14190
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:38:42 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:
Bug Depends On:    
Bug Blocks: 1122832    
Attachments:
Description Flags
ui search fields none

Description Peter Vreman 2015-02-23 10:37:56 UTC
Description of problem:
The naming of the full hostgroup is inconsistent in both WebUI and API. In total is has 4 different names for the same value:

API
hosts -> hostgroup_name
hostgroups -> title

WebUI search has:
Hosts -> hostgroup_fullname or hostgroup_title field
Host Groups -> label field


API:

# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hostgroups | jq '.results[] | .title' | grep Backup
"crash/Backup"
"crash/Backup/BackupTest"

# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hosts | jq '.results[].hostgroup_name' | grep Backup
"crash/Backup/BackupTest"


WebUI search:

Host Groups page:
"label ~ Backup"

Hosts page:
"hostgroup_fullname ~ Backup"
or
"hostgroup_title ~ Backup"


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


How reproducible:


Steps to Reproduce:
1. Create nested hostgroups
2. Add host to hostgroup
3. Query the full hostgroup name/label

Actual results:
Different field names has to be used


Expected results:
Consistent field name. Preferably label as this is also consistent with the Katello part.


Additional info:

Comment 1 RHEL Program Management 2015-02-23 17:13:33 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 orabin 2016-03-14 15:51:41 UTC
Created redmine issue http://projects.theforeman.org/issues/14190 from this bug

Comment 4 orabin 2016-03-29 13:22:09 UTC
Is this only for searching or would you like to change the name in the results?

Everything you see in the UI for search should also be available in the API so you can search on hostgroup_fullname and hostgroup_title from hosts.
Is one of them missing?

I wouldn't want to remove any options from the api now in case someone is using them.

In the output hostgroup_name is not always the same as hostgroup_title.
If you are using nested hostgroups where B has the parent A then name would be: B and title: A/B.
Do you need the hostgroup_title to also appear in the api result?

Comment 5 Peter Vreman 2016-03-29 16:02:59 UTC
Currently with Sat6.1.8 the API returns correctly 'name' and 'title' for hostgroup query.

[crash] root@li-lc-1017:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hostgroups | jq . | grep Backup
      "title": "crash/Backup",
      "name": "Backup",
      "title": "crash/Backup/BackupTest",
      "name": "BackupTest",


But for hosts API it returns 'hostgroup_name' with the value that belongs in fact to 'hostgroup_title'.

[crash] root@li-lc-1017:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hosts | jq . | grep Backup
      "hostgroup_name": "crash/Backup/BackupTest",


My expectation is that the API for /hosts it shall return also both:

'hostgroup_name'
'hostgroup_title'

with the same values as returned by /hostgroups 'name' and 'title'


My expectation for the WebUI is that in the search bar I can use the same fields as for the API.
Hostgroups: 'name' and 'title' (and not 'label' as this is also not in the API available)
Hosts: 'hostgroup_name' and 'hostgroup_title'

Comment 6 Bryan Kearney 2016-04-12 14:14:00 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14190 has been closed
-------------
Ori Rabin
Applied in changeset commit:a322a96e9a948f3b3638fd8af8b84c4d70bcb4d7.

Comment 7 jcallaha 2016-07-19 18:08:58 UTC
Failed QA in Satellite 6.2 Beta Snap 20.2

The Hosts search UI still uses the field hostgroup_fullname whereas the API uses hostgroup_name in the Hosts path.

See attached image for UI screenshot. 

API - /hosts/
"hostgroup_name": "backup",
"hostgroup_title": "rhel7 libvirt/backup",

API - /hostgroups/
"name": "backup",
"title": "rhel7 libvirt/backup"

Comment 8 jcallaha 2016-07-19 18:09:46 UTC
Created attachment 1181759 [details]
ui search fields

Comment 9 orabin 2016-07-20 13:14:00 UTC
I didn't want to break the api or to remove hostgroup_fullname from the UI so now you can search on both hostgroup_fullname and hostgroup_name in the API and UI.

You don't see hostgroup_name in the list because the option 'hostgroup' already searches on the name so adding it would again give multiple options for the same thing.
I can add it but I wouldn't want to remove hostgroup.

Can you try and search both UI and API with hostgroup_name and hostgroup_fullname?
It's not on the list so it won't autocomplete but it should still search.

If it does and 2 searches on the same thing is ok I can add it to the list.

Comment 10 jcallaha 2016-07-20 19:53:00 UTC
searching with hostgroup_name does work as expected. as you mentioned, it isn't listed in the suggested search fields. this could work for me, but I will ask the reporter if this also meets their intentions.

Comment 11 Peter Vreman 2016-07-21 07:18:34 UTC
The new behaviour as described in https://bugzilla.redhat.com/show_bug.cgi?id=1195180#c7 is ok for me. Using in the query the 'hostgroup' is also intuitive. That the responds then has hostgroup_xxxxxx fields is perfectly fine to have a clear scoping.

The main issues are solved:
 - 'label' vs. 'title'
 - 'hostgroup_name' returning the title instead of name only

For me issue is solved.

Thanks,
Peter

Comment 12 Brad Buckingham 2016-07-21 12:54:37 UTC
Peter thank you for the feedback!  Based on the input, I am going to move the bugzilla back to ON_QA for GA.

Comment 13 jcallaha 2016-07-21 14:37:16 UTC
Based on #11, this can now be marked Verified in Satellite 6.2 Beta Snap 20.3.

Comment 14 Bryan Kearney 2016-07-27 11:38:42 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:1501