Feature #22389

Hammer output should display context akin to the UI Org/Loc switcher

Added by Eric Helms 9 months ago. Updated 3 months ago.

Hammer core
Target version:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:


If a user has set a default context, for example wanting to always get data from Acme organization, that should be displayed as part of all output when making hammer requests. This would provide contextual information akin to the UI and help users to understand that the data they are viewing is scoped by context. This can help prevent issues where users expectations for data returned are not met.

Related issues

Related to Hammer CLI - Tracker #2823: Tracker for usability issuesNew2013-07-24


#1 Updated by Tomáš Strachota 9 months ago

  • Priority changed from Normal to High
  • Category set to Hammer core

#2 Updated by Tomáš Strachota 9 months ago

#3 Updated by Tomáš Strachota 9 months ago

This is an important feature. Eric, do you know if API responses contain the context? I'd expect it in some headers.

It's crucial to add such information especially to output of list commands and to "not found" error messages across the whole CLI.

#4 Updated by Martin Bacovsky 9 months ago

  • Target version set to 246
  • Assignee set to Martin Bacovsky
  • Status changed from New to Assigned

@Eric would it be acceptable if the information is displayed only in debug mode? I have PR ready to add the current taxonomies to the response headers. The response headers are printed in hammer debug mode. Advantage of this approach is that the taxonomies are displayed for each API subcall we do during the Hammer command execution.

This is what could be seen in the output for each request:

[DEBUG 2018-01-24 12:40:21 API] Response headers: {
                                 :date => "Wed, 24 Jan 2018 12:40:01 GMT",
                               :server => "Apache/2.4.6 (Red Hat Enterprise Linux)",
                      :foreman_version => "",
                  :foreman_api_version => "2",
                 :current_organization => "1; Default Organization",
                     :current_location => "; ANY",

If this is okay, no changes in Hammer are needed and I'll switch the component to Foreman/API

#5 Updated by Tomáš Strachota 9 months ago

Martin, I think we need to display the information on stdout with each info command (and also other commands as I described in my previous comment). This is IMHO to inform users which context they're in.

This feature should use your PR. Can you provide a link, please?

Also available in: Atom PDF