Feature #22389

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

Added by Eric Helms over 2 years ago. Updated 12 months ago.

Ready For Testing
Target version:
Bugzilla link:
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 issuesClosed

Related to Foreman - Feature #27092: Add taxonomies headers for API requestsClosed


#1 Updated by Tomáš Strachota over 2 years ago

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

#2 Updated by Tomáš Strachota over 2 years ago

#3 Updated by Tomáš Strachota over 2 years 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 over 2 years 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 over 2 years 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?

#6 Updated by The Foreman Bot over 1 year ago

  • Status changed from Assigned to New

#7 Updated by Shira Maximov 12 months ago

  • Triaged set to No
  • Category deleted (Hammer core)
  • Project changed from Hammer CLI to Foreman

#8 Updated by The Foreman Bot 12 months ago

  • Status changed from New to Ready For Testing
  • Pull request added

#9 Updated by Ondřej Ezr 12 months ago

  • Related to Feature #27092: Add taxonomies headers for API requests added

Also available in: Atom PDF