Bug 1356906

Summary: [hammer] creating a cv filter using content-view name throws Error: Could not find organization though org is associated
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: Content ManagementAssignee: David Davis <daviddavis>
Status: CLOSED ERRATA QA Contact: Og Maciel <omaciel>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bbuckingham, daviddavis, omaciel, rankumar
Target Milestone: UnspecifiedKeywords: Reopened, 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:
Embargoed:

Description Sachin Ghai 2016-07-15 09:08:55 UTC
Description of problem:
Creating a cv filter with cv name failed with error:


Could not create the filter:
  Error: Could not find organization, please set one of options --organization, --organization-label, --organization-id.
[ERROR 2016-07-15 05:02:18 Exception] 

HammerCLIForeman::MissingSeachOptions (Could not find organization, please set one of options --organization, --organization-label, --organization-id.):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.9/lib/hammer_cli_foreman/commands.rb:203:in `rescue in send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.9/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/apipie/command.rb:34:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'



please note that organization-id is already associated:

~]# hammer -v -u admin -p changeme --output=csv content-view filter create --inclusion="true" --type="package_group" --name="薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣" --organization-id="13" --content-view="ZjziAmAjqd"
[ERROR 2016-07-15 05:02:18 Exception] Error: Could not find organization, please set one of options --organization, --organization-label, --organization-id.

the issue appears only when we use content-view name. If we pass content-view-id then filter got created.

~]# hammer -v -u admin -p changeme --output=csv content-view filter create --inclusion="true" --type="package_group" --name="薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣" --organization-id="13" --content-view-id 1
Message,Id,Name
Filter created,60,薝𤪧㠅踊贯𤤿𠷿옌𒃖𠹣


Version-Release number of selected component (if applicable):
sat62 GA snap20.1

How reproducible:


Steps to Reproduce:
1. create cv filter with cv-name
2.
3.

Actual results:


Expected results:
cv filter with cv nam option should successfully be created.

Additional info:

Comment 3 David Davis 2016-09-06 13:46:27 UTC
This was fixed in the following commit:

https://github.com/Katello/hammer-cli-katello/commit/e0bea267be201e78d4f732b29233de7334451270

Comment 6 Og Maciel 2016-11-08 21:52:29 UTC
Verified this issue using the reproducer steps and using Satellite 6.3.0 Compose 6.0.

RHEL 7.2
--------

hammer -v -u admin -p changeme --output=csv content-view create --name='ZjziAmAjqd' --organization-id='1'
Message,Id,Name
Content view created,3,ZjziAmAjqd

hammer -v -u admin -p changeme --output=csv content-view filter create --inclusion="true" --type="package_group" --name="薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣" --organization-id="1" --content-view="ZjziAmAjqd"
Message,Id,Name
Filter created,1,薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣


==> /var/log/httpd/foreman-ssl_access_ssl.log <==
127.0.0.1 - - [08/Nov/2016:16:46:23 -0500] "GET //katello/api/organizations/1/content_views?name=ZjziAmAjqd HTTP/1.1" 200 358 "-" "Ruby"

==> /var/log/httpd/foreman-ssl_error_ssl.log <==
[Tue Nov 08 16:46:23.391411 2016] [ssl:warn] [pid 20585] [client 127.0.0.1:39912] AH02227: Failed to set r->user to 'SSL_CLIENT_S_DN_CN'
[Tue Nov 08 16:46:23.495365 2016] [ssl:warn] [pid 20583] [client 127.0.0.1:39914] AH02227: Failed to set r->user to 'SSL_CLIENT_S_DN_CN'

==> /var/log/foreman/production.log <==
2016-11-08 16:46:23 1c694801 [app] [I] Started GET "/katello/api/organizations/1/content_views?name=ZjziAmAjqd" for 127.0.0.1 at 2016-11-08 16:46:23 -0500
2016-11-08 16:46:23 1c694801 [app] [I] Processing by Katello::Api::V2::ContentViewsController#index as JSON
2016-11-08 16:46:23 1c694801 [app] [I]   Parameters: {"name"=>"ZjziAmAjqd", "api_version"=>"v2", "organization_id"=>"1", "content_view"=>{}}
2016-11-08 16:46:23 1c694801 [app] [I] Authorized user admin(Admin User)
2016-11-08 16:46:23 1c694801 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/content_views/index.json.rabl within katello/api/v2/layouts/collection (22.7ms)
2016-11-08 16:46:23 1c694801 [app] [I] Completed 200 OK in 47ms (Views: 21.3ms | ActiveRecord: 6.2ms)
2016-11-08 16:46:23 8979e311 [app] [I] Started POST "/katello/api/content_views/4/filters" for 127.0.0.1 at 2016-11-08 16:46:23 -0500
2016-11-08 16:46:23 8979e311 [app] [I] Processing by Katello::Api::V2::ContentViewFiltersController#create as JSON
2016-11-08 16:46:23 8979e311 [app] [I]   Parameters: {"name"=>"薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣", "type"=>"package_group", "inclusion"=>true, "api_version"=>"v2", "content_view_id"=>"4", "content_view_filter"=>{"name"=>"薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣", "type"=>"package_group", "inclusion"=>true}}
2016-11-08 16:46:23 8979e311 [app] [I] Authorized user admin(Admin User)

==> /var/log/httpd/foreman-ssl_access_ssl.log <==
127.0.0.1 - - [08/Nov/2016:16:46:23 -0500] "POST //katello/api/content_views/4/filters HTTP/1.1" 200 417 "-" "Ruby"

==> /var/log/foreman/production.log <==
2016-11-08 16:46:23 8979e311 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/common/create.json.rabl within katello/api/v2/layouts/resource (39.4ms)
2016-11-08 16:46:23 8979e311 [app] [I] Completed 200 OK in 113ms (Views: 36.9ms | ActiveRecord: 14.8ms)


RHEL 6.8
--------


hammer -v -u admin -p changeme --output=csv content-view create --name='ZjziAmAjqd' --organization-id='1'
Message,Id,Name
Content view created,3,ZjziAmAjqd

hammer -v -u admin -p changeme --output=csv content-view filter create --inclusion="true" --type="package_group" --name="薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣" --organization-id="1" --content-view="ZjziAmAjqd"
Message,Id,Name
Filter created,1,薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣

==> /var/log/foreman/production.log <==
2016-11-08 16:52:04 9586a749 [app] [I] Started GET "/katello/api/organizations/1/content_views?name=ZjziAmAjqd" for 127.0.0.1 at 2016-11-08 16:52:04 -0500
2016-11-08 16:52:04 9586a749 [app] [I] Processing by Katello::Api::V2::ContentViewsController#index as JSON
2016-11-08 16:52:04 9586a749 [app] [I]   Parameters: {"name"=>"ZjziAmAjqd", "api_version"=>"v2", "organization_id"=>"1", "content_view"=>{}}
2016-11-08 16:52:04 9586a749 [app] [I] Authorized user admin(Admin User)
2016-11-08 16:52:04 9586a749 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/content_views/index.json.rabl within katello/api/v2/layouts/collection (21.8ms)
2016-11-08 16:52:04 9586a749 [app] [I] Completed 200 OK in 51ms (Views: 20.7ms | ActiveRecord: 5.4ms)

==> /var/log/httpd/foreman-ssl_access_ssl.log <==
127.0.0.1 - - [08/Nov/2016:16:52:04 -0500] "GET //katello/api/organizations/1/content_views?name=ZjziAmAjqd HTTP/1.1" 200 356 "-" "Ruby"

==> /var/log/foreman/production.log <==
2016-11-08 16:52:04 0c6e615f [app] [I] Started POST "/katello/api/content_views/3/filters" for 127.0.0.1 at 2016-11-08 16:52:04 -0500
2016-11-08 16:52:04 0c6e615f [app] [I] Processing by Katello::Api::V2::ContentViewFiltersController#create as JSON
2016-11-08 16:52:04 0c6e615f [app] [I]   Parameters: {"name"=>"薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣", "type"=>"package_group", "inclusion"=>true, "api_version"=>"v2", "content_view_id"=>"3", "content_view_filter"=>{"name"=>"薝𤪧㠅 踊贯𤤿𠷿옌𒃖𠹣", "type"=>"package_group", "inclusion"=>true}}
2016-11-08 16:52:04 0c6e615f [app] [I] Authorized user admin(Admin User)
2016-11-08 16:52:04 0c6e615f [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/common/create.json.rabl within katello/api/v2/layouts/resource (36.6ms)
2016-11-08 16:52:04 0c6e615f [app] [I] Completed 200 OK in 100ms (Views: 34.9ms | ActiveRecord: 8.4ms)

==> /var/log/httpd/foreman-ssl_access_ssl.log <==
127.0.0.1 - - [08/Nov/2016:16:52:04 -0500] "POST //katello/api/content_views/3/filters HTTP/1.1" 200 420 "-" "Ruby"

Comment 7 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