Bug 1649699 - host list --order is a guessing game
Summary: host list --order is a guessing game
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.5.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: 6.6.0
Assignee: Shira Maximov
QA Contact: Peter Dragun
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-14 09:29 UTC by Peter Ondrejka
Modified: 2019-10-22 19:48 UTC (History)
12 users (show)

Fixed In Version: tfm-rubygem-hammer_cli_foreman-0.16.0,rubygem-hammer_cli_foreman-0.17.0.8-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-22 19:48:57 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 11431 Low Closed Include information about fields that can be used for ordering and filtering 2020-06-29 11:03:24 UTC
Foreman Issue Tracker 27602 Normal Resolved Update help information for ordering fields 2020-06-29 11:03:24 UTC

Description Peter Ondrejka 2018-11-14 09:29:18 UTC
Description of problem:
There is no convenient way to tell which keywords will be accepted by 'hammer host list --order' (probably the case of all table ordering in hammer). One would expect the names will somehow resemble the table headers, e.g.: 

 ~]# hammer host list --thin 1
---|--------|------------------|------------|--------------|----------------------
ID | NAME   | OPERATING SYSTEM | HOST GROUP | CONTENT VIEW | LIFECYCLE ENVIRONMENT
...

~]# hammer host list --thin 1 --order 'OPERATING SYSTEM'
400 Bad Request
  the field 'OPERATING' in the order statement is not valid field for search

~]# hammer host list --thin 1 --order 'operating_system'
400 Bad Request
  the field 'operating_system' in the order statement is not valid field for search

[root@smqa-x3550m3-03 ~]# hammer host list --thin 1 --order 'os'
... works

For some fields I'm just unable to find out the keyword or even if they are sortable, for example the host ID, which is ironic as it is mentioned as an example in the 'hammer host list --help':   
--order ORDER  Sort field and order, eg. ‘id DESC’


Version-Release number of selected component (if applicable):
Satellite 6.5 sn 3 but also happens in 6.4


Expected results:
One way to be more helpful here is to provide a list of available keywords in help, or in error message, something like: 
"the field 'OPERATING' in the order statement is not valid field for search (use one of os, ...)"

Comment 2 pm-sat@redhat.com 2018-12-14 11:08:58 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/11431 has been resolved.

Comment 3 Peter Ondrejka 2019-06-12 10:14:36 UTC
I checked with Satellite 6.6 snap 6, the `Search fields` section has been added to the output of `hammer host list -h` and also to the help of list commands for other entities, but at many places it is still missing (organization, location, product, job template, etc.). It is not clear why this pattern emerges.

Also I would change the help for the --order subcommand to refer to the search fields, something like:

 --order ORDER          Sort field and order, eg. ‘name DESC’. See "Search fields" below for the list of valid fields

Comment 4 Bryan Kearney 2019-06-12 12:06:52 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/11431 has been resolved.

Comment 5 Oleh Fedorenko 2019-06-21 12:33:10 UTC
It's not a Hammer issue anymore, since Hammer relies on the API documentation provided by the server, which apparently lacks some documented resources and thus should be updated. I've created an upstream issue: https://projects.theforeman.org/issues/27098

Comment 6 Bryan Kearney 2019-08-13 10:06:08 UTC
Upstream bug assigned to mshira@redhat.com

Comment 7 Bryan Kearney 2019-08-13 10:06:09 UTC
Upstream bug assigned to mshira@redhat.com

Comment 8 Martin Bacovsky 2019-08-27 10:56:44 UTC
The last missing patch was merged upstream: https://github.com/theforeman/hammer-cli-foreman/pull/438

Comment 10 Peter Dragun 2019-09-09 12:36:30 UTC
Comment #3 still persist. Issue https://projects.theforeman.org/issues/27098 is not resolved. This should not be on QA.

Comment 11 Mike McCune 2019-09-12 19:56:17 UTC
Comment #3 is greatly expanding the scope of this bugzilla beyond just 'hammer host list' Can we verify this for *just* the host list and file new bugs for comprehensive update for other commands?

Going to move this back ON_QA for verification that you can order by the "Search fields:" in the host list which appeared to work for me

Comment 12 Peter Ondrejka 2019-09-13 12:13:36 UTC
Hi Mike, the fix also spans beyond 'hammer host list'. I understand the request, though filing bugs separately per subcommand sounds like an overhead, so I suggest just one bug for covering the subcommands that were omitted here.

Comment 13 Peter Dragun 2019-09-16 12:59:08 UTC
Verified on Satellite 6.6 snap 20. Host list in help shows possible arguments for search and order. Creating another bug for other commands as requested.

Comment 14 Bryan Kearney 2019-10-22 19:48:57 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-2019:3172


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