Bug #11306
closedID always has to be equal to "1" when importing classes using hammer cli
Description
Here's what I did when trying to import an environment:
first I create the environment, by the same name as listed in //etc/puppet/environments:
# hammer environment create --name $environment
Next I try to import the classes, the following should work but fails:
# hammer proxy import-classes --environment $environment Import of puppet classes failed: Missing arguments for 'id'
Next I try the following, which also should work, but once again fails:
# hammer proxy import-classes --environment $environment --id $id Import of puppet classes failed: Resource smart_proxy not found by id '$id'
The only workaround is if I always set the id's value to "1", irrespective of which environment I want to import classes for:
# hammer proxy import-classes --environment $environment --id 1 Puppet classes were imported
So I believe we have 2 bugs, here. First the id parameter should be optional. Second, the id parameter if specified should be the correct value.
Here's the debug info:
[root@puppetmaster ~]# hammer -d proxy import-classes --environment $environment [ INFO 2015-08-06 15:29:23 Init] Initialization of Hammer CLI (0.2.0) has started... [DEBUG 2015-08-06 15:29:23 Init] Running at ruby 2.0.0-p598 [ INFO 2015-08-06 15:29:23 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded [ INFO 2015-08-06 15:29:23 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded [ INFO 2015-08-06 15:29:23 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded [DEBUG 2015-08-06 15:29:23 Connection] Registered: foreman [DEBUG 2015-08-06 15:29:23 API] Global headers: { :content_type => "application/json", :accept => "application/json;version=2", "Accept-Language" => "en_GB" } [ INFO 2015-08-06 15:29:23 Modules] Extension module hammer_cli_foreman (0.2.0) loaded [DEBUG 2015-08-06 15:29:23 Init] Using locale 'en_GB' [DEBUG 2015-08-06 15:29:23 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/gems/gems/hammer_cli- 0.2.0/locale' [DEBUG 2015-08-06 15:29:23 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/gems/gems/ham mer_cli_foreman-0.2.0/locale' [ INFO 2015-08-06 15:29:23 HammerCLI::MainCommand] Called with options: {"option_debug"=>true} [ INFO 2015-08-06 15:29:23 HammerCLIForeman::SmartProxy] Called with options: {} [ INFO 2015-08-06 15:29:23 HammerCLIForeman::SmartProxy::ImportPuppetClassesCommand] Called with options: {"option_envir onment_name"=>"$environment"} [ INFO 2015-08-06 15:29:23 API] GET /api/environments [DEBUG 2015-08-06 15:29:23 API] Params: { :search => "name = \"$environment\"" } [DEBUG 2015-08-06 15:29:23 API] Headers: { :params => { :search => "name = \"$environment\"" } } [DEBUG 2015-08-06 15:29:24 API] Response: { "total" => 4, "subtotal" => 1, "page" => 1, "per_page" => 20, "search" => "name = \"$environment\"", "sort" => { "by" => nil, "order" => nil }, "results" => [ [0] { "created_at" => "2015-08-06T14:26:04Z", "updated_at" => "2015-08-06T14:26:04Z", "name" => "$environment", "id" => 7 } ] } [DEBUG 2015-08-06 15:29:24 API] Response headers: { :date => "Thu, 06 Aug 2015 14:29:23 GMT", :server => "Apache/2.4.6 (CentOS)", :foreman_version => "1.8.2", :foreman_api_version => "2", :apipie_checksum => "296420cd159a1435d80a1a3e3a642264", :x_ua_compatible => "IE=Edge,chrome=1", :cache_control => "must-revalidate, private, max-age=0", :x_request_id => "23c3de7e18401d8a305e2c79da5ef2dd", :x_runtime => "0.061600", :x_rack_cache => "miss", :x_powered_by => "Phusion Passenger 4.0.18", :set_cookie => [ [0] "_session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTAzMjYzNmIyNDRhMmU0MzY2NDA3MTIyYjBhZDg2YTM4BjsAVEkiC2xvY2FsZQY 7AEYiCmVuX0dC--6880435ecda38b8a9a2d684cb2fbf784c41a00b6; path=/; HttpOnly", [1] "request_method=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT" ], :etag => "\"0aa26df58d42f93dfdaff5005d75d767\"", :status => "200 OK", :connection => "close", :transfer_encoding => "chunked", :content_type => "application/json; charset=utf-8" } [ERROR 2015-08-06 15:29:24 Exception] Missing arguments for 'id' Import of puppet classes failed: Missing arguments for 'id' [ERROR 2015-08-06 15:29:24 Exception] ApipieBindings::MissingArgumentsError (Missing arguments for 'id'): /usr/share/gems/gems/apipie-bindings-0.0.13/lib/apipie_bindings/action.rb:63:in `validate!' /usr/share/gems/gems/apipie-bindings-0.0.13/lib/apipie_bindings/api.rb:159:in `call' /usr/share/gems/gems/apipie-bindings-0.0.13/lib/apipie_bindings/resource.rb:14:in `call' /usr/share/gems/gems/hammer_cli-0.2.0/lib/hammer_cli/apipie/command.rb:43:in `send_request' /usr/share/gems/gems/hammer_cli_foreman-0.2.0/lib/hammer_cli_foreman/commands.rb:185:in `send_request' /usr/share/gems/gems/hammer_cli-0.2.0/lib/hammer_cli/apipie/command.rb:34:in `execute' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run' /usr/share/gems/gems/hammer_cli-0.2.0/lib/hammer_cli/abstract.rb:23:in `run' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run' /usr/share/gems/gems/hammer_cli-0.2.0/lib/hammer_cli/abstract.rb:23:in `run' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run' /usr/share/gems/gems/hammer_cli-0.2.0/lib/hammer_cli/abstract.rb:23:in `run' /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:126:in `run' /usr/share/gems/gems/hammer_cli-0.2.0/bin/hammer:108:in `<top (required)>' /bin/hammer:23:in `load' /bin/hammer:23:in `<main>'
Updated by Dominic Cleal over 9 years ago
- Status changed from New to Feedback
The --id parameter is for the proxy subcommand, which means you're actually specifying a smart proxy ID and not an environment ID.
When importing classes you need to choose the smart proxy to import from, and I guess you only have one. Run "hammer proxy list" and you'll see a list of smart proxies.
Updated by Sher Chowdhury over 9 years ago
Ah right, my apologies. Thanks for pointing that out.