Bug 1114109

Summary: hammer activation-key update should not require an organization-id when have the --id option
Product: Red Hat Satellite Reporter: Elyézer Rezende <erezende>
Component: HammerAssignee: Dustin Tsang <dtsang>
Status: CLOSED WONTFIX QA Contact: Elyézer Rezende <erezende>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.4CC: bbuckingham, cwelton, mmccune
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/6465
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-23 00:56:35 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 Elyézer Rezende 2014-06-27 18:15:53 UTC
Description of problem:
When updating an activation key passing its ID, the organization option should not be required.

Version-Release number of selected component (if applicable):
# hammer --version
hammer (0.1.1)
 * hammer_cli_foreman (0.1.1)
 * hammer_cli_katello (0.0.4)

How reproducible:
Aways

Steps to Reproduce:
1. Create an activation key using hammer
2. Try to update its name passing --id and --new-name options

Actual results:
The activation key is not updated and an exception is raised


Expected results:
The activation key should be updated.


Additional info:
# LANG=en_US hammer -v -u admin -p changeme  --output csv activation-key create --name='ue99k5' --organization-id='169' --usage-limit='unlimited'
Message,Id,Name
Activation key created,35,ue99k5

# LANG=en_US hammer -v -u admin -p changeme  activation-key info --id='35'
Name:                  ue99k5
ID:                    35
Description:
Lifecycle Environment:
Content View:
Host Collections:

# LANG=en_US hammer -v -u admin -p changeme  --output csv activation-key update --id='35' --new-name='glHZmTDUdzxiYFJ'
[ERROR 2014-06-27 14:02:31 Exception] Error: Missing options to search organization
Could not update the activation key:
  Error: Missing options to search organization
[ERROR 2014-06-27 14:02:31 Exception]

HammerCLIForeman::MissingSeachOptions (Missing options to search organization):
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/id_resolver.rb:115:in `search_options'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/id_resolver.rb:88:in `find_resource'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/id_resolver.rb:82:in `get_id'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/id_resolver.rb:76:in `organization_id'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:133:in `send'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:133:in `get_resource_id'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:164:in `request_params'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:161:in `each'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:161:in `request_params'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/command.rb:42:in `send_request'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:154:in `send_request'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/command.rb:33:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:22:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:22:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:22:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/bin/hammer:100
    /usr/bin/hammer:19:in `load'
    /usr/bin/hammer:19

Comment 1 RHEL Program Management 2014-06-27 18:16:44 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Dustin Tsang 2014-07-02 06:44:42 UTC
Created redmine issue http://projects.theforeman.org/issues/6465 from this bug

Comment 4 Dustin Tsang 2014-07-23 00:56:35 UTC
Pull-request to upstream (https://github.com/Katello/hammer-cli-katello/pull/202) was rejected. Organization should be given since activation-keys should always have an organization as context.