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'
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
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, ...)"
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/11431 has been resolved.
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
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