Bug 1099557

Summary: activation keys api - not filtering by lifecycle environment or content view any longer
Product: Red Hat Satellite Reporter: Tom McKay <tomckay>
Component: Content ManagementAssignee: Dustin Tsang <dtsang>
Status: CLOSED CURRENTRELEASE QA Contact: Ales Dujicek <adujicek>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.3CC: adujicek, dtsang, jmontleo, mmccune, omaciel
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/5828
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-02 14:06:06 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tom McKay 2014-05-20 15:29:45 UTC
Coding error in activation_keys_controller#index where the elasticsearch filters are incorrectly reset.

Comment 1 Tom McKay 2014-05-20 15:29:47 UTC
Created from redmine issue http://projects.theforeman.org/issues/5828

Comment 3 Og Maciel 2014-05-20 20:49:02 UTC
fwiw this issue also affects switching the content view from a content host via the web ui.

Comment 4 Bryan Kearney 2014-05-21 17:53:56 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/5828 has been closed

Comment 6 Ales Dujicek 2014-05-28 11:32:11 UTC
version: Satellite-6.0.3-RHEL-6-20140523.0

hammer activation-key list --organization-id 3
---|---------|----------------|-----------------------|--------------------------
ID | NAME    | CONSUMED       | LIFECYCLE ENVIRONMENT | CONTENT VIEW             
---|---------|----------------|-----------------------|--------------------------
2  | key2    | 0 of Unlimited | Library               | Default Organization View
5  | prodkey | 0 of Unlimited | prod                  |                          
1  | key1    | 0 of Unlimited | Library               | Default Organization View
4  | devkey2 | 0 of Unlimited | dev                   |                          
3  | devkey  | 0 of Unlimited | dev                   | cv1                      
---|---------|----------------|-----------------------|--------------------------


[OK] filter by content_view_id:
curl ... /katello/api/v2/organizations/3/activation_keys -d "content_view_id=4"
{"total":1,"subtotal":1,"page":1,"per_page":20,"search ...

curl ... /katello/api/v2/organizations/3/activation_keys -d "content_view_id=5"
{"total":0,"subtotal":0,"page":1,"per_page":20,"search":null,"sort":{"by":null,"order":null},"results":[]}

hammer --csv activation-key list --organization charlie --content-view-id 4
ID,Name,Consumed,Lifecycle Environment,Content View
3,devkey,0 of Unlimited,dev,cv1


[OK] filter by environment_id:
curl ... /katello/api/v2/organizations/3/activation_keys -d "environment_id=5"
{"total":1,"subtotal":1,"page":1,"per_page":20,"searc ...

curl ... /katello/api/v2/organizations/3/activation_keys -d "environment_id=4"
{"total":2,"subtotal":2,"page":1,"per_page":20," ...

hammer --csv activation-key list --organization charlie --environment-id 5
ID,Name,Consumed,Lifecycle Environment,Content View
5,prodkey,0 of Unlimited,prod,""


but api cannot filter by environment and cv names
and  hammer always returns all results


[failed] filter by environment:
curl ... /katello/api/v2/organizations/3/activation_keys -d "environment=Library"
{"displayMessage":"can't convert Symbol into Integer","errors":["can't convert Symbol into Integer"]}

hammer --csv activation-key list --organization charlie --environment Library
ID,Name,Consumed,Lifecycle Environment,Content View
2,key2,0 of Unlimited,Library,Default Organization View
5,prodkey,0 of Unlimited,prod,""
1,key1,0 of Unlimited,Library,Default Organization View
4,devkey2,0 of Unlimited,dev,""
3,devkey,0 of Unlimited,dev,cv1

[failed] filter by content_view:
curl ... /katello/api/v2/organizations/3/activation_keys -d "content_view=cv1"
{"total":5,"subtotal":5,"page":1,"per_pa ...
should be 1 ^^

hammer --csv activation-key list --organization charlie --content-view cv1 
ID,Name,Consumed,Lifecycle Environment,Content View
2,key2,0 of Unlimited,Library,Default Organization View
5,prodkey,0 of Unlimited,prod,""
1,key1,0 of Unlimited,Library,Default Organization View
4,devkey2,0 of Unlimited,dev,""
3,devkey,0 of Unlimited,dev,cv1

Comment 8 Tom McKay 2014-05-30 21:50:47 UTC

    [thomasmckay@thomasmckay hammer-cli-csv{threaded}]$ hammer activation-key list --organization-id 3 --content-view-id 4
    ----|------|----------------|-----------------------|-------------
    ID  | NAME | CONSUMED       | LIFECYCLE ENVIRONMENT | CONTENT VIEW
    ----|------|----------------|-----------------------|-------------
    119 | a    | 2 of Unlimited | Library               | a1          
    ----|------|----------------|-----------------------|-------------
    [thomasmckay@thomasmckay hammer-cli-csv{threaded}]$ hammer activation-key list --organization-id 3 --content-view a1
    Error: content_view found more than once
     
    HammerCLIForeman::ResolverError (content_view found more than once):
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/id_resolver.rb:144:in `pick_result'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/id_resolver.rb:139:in `find_resource'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/id_resolver.rb:117:in `get_id'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/id_resolver.rb:111:in `block (2 levels) in define_id_finders'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:96:in `get_resource_id'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:121:in `block in request_params'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:118:in `each'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:118:in `request_params'
        /home/thomasmckay/code/hammer-cli/lib/hammer_cli/apipie/command.rb:42:in `send_request'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:113:in `send_request'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:142:in `send_request'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:188:in `retrieve_and_print'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:175:in `browse_collection'
        /home/thomasmckay/code/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:160:in `execute'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
        /home/thomasmckay/code/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/gems/clamp-0.6.3/lib/clamp/subcommand/execution.rb:11:in `execute'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
        /home/thomasmckay/code/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/gems/clamp-0.6.3/lib/clamp/subcommand/execution.rb:11:in `execute'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
        /home/thomasmckay/code/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:125:in `run'
        /home/thomasmckay/code/hammer-cli/bin/hammer:100:in `<top (required)>'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/bin/hammer:23:in `load'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/bin/hammer:23:in `<main>'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/bin/ruby_executable_hooks:15:in `eval'
        /usr/local/rvm/gems/ruby-1.9.3-p448@hammer/bin/ruby_executable_hooks:15:in `<main>'

Comment 9 Dustin Tsang 2014-06-17 15:43:51 UTC
currently, filtering by --content-view works but --environment yields error message: "environment found more than once"

Comment 10 Dustin Tsang 2014-06-17 15:44:27 UTC
redmine issue created: 
http://projects.theforeman.org/issues/6253

Comment 11 Dustin Tsang 2014-06-17 17:56:15 UTC
The pull requests that fixes this issue:
https://github.com/Katello/hammer-cli-katello/pull/189

Comment 13 Ales Dujicek 2014-06-19 11:51:46 UTC
Verified - Satellite-6.0.3-RHEL-6-20140618.0

# hammer --csv activation-key list --organization 000org --content-view view
ID,Name,Consumed,Lifecycle Environment,Content View
28,key_lib_view,0 of Unlimited,Library,view
31,key_dev_view,0 of Unlimited,dev,view

# hammer --csv activation-key list --organization 000org --content-view-id 142
ID,Name,Consumed,Lifecycle Environment,Content View
28,key_lib_view,0 of Unlimited,Library,view
31,key_dev_view,0 of Unlimited,dev,view

# hammer --csv activation-key list --organization 000org --environment Library
ID,Name,Consumed,Lifecycle Environment,Content View
28,key_lib_view,0 of Unlimited,Library,view
27,key_lib_default,0 of Unlimited,Library,Default Organization View
26,key_lib,0 of Unlimited,Library,Default Organization View

# hammer --csv activation-key list --organization 000org --environment-id 132
ID,Name,Consumed,Lifecycle Environment,Content View
28,key_lib_view,0 of Unlimited,Library,view
27,key_lib_default,0 of Unlimited,Library,Default Organization View
26,key_lib,0 of Unlimited,Library,Default Organization View

Comment 14 Bryan Kearney 2014-07-02 14:06:06 UTC
This was delivered with 6.0.3, which is the Satellite 6 Beta.