Bug 1402646

Summary: [Bug] Hammer command won't accept specified organization name other than the default when .hammer/defaults.yml is configured
Product: Red Hat Satellite Reporter: jalviso <jalviso>
Component: HammerAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WONTFIX QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.2CC: dhlavacd, ess-unisys, mhulan, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-04 17:59:52 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 jalviso 2016-12-08 03:10:06 UTC
Description of problem:

Currently if .hammer/defaults.yml is defined with default organization,
any hammer command run with --organization option other than the default will not be honoured. 

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

How reproducible: Always

Steps to Reproduce:

0. Hammer organization defined:

# hammer organization list
[Foreman] Password for admin: 
---|--------|--------|------------
ID | NAME   | LABEL  | DESCRIPTION
---|--------|--------|------------
1  | redhat | redhat |            
4  | test   | test   |            
---|--------|--------|------------

1. Without hammer defaults configured (example using hostgroup command):

# hammer hostgroup list --organization redhat
[Foreman] Password for admin: 
---|-------------|-------------|------------------|------------------------------|------
ID | NAME        | TITLE       | OPERATING SYSTEM | ENVIRONMENT                  | MODEL
---|-------------|-------------|------------------|------------------------------|------
1  | Development | Development | RedHat 7.2       | KT_redhat_Library_puppetcv_2 |      
---|-------------|-------------|------------------|------------------------------|------

# hammer hostgroup list --organization test
[Foreman] Password for admin: 
---|------|-------|------------------|-------------|------
ID | NAME | TITLE | OPERATING SYSTEM | ENVIRONMENT | MODEL
---|------|-------|------------------|-------------|------
2  | test | test  | RedHat 7.2       |             |      
---|------|-------|------------------|-------------|------


2. With configured hammer default:

# cat .hammer/defaults.yml 
---
:defaults:
  :organization_id:
    :value: '1'
  :location_id:
    :value: '2'

2. Run hammer command specifying other --organization option.

hammer> hostgroup list --organization test
[Foreman] Password for admin: 
---|-------------|-------------|------------------|------------------------------|------
ID | NAME        | TITLE       | OPERATING SYSTEM | ENVIRONMENT                  | MODEL
---|-------------|-------------|------------------|------------------------------|------
1  | Development | Development | RedHat 7.2       | KT_redhat_Library_puppetcv_2 |      
---|-------------|-------------|------------------|------------------------------|------

Actual result: It gives the list of Hostgroup of the default.

3. Run hammer command specifying other organization by --organisation-id

hammer> hostgroup list --organization-id 4
[Foreman] Password for admin: 
---|------|-------|------------------|-------------|------
ID | NAME | TITLE | OPERATING SYSTEM | ENVIRONMENT | MODEL
---|------|-------|------------------|-------------|------
2  | test | test  | RedHat 7.2       |             |      
---|------|-------|------------------|-------------|------

Actual result: It gives the correct list of Hostgroup in organization test(id 4)

Expected result: 

With hammer default.yml configured, we should be able to use
organization by name (not only organization-id) to get correct result.


Additional info:

This is also true to other hammer commands with specified organization name, example:

hammer activation-key create 
hammer activation-key list

Comment 1 Tomas Strachota 2016-12-14 12:39:29 UTC
The issue here is we treat options like --organization and --organization-id separately and "*-id" form takes precedence. Therefore when you save the default for organization_id it always overrides --organization.

At the moment it works only with the same combinations:
- you have organization_id in defaults and override with --organization-id
- you have organization in defaults and override with --organization
cross-combinations fail.

We need to add a connection between the id and name options and properly detect the situations when one overrides the other.

Comment 2 Tomas Strachota 2016-12-14 12:59:15 UTC
Created redmine issue http://projects.theforeman.org/issues/17673 from this bug

Comment 4 Bryan Kearney 2018-09-04 17:59:52 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.