Bug 1920224 - hammer content-view list --organization <ORG NAME> seems to show always the result for ORG with ID 1
Summary: hammer content-view list --organization <ORG NAME> seems to show always the ...
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.8.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: Unspecified
Assignee: Oleh Fedorenko
QA Contact: Gaurav Talreja
URL:
Whiteboard:
: 1953713 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-01-25 20:12 UTC by Rafael Cavalcanti
Modified: 2021-10-18 17:00 UTC (History)
10 users (show)

Fixed In Version: tfm-rubygem-hammer_cli_foreman-2.5.1.1-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32392 0 Normal Closed hammer content-view list --organization <ORG NAME> seems to show always the result for ORG with ID 1 2021-07-28 17:24:45 UTC
Foreman Issue Tracker 33711 0 Normal Assigned Provided id options don't override defaults 2021-10-18 17:00:55 UTC

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.


Note You need to log in before you can comment on or make changes to this bug.