Bug 1920224

Summary: hammer content-view list --organization <ORG NAME> seems to show always the result for ORG with ID 1
Product: Red Hat Satellite Reporter: Rafael Cavalcanti <rcavalca>
Component: HammerAssignee: Oleh Fedorenko <ofedoren>
Status: CLOSED MIGRATED QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: ahumbe, apatel, gpadholi, kgaikwad, lhellebr, msunil, ofedoren, pcreech, zhunting
Target Milestone: streamKeywords: MigratedToJIRA, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_foreman-2.5.1.1-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 00:45:07 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 Rafael Cavalcanti 2021-01-25 20:12:20 UTC
Description of problem:
hammer content-view  list --organization <ORG NAME> always shows the CV's related to ORG with ID=1

---
From hammer -d:
[ INFO 2021-01-25T14:56:19 HammerCLIKatello::ContentView::ListCommand] Called with options: {"option_organization_name"=>"Import", "option_organization_id"=>"1"}
[ INFO 2021-01-25T14:56:19 API] Server: https://recife.rguerra.lab
[ INFO 2021-01-25T14:56:19 API] GET /katello/api/organizations/1/content_views


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


How reproducible:


Steps to Reproduce:
1. List all orgs:
---
hammer organization list
---|----------|----------|-------------|---------
ID | TITLE    | NAME     | DESCRIPTION | LABEL   
---|----------|----------|-------------|---------
1  | ACME     | ACME     |             | ACME    
5  | Export   | Export   |             | Export  
6  | Import   | Import   |             | Import  
8  | new_one  | new_one  |             | new_one 
4  | NO_Repos | NO_Repos |             | NO_Repos
---|----------|----------|-------------|---------
---

2. Run 'hammer content-view  list --organization <Org Name>' using an ORG NAME with ID other than 1.
---
hammer content-view  list --organization Export
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS              
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
10              | CAP68                     | CAP68                     | false     | 2020/12/11 01:35:43 | 91, 10, 89, 2, 90, 7        
6               | CCV-1                     | CCV-1                     | true      | 2020/09/24 13:58:41 |                             
4               | CV-Ansible                | CV-Ansible                | false     | 2020/09/16 16:11:18 | 6                           
3               | CV-CAP67                  | CV-CAP67                  | false     | 2020/10/08 14:49:51 | 6, 13, 10, 1, 2, 4, 7, 8, 48
9               | CV-HPC-76                 | CV-HPC-76                 | false     | 2020/10/14 18:07:05 | 76, 74, 75                  
12              | cv-puppet                 | cv-puppet                 | false     | 2020/12/21 17:48:33 |                             
13              | cv-sattools-rhel6         | cv-sattools-rhel6         | false     | 2020/12/22 18:34:06 | 3                           
1               | Default Organization View | Default_Organization_View | false     | 2020/09/14 20:04:58 |                             
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------



3. Run 'hammer content-view  list --organization <Org Name>' using an ORG NAME with ID = 1.
---
hammer content-view  list --organization ACME
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS              
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
10              | CAP68                     | CAP68                     | false     | 2020/12/11 01:35:43 | 91, 10, 89, 2, 90, 7        
6               | CCV-1                     | CCV-1                     | true      | 2020/09/24 13:58:41 |                             
4               | CV-Ansible                | CV-Ansible                | false     | 2020/09/16 16:11:18 | 6                           
3               | CV-CAP67                  | CV-CAP67                  | false     | 2020/10/08 14:49:51 | 6, 13, 10, 1, 2, 4, 7, 8, 48
9               | CV-HPC-76                 | CV-HPC-76                 | false     | 2020/10/14 18:07:05 | 76, 74, 75                  
12              | cv-puppet                 | cv-puppet                 | false     | 2020/12/21 17:48:33 |                             
13              | cv-sattools-rhel6         | cv-sattools-rhel6         | false     | 2020/12/22 18:34:06 | 3                           
1               | Default Organization View | Default_Organization_View | false     | 2020/09/14 20:04:58 |                             
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
---

Actual results:
Hammer returns the output related to ORG with ID=1.
---
hammer content-view  list --organization ACME
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS              
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
10              | CAP68                     | CAP68                     | false     | 2020/12/11 01:35:43 | 91, 10, 89, 2, 90, 7        
6               | CCV-1                     | CCV-1                     | true      | 2020/09/24 13:58:41 |                             
4               | CV-Ansible                | CV-Ansible                | false     | 2020/09/16 16:11:18 | 6                           
3               | CV-CAP67                  | CV-CAP67                  | false     | 2020/10/08 14:49:51 | 6, 13, 10, 1, 2, 4, 7, 8, 48
9               | CV-HPC-76                 | CV-HPC-76                 | false     | 2020/10/14 18:07:05 | 76, 74, 75                  
12              | cv-puppet                 | cv-puppet                 | false     | 2020/12/21 17:48:33 |                             
13              | cv-sattools-rhel6         | cv-sattools-rhel6         | false     | 2020/12/22 18:34:06 | 3                           
1               | Default Organization View | Default_Organization_View | false     | 2020/09/14 20:04:58 |                             
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------


Expected results:
Shows the output related to the ORG NAME.

Additional info:

Passing the ORG ID to the command instead of the ORG NAME, hammer shows the expected result:
---
hammer content-view  list --organization-id 1
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS              
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------
10              | CAP68                     | CAP68                     | false     | 2020/12/11 01:35:43 | 91, 10, 89, 2, 90, 7        
6               | CCV-1                     | CCV-1                     | true      | 2020/09/24 13:58:41 |                             
4               | CV-Ansible                | CV-Ansible                | false     | 2020/09/16 16:11:18 | 6                           
3               | CV-CAP67                  | CV-CAP67                  | false     | 2020/10/08 14:49:51 | 6, 13, 10, 1, 2, 4, 7, 8, 48
9               | CV-HPC-76                 | CV-HPC-76                 | false     | 2020/10/14 18:07:05 | 76, 74, 75                  
12              | cv-puppet                 | cv-puppet                 | false     | 2020/12/21 17:48:33 |                             
13              | cv-sattools-rhel6         | cv-sattools-rhel6         | false     | 2020/12/22 18:34:06 | 3                           
1               | Default Organization View | Default_Organization_View | false     | 2020/09/14 20:04:58 |                             
----------------|---------------------------|---------------------------|-----------|---------------------|-----------------------------

 hammer content-view  list --organization-id 5
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                                | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
14              | cv_test                   | cv_test                              | false     | 2021/01/24 18:30:18 | 61, 60        
7               | Default Organization View | 197e3103-eafd-467b-8137-35c9927aa088 | false     | 2020/09/28 21:39:56 |               
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------

By passing the ORG ID, it does the right API call:
---
GET /katello/api/organizations/5/content_views
---

Comment 1 Oleh Fedorenko 2021-04-20 12:03:44 UTC
Hello Rafael,

I've just tried similar commands in Satellite 6.8.4 and it seems to be working as expected:

> hammer content-view list
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                                | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
2               | Default Organization View | ba1aa9f4-489c-448e-ab1c-631a0b5d22cb | false     | 2021/04/20 11:48:02 |               
1               | Default Organization View | Default_Organization_View            | false     | 2021/02/25 15:56:09 |               
3               | testcv                    | testcv                               | false     |                     |               
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
> hammer content-view list --organization testorg
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                                | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
2               | Default Organization View | ba1aa9f4-489c-448e-ab1c-631a0b5d22cb | false     | 2021/04/20 11:48:02 |               
3               | testcv                    | testcv                               | false     |                     |               
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
> hammer content-view list --organization "Default Organization"
----------------|---------------------------|---------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|---------------------------|-----------|---------------------|---------------
1               | Default Organization View | Default_Organization_View | false     | 2021/02/25 15:56:09 |               
----------------|---------------------------|---------------------------|-----------|---------------------|---------------

Can you please verify if this was fixed since version 6.8.4? Also, if you will face this issue again, could you please provide "hammer defaults list" command output?

Comment 2 Rafael Cavalcanti 2021-04-21 13:03:48 UTC
Hello Oleh,

Thanks for looking into this and apologies for missing the defaults information.
This behavior is happening when the 'hammer defaults' is set.

1) With defauls:
---
# hammer content-view  list --organization rguerra_org2
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS   
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
8               | cv-app-capsule            | cv-app-capsule            | false     | 2021/02/11 22:21:39 | 1, 2, 6, 7, 8, 10
7               | cv-os-rhel-6Server        | cv-os-rhel-6Server        | false     | 2021/04/15 00:42:13 | 43, 44, 85       
2               | cv-os-rhel-7Server        | cv-os-rhel-7Server        | false     | 2021/04/14 21:06:24 | 2, 8             
5               | cv-os-rhel-82kickstart    | cv-os-rhel-82kickstart    | false     | 2020/12/06 04:39:16 | 34, 35           
4               | cv-os-rhel-83-kickstart   | cv-os-rhel-83-kickstart   | false     | 2020/12/04 22:16:08 | 26, 27           
3               | cv-os-rhel-8Server        | cv-os-rhel-8Server        | false     | 2020/11/10 01:53:39 | 4, 5, 9          
6               | cv-test-delete            | cv-test-delete            | false     |                     |                  
1               | Default Organization View | Default_Organization_View | false     | 2020/11/09 01:49:24 |                  
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
# hammer content-view  list --organization rguerra_org
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS   
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
8               | cv-app-capsule            | cv-app-capsule            | false     | 2021/02/11 22:21:39 | 1, 2, 6, 7, 8, 10
7               | cv-os-rhel-6Server        | cv-os-rhel-6Server        | false     | 2021/04/15 00:42:13 | 43, 44, 85       
2               | cv-os-rhel-7Server        | cv-os-rhel-7Server        | false     | 2021/04/14 21:06:24 | 2, 8             
5               | cv-os-rhel-82kickstart    | cv-os-rhel-82kickstart    | false     | 2020/12/06 04:39:16 | 34, 35           
4               | cv-os-rhel-83-kickstart   | cv-os-rhel-83-kickstart   | false     | 2020/12/04 22:16:08 | 26, 27           
3               | cv-os-rhel-8Server        | cv-os-rhel-8Server        | false     | 2020/11/10 01:53:39 | 4, 5, 9          
6               | cv-test-delete            | cv-test-delete            | false     |                     |                  
1               | Default Organization View | Default_Organization_View | false     | 2020/11/09 01:49:24 |                  
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
# hammer content-view  list --organization acme
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS   
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
8               | cv-app-capsule            | cv-app-capsule            | false     | 2021/02/11 22:21:39 | 1, 2, 6, 7, 8, 10
7               | cv-os-rhel-6Server        | cv-os-rhel-6Server        | false     | 2021/04/15 00:42:13 | 43, 44, 85       
2               | cv-os-rhel-7Server        | cv-os-rhel-7Server        | false     | 2021/04/14 21:06:24 | 2, 8             
5               | cv-os-rhel-82kickstart    | cv-os-rhel-82kickstart    | false     | 2020/12/06 04:39:16 | 34, 35           
4               | cv-os-rhel-83-kickstart   | cv-os-rhel-83-kickstart   | false     | 2020/12/04 22:16:08 | 26, 27           
3               | cv-os-rhel-8Server        | cv-os-rhel-8Server        | false     | 2020/11/10 01:53:39 | 4, 5, 9          
6               | cv-test-delete            | cv-test-delete            | false     |                     |                  
1               | Default Organization View | Default_Organization_View | false     | 2020/11/09 01:49:24 |                  
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
# cat .hammer/defaults.yml
:defaults:
  :organization_id:
    :value: '1'
  :organization:
    :value: acme
---

2) w/o hammer defaults:
---
# hammer content-view  list --organization rguerra_org2
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                                | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
14              | Default Organization View | 8388f73c-dc14-4181-9d21-21c41c9219ff | false     | 2021/04/20 18:22:04 |               
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
# hammer content-view  list --organization rguerra_org
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
CONTENT VIEW ID | NAME                      | LABEL                                | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
12              | cv_1                      | cv_1                                 | false     |                     |               
13              | cv2                       | cv2                                  | false     |                     |               
11              | Default Organization View | 3ff82933-0402-41c3-8aef-d831719bff6d | false     | 2021/04/20 18:14:23 |               
----------------|---------------------------|--------------------------------------|-----------|---------------------|---------------
# hammer content-view  list --organization acme
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS   
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
8               | cv-app-capsule            | cv-app-capsule            | false     | 2021/02/11 22:21:39 | 1, 2, 6, 7, 8, 10
7               | cv-os-rhel-6Server        | cv-os-rhel-6Server        | false     | 2021/04/15 00:42:13 | 43, 44, 85       
2               | cv-os-rhel-7Server        | cv-os-rhel-7Server        | false     | 2021/04/14 21:06:24 | 2, 8             
5               | cv-os-rhel-82kickstart    | cv-os-rhel-82kickstart    | false     | 2020/12/06 04:39:16 | 34, 35           
4               | cv-os-rhel-83-kickstart   | cv-os-rhel-83-kickstart   | false     | 2020/12/04 22:16:08 | 26, 27           
3               | cv-os-rhel-8Server        | cv-os-rhel-8Server        | false     | 2020/11/10 01:53:39 | 4, 5, 9          
6               | cv-test-delete            | cv-test-delete            | false     |                     |                  
1               | Default Organization View | Default_Organization_View | false     | 2020/11/09 01:49:24 |                  
----------------|---------------------------|---------------------------|-----------|---------------------|------------------
# cat .hammer/defaults.yml && date
Wed Apr 21 06:03:25 PDT 2021
---


Rafael

Comment 3 Oleh Fedorenko 2021-04-22 11:53:47 UTC
Thanks a lot for more info! Now it seems like a valid bug, since any explicitly provided options should override any defaults.

Few notes how to workaround this if needed:
1 - use `--no-use-defaults` option for hammer main command
2 - use --organization-id instead of --organization

Comment 4 Oleh Fedorenko 2021-04-22 11:54:43 UTC
Created redmine issue https://projects.theforeman.org/issues/32392 from this bug

Comment 5 Oleh Fedorenko 2021-04-27 08:17:41 UTC
*** Bug 1953713 has been marked as a duplicate of this bug. ***

Comment 7 Bryan Kearney 2021-05-10 20:04:21 UTC
Upstream bug assigned to ofedoren

Comment 8 Bryan Kearney 2021-05-10 20:04:23 UTC
Upstream bug assigned to ofedoren

Comment 9 Bryan Kearney 2021-06-13 12:04:34 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32392 has been resolved.

Comment 18 Eric Helms 2024-06-06 00:45:07 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.