Bug 1369609

Summary: content view filter does not use 'Default' organization and location in hammer
Product: Red Hat Satellite Reporter: Ashfaqur Rahaman <arahaman>
Component: HammerAssignee: Martin Bacovsky <mbacovsk>
Status: CLOSED ERRATA QA Contact: Katello QA List <katello-qa-list>
Severity: low Docs Contact:
Priority: medium    
Version: 6.2.0CC: bbuckingham, jcallaha, mbacovsk, oshtaier
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: Environment:
Last Closed: 2018-02-21 16:49:54 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:

Description Ashfaqur Rahaman 2016-08-24 00:27:22 UTC
Description of problem:

When creating the content view filter using hammer, it does not read the default organization and location from the defaults.yml file. 

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

How reproducible:
100%

Steps to Reproduce:

1.Set default organization and location by creating defaults.yml and copy it in /root/.hammer
~~
hammer> organization list
---|------|--------------------------------------|------------
ID | NAME | LABEL                                | DESCRIPTION
---|------|--------------------------------------|------------
1  | org1 | 1e9d14ee-f38d-46cb-a7b7-63f4d39a20b6 |            
---|------|--------------------------------------|------------
hammer> location list
---|-----
ID | NAME
---|-----
2  | loc1
---|-----
hammer> 

[root@sat62 hammer_cli]# cat /root/.hammer/defaults.yml 
---
:defaults:
  :organization_id:
    :value: '1'
  :location_id:
    :value: '2'
~~

2. login to hammer shell 
3. Try hammer commands which use organization and location: 

Other hammer commands working as below: 

~~~
# hammer> repository list
---|-----------------------------------------------------------|---------------------------------|--------------|---------------------------------------------------------------------------------
ID | NAME                                                      | PRODUCT                         | CONTENT TYPE | URL                                                                             
---|-----------------------------------------------------------|---------------------------------|--------------|---------------------------------------------------------------------------------
2  | Red Hat Satellite Tools 6.2 for RHEL 7 Server RPMs x86_64 | Red Hat Enterprise Linux Server | yum          | https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/sat-tools/6....
1  | Red Hat Enterprise Linux 7 Server RPMs x86_64 7.2         | Red Hat Enterprise Linux Server | yum          | https://cdn.redhat.com/content/dist/rhel/server/7/7.2/x86_64/os                 
3  | Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.2    | Red Hat Enterprise Linux Server | yum          | https://cdn.redhat.com/content/dist/rhel/server/7/7.2/x86_64/kickstart          
---|-----------------------------------------------------------|---------------------------------|--------------|---------------------------------------------------------------------------------

hammer> content-view list
----------------|---------------------------|---------------------------|-----------|---------------
CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | REPOSITORY IDS
----------------|---------------------------|---------------------------|-----------|---------------
1               | Default Organization View | Default_Organization_View |           |               
2               | cv_rhel7                  | cv_rhel7                  |           | 1, 2, 3       
----------------|---------------------------|---------------------------|-----------|---------------
~~~

Actual results:

But when we try to create content view filter, it fails with organization id. 

~~~
hammer> content-view filter create --name "July" --type erratum --inclusion true --content-view cv_rhel7
Could not create the filter:
  Error: At least one of options --organization-id, --organization, --organization-label is required
  
  See: ' content-view filter create --help'
~~~


Expected results:
It should work using the default value like other hammer commands. 

Additional info:
N/A

Comment 3 Martin Bacovsky 2016-09-20 15:17:31 UTC
This is bug in Hammer core. The validators do not take the defaults into account and the validation fails.

During investigation I found out that there is similarly looking issue that is caused by missing organization in builde_options in some of the filter commands and it fails to look up CV by name:
 
hammer -d content-view filter list --content-view "Default Organization View"

Comment 4 Martin Bacovsky 2016-09-21 10:48:23 UTC
Created redmine issue http://projects.theforeman.org/issues/16631 from this bug

Comment 5 Bryan Kearney 2016-09-21 12:19:07 UTC
Upstream bug assigned to mbacovsk

Comment 6 Bryan Kearney 2016-09-21 12:19:11 UTC
Upstream bug assigned to mbacovsk

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

Comment 10 Oleksandr Shtaier 2017-07-03 11:03:22 UTC
Verified on latest 6.3:

hammer -v -u admin -p changeme  defaults add --param-value="86" --param-name="organization_id"

Added organization_id default-option with value 86

hammer -v -u admin -p changeme  defaults add --param-value="87" --param-name="location_id"

Added location_id default-option with value 87

hammer -v -u admin -p changeme --output=csv content-view filter create --inclusion="true" --type="erratum" --name="MKAyInEfyb" --content-view="NETzkAcOaa"

Message,Id,Name
Filter created,4,MKAyInEfyb

hammer -v -u admin -p changeme  content-view filter info --id="4"
Filter ID:    4
Name:         MKAyInEfyb
Type:         erratum
Inclusion:    true
Description:  
Repositories: 

Rules:


I am getting expected error in case defaults were not specified and successful outcome in case they were provided

Test Automation script was created and corresponding PR is raised:
https://github.com/SatelliteQE/robottelo/pull/4915

Comment 11 Bryan Kearney 2018-02-21 16:45:33 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/RHSA-2018:0336

Comment 12 Satellite Program 2018-02-21 16:49:54 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/RHSA-2018:0336