Bug #4306
closedUnable to successfully perform a CLI command that uses a nested resource.
Description
When using the CLI for a nested resource, an error is generated as the logic is not able to properly process the command-line arguments. I am not sure where the root cause of this issue is; therefore, apologies if it is external to hammer-cli.
The configuration where the issue is being observed involves:- hammer-cli
- apipie
- hammer-cli-katello
- katello_api
- katello
- foreman
*Details: *
* command execution:
hammer> puppet-modules info --repository-id 1 --id e890e724-eb24-4332-9d2f-2020b5ba3d1b
missing param 'repository_id' in parameters
- (stack trace at very bottom - from looking at the code, it appears that although --repository-id is there, when it gets to base.rb, only id is included)
* command help:
hammer> puppet-modules info help
Error: too many arguments
See: ' puppet-modules info --help'
hammer> puppet-modules info --help
Usage:
puppet-modules info [OPTIONS]
Options:
--id ID resource id
--name NAME resource name
--repository-id REPOSITORY_ID repository identifier
-h, --help print help
* katello routes (v2.rb):
api_resources :repositories, :only => [:index, :create, :show, :update, :destroy], :constraints => { :id => /[0-9a-zA-Z\-_.]*/ } do
...
api_resources :puppet_modules, :only => [:index, :show] do
get :search, :on => :collection
end
...
end
* katello controller action/doc:
api :GET, "/repositories/:repository_id/puppet_modules/:id", "Show a puppet module"
param :repository_id, :identifier, :desc => "repository identifier"
param :id, String, :desc => "puppet module identifier"
def show
respond :resource => @puppet_module
end
* katello_api puppet_module.rb (apipie doc):
module KatelloApi
module Resources
class PuppetModule < KatelloApi::Base
def self.doc
@doc ||= KatelloApi.doc['resources']["puppet_modules"]
end
- @param [Hash] params a hash of params to be passed to the service
# @option params [String] repository_id repository identifier
#
# @param [Hash] headers additional http headers
# @return [Array] First item: parsed data; second item: raw body
def index(params = {}, headers = {})
perform_call(method, params, headers)
end
- @param [Hash] params a hash of params to be passed to the service
- @option params [String] id puppet module identifier
- @option params [String] repository_id repository identifier #
- @param [Hash] headers additional http headers
- @return [Array] First item: parsed data; second item: raw body
def show(params = {}, headers = {})
perform_call(method, params, headers)
end
end
end
end
* hammer.log for the error:
[ INFO 2014-02-10 13:39:44 HammerCLI::ShellMainCommand] Called with options: {}
[ INFO 2014-02-10 13:39:44 HammerCLIKatello::PuppetModule] Called with options: {}
[ INFO 2014-02-10 13:39:44 HammerCLIKatello::PuppetModule::InfoCommand] Called with options: {"option_id"=>"e890e724-eb24-4332-9d2f-2020b5ba3d1b", "option_repository_id"=>"1"}
[ERROR 2014-02-10 13:39:44 Exception] missing param 'repository_id' in parameters
[ERROR 2014-02-10 13:39:44 Exception]
ArgumentError (missing param 'repository_id' in parameters):
/home/bbucking/github/katello_api/lib/katello_api/base.rb:152:in `block in fill_params_in_url'
/home/bbucking/github/katello_api/lib/katello_api/base.rb:150:in `each'
/home/bbucking/github/katello_api/lib/katello_api/base.rb:150:in `inject'
/home/bbucking/github/katello_api/lib/katello_api/base.rb:150:in `fill_params_in_url'
/home/bbucking/github/katello_api/lib/katello_api/base.rb:50:in `perform_call'
/home/bbucking/github/katello_api/lib/katello_api/resources/puppet_module.rb:24:in `show'
/home/bbucking/github/hammer-cli/lib/hammer_cli/apipie/resource.rb:53:in `call'
/home/bbucking/github/hammer-cli/lib/hammer_cli/apipie/read_command.rb:17:in `retrieve_data'
/home/bbucking/github/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:117:in `retrieve_data'
/home/bbucking/github/hammer-cli/lib/hammer_cli/apipie/read_command.rb:8:in `execute'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
/home/bbucking/github/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/subcommand/execution.rb:11:in `execute'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
/home/bbucking/github/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/subcommand/execution.rb:11:in `execute'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
/home/bbucking/github/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:125:in `run'
/home/bbucking/github/hammer-cli/lib/hammer_cli/shell.rb:104:in `execute'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
/home/bbucking/github/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/subcommand/execution.rb:11:in `execute'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:67:in `run'
/home/bbucking/github/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/gems/clamp-0.6.3/lib/clamp/command.rb:125:in `run'
/home/bbucking/github/hammer-cli/bin/hammer:61:in `<top (required)>'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/bin/hammer:23:in `load'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/bin/hammer:23:in `<main>'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/bin/ruby_executable_hooks:15:in `eval'
/home/bbucking/.rvm/gems/ruby-1.9.3-p194@hammer/bin/ruby_ex
Updated by Brad Buckingham almost 11 years ago
Thanks adamprice for pointing this out.
It looks like the issue being encountered above is that in hammer-cli-foreman/lib/hammer-cli-foreman/commands.rb, the 'request_params' method assumes that certain commands will only have 'id'. In other words, it appears that foreman may not utilize nested routes.
Will close this issue for now.
Updated by Tomáš Strachota over 10 years ago
- Is duplicate of Bug #4311: Name searches don't work when there are other parameters in the search route added