Bug 1244821

Summary: [RFE] Hammer does not report error if configuration file is not found
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: HammerAssignee: Tomas Strachota <tstrachota>
Status: CLOSED ERRATA QA Contact: Sachin Ghai <sghai>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: bbuckingham, mbacovsk, peter.vreman, sghai, sthirugn, xdmoon
Target Milestone: UnspecifiedKeywords: FutureFeature, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/11158
Whiteboard: Verified in Upstream
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 10:59: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:
Bug Depends On:    
Bug Blocks: 260381, 1122832    

Description Peter Vreman 2015-07-20 14:33:04 UTC
Description of problem:

Hammer does not abort or warn the user if the configuration file does not exists. Instead it silently ignores it and switches to interactive mode and asks for the Username and password.

# hammer -c /notexistingfile.conf user list
[Foreman] Username: admin
[Foreman] Password for admin:
---|--------|------------|--------------------------------
ID | LOGIN  | NAME       | EMAIL
---|--------|------------|--------------------------------
3  | admin  | Admin User | root.com
4  | hoici  | hoici      | root@localhost
5  | viewer | viewer     | viewer.hilti.com
---|--------|------------|--------------------------------



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


How reproducible:


Steps to Reproduce:
1. See command above
2.
3.

Actual results:
Interactive input is asked

Expected results:
Abort with an error that the file cannot be found. Alternative is to report a warning and switch to interactive mode

Additional info:

Comment 1 RHEL Program Management 2015-07-20 14:44:45 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Bryan Kearney 2015-07-20 16:06:18 UTC
Created redmine issue http://projects.theforeman.org/issues/11158 from this bug

Comment 4 Martin Bacovsky 2015-07-21 11:03:14 UTC
Config file is optional and interactive mode is turned on by default in hammer so the behaviour you describe is intentional.

Would explicitly turning interactive mode off solve the problem for you?

However I agree that the message hammer prints is not extra helpful and could be improved:

$ hammer --interactive no os list
Invalid username or password

Comment 5 Peter Vreman 2015-07-21 13:40:46 UTC
I expect that when i pass a value for a parameter that the value is still validated, even if the parameter is optional. Therefor i expected a Warning that the supplied configuration file is not found, and then it switches to interactive mode.

Comment 6 Bryan Kearney 2015-08-18 12:45:39 UTC
Upstream bug assigned to tstrachota

Comment 7 Bryan Kearney 2015-08-28 08:04:03 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/11158 has been closed
-------------
Anonymous
Applied in changeset commit:169bffe4b7098027279385dafd98e75110c4dfe9.

Comment 8 Sachin Ghai 2015-09-08 09:44:52 UTC
Verified with upstream:

foreman-release-1.10.0-0.develop.201509041547git84f7fc6.el6.noarch
foreman-1.10.0-0.develop.201509041547git84f7fc6.el6.noarch
katello-2.4.0-6.nightly.el6.noarch
katello-installer-base-2.4.0-1.nightly.201509040043gitb37b92b.el6.noarch
katello-installer-2.4.0-1.nightly.201509040043gitb37b92b.el6.noarch
tfm-rubygem-hammer_cli_foreman-0.3.0-2.201508261233git7334971.el6.noarch
tfm-rubygem-hammer_cli-0.3.0-2.201508280738git8a70aa0.el6.noarch
tfm-rubygem-hammer_cli_katello-0.0.17-4.el6.noarch

Now we can see proper error on passing non-existing config file.

[root@cloud-qe hammerify]# hammer -u admin -p changeme -c /notexistingfile.conf user list
Error: Custom configuration file /notexistingfile.conf does not exist.
[root@cloud-qe hammerify]#

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