Bug 1253737

Summary: Hammer JSON output not returning valid JSON for simple messages
Product: Red Hat Satellite Reporter: jcallaha
Component: HammerAssignee: Tomas Strachota <tstrachota>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: bbuckingham, bkearney
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/11355
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:43:51 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:

Description jcallaha 2015-08-14 14:24:14 UTC
Description of problem:
Hammer currently does not return valid json, when requested, if the output is a simple message like "____ deleted" or "Activation key copied". 

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

How reproducible:
Always

Steps to Reproduce:
1. Run a command that only returns a message stating that it passed, specifying --output=json
2. View results

Actual results:
hammer --output=json activation-key copy --name=tester --new-name=copykey --organization-id=3
Activation key copied

Expected results:
hammer --output=json activation-key copy --name=tester --new-name=copykey --organization-id=3
{'Message':'Activation key copied'}

Comment 1 Bryan Kearney 2015-08-14 15:35:52 UTC
Created redmine issue http://projects.theforeman.org/issues/11355 from this bug

Comment 3 jcallaha 2015-09-16 20:50:14 UTC
Additionally, if the json output could include the contents of the csv output, it would be even better!

hammer --output=csv activation-key copy --name=tester --new-name=copykey --organization-id=3

Message,Id,Name
Activation key copied,193,copykey

Comment 4 Bryan Kearney 2015-10-02 14:02:31 UTC
Upstream bug assigned to tstrachota

Comment 5 Bryan Kearney 2015-10-21 14:04:33 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/11355 has been closed
-------------
Anonymous
Applied in changeset commit:ca96ee11fb3a2d017659e5a20e8c1fd9fdfe47d2.

Comment 7 jcallaha 2015-11-09 21:49:55 UTC
Verified in upstream.

  RELEASE: Red Hat Enterprise Linux Server release 7.1 (Maipo)
  FOREMAN: 1.11.0-develop
     RUBY: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
   PUPPET: 3.8.4


[root@qe-blade-12 ~]# hammer --output=json activation-key create --name=test --organization-id=1
[Foreman] Password for admin: 
{
  "message": "Activation key created",
  "id": 2,
  "name": "test"
}

Comment 10 Bryan Kearney 2016-07-27 11:43:51 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