Bug 1368173

Summary: hammer job-template list gives 404 if called with saved default organization or location
Product: Red Hat Satellite Reporter: Peter Ondrejka <pondrejk>
Component: Remote ExecutionAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: arahaman, bbuckingham, bkearney, david.logan, inecas, jcallaha, mmithaiw, oshtaier, rankumar, satellite6-bugs, sjayapra
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1728441 (view as bug list) Environment:
Last Closed: 2017-06-09 10:28:09 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:
Bug Depends On:    
Bug Blocks: 1728441    

Comment 2 Bryan Kearney 2016-08-31 12:19:06 UTC
Upstream bug component is Remote Execution

Comment 3 Bryan Kearney 2016-10-25 12:17:57 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16391 has been resolved.

Comment 6 Oleksandr Shtaier 2017-06-09 10:28:09 UTC
It doesn't seem that 'Default Location' always has id=1. For example in my system:

hammer location list
---|------------------|------------
ID | NAME             | DESCRIPTION
---|------------------|------------
8  | 44Gj1fxh1Y       |            
4  | 7Vq6VhzxUe       |            
2  | Default Location |            

So in case you specify `defaults` in mentioned way you obviously get 404 error:
CLIReturnCodeError: CLIReturnCodeError(return_code=128, stderr=u"[ERROR 2017-06-09 06:21:03 API] 404 Resource Not Found
[ERROR 2017-06-09 06:21:03 Exception] Location with id 1 not found
Location with id 1 not found
[ERROR 2017-06-09 06:21:03 Exception] 
RestClient::ResourceNotFound (404 Resource Not Found)


In case you specify entities that at least exists - functionality works as intended
LANG=en_US.UTF-8  hammer -v -u admin -p changeme  defaults add --param-value="1" --param-name="organization_id"
Added organization_id default-option with value 1.

LANG=en_US.UTF-8  hammer -v -u admin -p changeme  defaults add --param-value="2" --param-name="location_id"
Added location_id default-option with value 2.

LANG=en_US.UTF-8  hammer -v -u admin -p changeme --output=csv job-template list --per-page="10000"
ID,Name,Job Category,Provider,Type
106,Install Errata - Katello SSH Default,Katello,SSH,job_template
107,Install Group - Katello SSH Default,Katello,SSH,job_template
108,Install Package - Katello SSH Default,Katello,SSH,job_template
101,Package Action - SSH Default,Packages,SSH,job_template
102,Power Action - SSH Default,Power,SSH,job_template
103,Puppet Run Once - SSH Default,Puppet,SSH,job_template
131,QoXgGlloNo,Miscellaneous,SSH,job_template
109,Remove Group - Katello SSH Default,Katello,SSH,job_template
110,Remove Package - Katello SSH Default,Katello,SSH,job_template
111,Restart Services - Katello SSH Default,Katello,SSH,job_template
104,Run Command - SSH Default,Commands,SSH,job_template
127,Run OpenSCAP scans,OpenSCAP,SSH,job_template
105,Service Action - SSH Default,Services,SSH,job_template
112,Update Group - Katello SSH Default,Katello,SSH,job_template
113,Update Package - Katello SSH Default,Katello,SSH,job_template


And the same scenario will be persistent for any other entity:
hammer job-template list
Location with id 1 not found

hammer host list
Location with id 1 not found
...

If that problem is a defect - so component should be changed anyway, but in my opinion functionality for job templates works as it should. In case we need to make defaults ignored - then it has to be resolved in scope of another BZ

Comment 7 Oleksandr Shtaier 2017-06-09 10:37:07 UTC
Anyway, defaults seems ignored for list command:

Directly by org id
LANG=en_US.UTF-8  hammer -v -u admin -p changeme --output=csv job-template list --organization-id="23" --per-page="10000"
ID,Name,Job Category,Provider,Type
106,Install Errata - Katello SSH Default,Katello,SSH,job_template
...
112,Update Group - Katello SSH Default,Katello,SSH,job_template
113,Update Package - Katello SSH Default,Katello,SSH,job_template
141,wJFArBlmui,Miscellaneous,SSH,job_template

Using saved org id
LANG=en_US.UTF-8  hammer -v -u admin -p changeme  defaults add --param-value="23" --param-name="organization_id"
Added organization_id default-option with value 23.

LANG=en_US.UTF-8  hammer -v -u admin -p changeme  defaults add --param-value="24" --param-name="location_id"
Added location_id default-option with value 24.

LANG=en_US.UTF-8  hammer -v -u admin -p changeme --output=csv job-template list --per-page="10000"
ID,Name,Job Category,Provider,Type
106,Install Errata - Katello SSH Default,Katello,SSH,job_template
...
112,Update Group - Katello SSH Default,Katello,SSH,job_template
113,Update Package - Katello SSH Default,Katello,SSH,job_template

Comment 13 David Logan 2017-10-12 01:36:22 UTC
Hi,

I logged this bug via RH, I've tried the exact same examples as you showed above prior to closing it as not a bug. Every one of my examples failed as per the bug report. Our satellite system is using

satellite-6.2.9-7.0.el7sat.noarch
satellite-cli-6.2.9-7.0.el7sat.noarch
satellite-installer-6.2.0.13-1.el7sat.noarch

Thanks
David

[root@dcslrhst02 scripts]# hammer -v --output=csv job-template list
[ERROR 2017-10-12 10:56:19 Exception] 404 Resource Not Found
404 Resource Not Found
[ERROR 2017-10-12 10:56:19 Exception]

RestClient::ResourceNotFound (404 Resource Not Found):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:308:in `block in rest_client_call_block'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:228:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:228:in `process_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit'
    /opt/rh/rh-ruby22/root/usr/share/ruby/net/http.rb:853:in `start'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:295:in `call_client'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:224:in `http_call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:174:in `call_action'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:169:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/resource.rb:14:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:280:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:315:in `retrieve_all'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:299:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/bin/hammer:125:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'


[root@dcslrhst02 scripts]# hammer -v --output=csv job-template list --per-page="10000"
[ERROR 2017-10-12 10:56:31 Exception] 404 Resource Not Found
404 Resource Not Found
[ERROR 2017-10-12 10:56:31 Exception]

RestClient::ResourceNotFound (404 Resource Not Found):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:308:in `block in rest_client_call_block'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:228:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:228:in `process_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit'
    /opt/rh/rh-ruby22/root/usr/share/ruby/net/http.rb:853:in `start'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:295:in `call_client'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:224:in `http_call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:174:in `call_action'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:169:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/resource.rb:14:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:280:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:303:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/bin/hammer:125:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'


[root@dcslrhst02 scripts]# hammer -v --output=csv job-template list --per-page="10000" --organisation-id="1"
[ERROR 2017-10-12 10:57:25 Exception] Error: Unrecognised option '--organisation-id'

See: 'hammer job-template list --help'
Error: Unrecognised option '--organisation-id'

See: 'hammer job-template list --help'
[ERROR 2017-10-12 10:57:25 Exception]

Clamp::UsageError (Unrecognised option '--organisation-id'):
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/option/parsing.rb:62:in `find_option'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/option/parsing.rb:28:in `parse_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:53:in `parse'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:32:in `parse'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:67:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/bin/hammer:125:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'


[root@dcslrhst02 scripts]# hammer -v --output=csv job-template list --per-page="10000" --organization-id="1"
[ERROR 2017-10-12 10:57:43 Exception] 404 Resource Not Found
404 Resource Not Found
[ERROR 2017-10-12 10:57:43 Exception]

RestClient::ResourceNotFound (404 Resource Not Found):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:308:in `block in rest_client_call_block'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:228:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:228:in `process_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit'
    /opt/rh/rh-ruby22/root/usr/share/ruby/net/http.rb:853:in `start'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:295:in `call_client'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:224:in `http_call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:174:in `call_action'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:169:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/resource.rb:14:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:280:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:303:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/bin/hammer:125:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'


[root@dcslrhst02 scripts]# hammer -v --output=csv organization list
Id,Name,Label,Description
1,DCS,DCS,""
[root@dcslrhst02 scripts]#

Comment 15 David Logan 2017-11-01 23:19:13 UTC
You keep flagging this as needinfo? Could you please explain to me what you actually need? Is it something from me? If so, what?

Comment 16 Sandeep MJ 2017-11-01 23:33:57 UTC
David,

Sorry, the "needinfo" was intended for Engineering after my internal comment. Apologies for the noise.

Regards,
Sandeep.

Comment 18 Ivan Necas 2018-02-26 12:16:05 UTC
*** Bug 1518033 has been marked as a duplicate of this bug. ***

Comment 19 Red Hat Bugzilla 2023-09-14 23:59:56 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 500 days