Bug 1397860 - API/CLI host registration fails with ArgumentError: wrong number of arguments (3 for 2)
Summary: API/CLI host registration fails with ArgumentError: wrong number of argument...
Keywords:
Status: CLOSED DUPLICATE of bug 1383793
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hosts - Content
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Lukas Pramuk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-23 13:24 UTC by Lukas Pramuk
Modified: 2017-04-25 16:34 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-01 16:48:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Lukas Pramuk 2016-11-23 13:24:02 UTC
Description of problem:
hammer import content-host fails to create a host. Issued POST "/api/hosts/subscriptions" fails with ArgumentError: wrong number of arguments (3 for 2)

Version-Release number of selected component (if applicable):
Sat6.3 Snap6
tfm-rubygem-hammer_cli_import-0.11.3-1.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1. # hammer import content-host --debug --csv-file system-profiles.csv --export-directory .
Importing from system-profiles.csv
Creating new host: profile1
E, [2016-11-23T08:14:52.763351 #23470] ERROR -- : 500 Internal Server Error
Caught RestClient::InternalServerError:500 Internal Server Error while processing CSV line:
{"server_id"=>"1000010009", "profile_name"=>"profile1", "hostname"=>"tyan-gt24-01.example.com", "description"=>nil, "organization_id"=>"1", "base_channel_id"=>nil, "base_channel_label"=>nil, "child_channel_id"=>nil, "system_group_id"=>nil, "release"=>"7Server", "architecture"=>"x86_64", "virtual_host"=>nil, "virtual_guest"=>nil}
Summary
  No action taken.

2. # tail -f /var/log/foreman/production.log
2016-11-23 06:17:35 1a842526 [app] [I] Started GET "/katello/api/organizations?per_page=999999" for 127.0.0.1 at 2016-11-23 06:17:35 -0500
2016-11-23 06:17:35 1a842526 [app] [I] Processing by Katello::Api::V2::OrganizationsController#index as JSON
2016-11-23 06:17:35 1a842526 [app] [I]   Parameters: {"per_page"=>"999999", "api_version"=>"v2", "organization"=>{}}
2016-11-23 06:17:35 1a842526 [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:35 1a842526 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/organizations/index.json.rabl within api/v2/layouts/index_layout (40.3ms)
2016-11-23 06:17:35 1a842526 [app] [I] Completed 200 OK in 60ms (Views: 41.2ms | ActiveRecord: 4.0ms)
2016-11-23 06:17:35 1973dd22 [app] [I] Started GET "/katello/api/organizations/102/content_views?per_page=999999" for 127.0.0.1 at 2016-11-23 06:17:35 -0500
2016-11-23 06:17:35 1973dd22 [app] [I] Processing by Katello::Api::V2::ContentViewsController#index as JSON
2016-11-23 06:17:35 1973dd22 [app] [I]   Parameters: {"per_page"=>"999999", "api_version"=>"v2", "organization_id"=>"102", "content_view"=>{}}
2016-11-23 06:17:36 1973dd22 [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:36 1973dd22 [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 (25.3ms)
2016-11-23 06:17:36 1973dd22 [app] [I] Completed 200 OK in 50ms (Views: 23.5ms | ActiveRecord: 7.2ms)
2016-11-23 06:17:36 fab44fa8 [app] [I] Started GET "/katello/api/organizations/102/host_collections?per_page=999999" for 127.0.0.1 at 2016-11-23 06:17:36 -0500
2016-11-23 06:17:36 fab44fa8 [app] [I] Processing by Katello::Api::V2::HostCollectionsController#index as JSON
2016-11-23 06:17:36 fab44fa8 [app] [I]   Parameters: {"per_page"=>"999999", "api_version"=>"v2", "organization_id"=>"102", "host_collection"=>{}}
2016-11-23 06:17:36 fab44fa8 [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:36 fab44fa8 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/host_collections/index.json.rabl within katello/api/v2/layouts/collection (2.1ms)
2016-11-23 06:17:36 fab44fa8 [app] [I] Completed 200 OK in 27ms (Views: 3.4ms | ActiveRecord: 4.4ms)
2016-11-23 06:17:36 50636363 [app] [I] Started GET "/api/organizations/102/hosts?per_page=999999" for 127.0.0.1 at 2016-11-23 06:17:36 -0500
2016-11-23 06:17:36 50636363 [app] [I] Processing by Api::V2::HostsController#index as JSON
2016-11-23 06:17:36 50636363 [app] [I]   Parameters: {"per_page"=>"999999", "apiv"=>"v2", "organization_id"=>"102", :host=>{}}
2016-11-23 06:17:36 50636363 [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:36 50636363 [app] [I]   Rendered api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout (0.9ms)
2016-11-23 06:17:36 50636363 [app] [I] Completed 200 OK in 48ms (Views: 7.4ms | ActiveRecord: 7.8ms)
2016-11-23 06:17:36 c747511c [app] [I] Started GET "/katello/api/organizations/102/content_views?per_page=999999&name=Default+Organization+View" for 127.0.0.1 at 2016-11-23 06:17:36 -0500
2016-11-23 06:17:36 c747511c [app] [I] Processing by Katello::Api::V2::ContentViewsController#index as JSON
2016-11-23 06:17:36 c747511c [app] [I]   Parameters: {"per_page"=>"999999", "name"=>"Default Organization View", "api_version"=>"v2", "organization_id"=>"102", "content_view"=>{}}
2016-11-23 06:17:36 c747511c [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:36 c747511c [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 (26.4ms)
2016-11-23 06:17:36 c747511c [app] [I] Completed 200 OK in 52ms (Views: 24.1ms | ActiveRecord: 7.7ms)
2016-11-23 06:17:36 a8eac1fb [app] [I] Started GET "/katello/api/organizations/102/environments?name=Library" for 127.0.0.1 at 2016-11-23 06:17:36 -0500
2016-11-23 06:17:36 a8eac1fb [app] [I] Processing by Katello::Api::V2::EnvironmentsController#index as JSON
2016-11-23 06:17:36 a8eac1fb [app] [I]   Parameters: {"name"=>"Library", "api_version"=>"v2", "organization_id"=>"102", "environment"=>{}}
2016-11-23 06:17:36 a8eac1fb [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:36 a8eac1fb [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/views/katello/api/v2/environments/index.json.rabl within katello/api/v2/layouts/collection (52.0ms)
2016-11-23 06:17:36 a8eac1fb [app] [I] Completed 200 OK in 77ms (Views: 42.9ms | ActiveRecord: 14.9ms)
2016-11-23 06:17:36 e73e59fa [app] [I] Started POST "/api/hosts/subscriptions" for 127.0.0.1 at 2016-11-23 06:17:36 -0500
2016-11-23 06:17:36 e73e59fa [app] [I] Processing by Katello::Api::V2::HostSubscriptionsController#create as JSON
2016-11-23 06:17:36 e73e59fa [app] [I]   Parameters: {"name"=>"profile1", "comment"=>"\nsat5_system_id: 1000010009", "facts"=>"[FILTERED]", "organization_id"=>102, "lifecycle_environment_id"=>97, "content_view_id"=>109, "host_collection_ids"=>nil, "api_version"=>"v2", "host_subscription"=>{"name"=>"profile1", "comment"=>"\nsat5_system_id: 1000010009", "facts"=>"[FILTERED]", "organization_id"=>102, "lifecycle_environment_id"=>97, "content_view_id"=>109, "host_collection_ids"=>nil}}
2016-11-23 06:17:36 e73e59fa [app] [I] Authorized user admin(Admin User)
2016-11-23 06:17:36 e73e59fa [app] [E] ArgumentError: wrong number of arguments (3 for 2)
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/models/katello/host/subscription_facet.rb:85:in `find_or_create_host'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc3/app/controllers/katello/api/v2/host_subscriptions_controller.rb:74:in `create'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/abstract_controller/base.rb:198:in `process_action'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:313:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'


Actual results:
POST call fails

Expected results:
POST call succeeds and profile is being created

Comment 2 Lukas Pramuk 2016-11-23 13:32:25 UTC
cut'n'paste friendly reproducer :-) 

1)
cat > users.csv << EOF
organization_id,organization,user_id,username,last_name,first_name,position,email,role,creation_time,last_login_time,active
1,SatelliteQE,1,admin,Admin,Admin,,root@localhost,Satellite Administrator,2014-09-10 19:39:59,2016-04-07 01:00:14,enabled
EOF

2)
hammer import organization --verbose --csv-file users.csv

3)
cat > system-profiles.csv << EOF 
server_id,profile_name,hostname,description,organization_id,organization_name,base_channel_id,base_channel_label,child_channel_id,child_channel_label,system_group_id,system_group,release,architecture,virtual_host,virtual_guest,is_virtualized,virt_type
1000010009,profile1,tyan-gt24-01.example.com,,1,Red Hat SatTeam QA,,,,,,,7Server,x86_64,,,No,
EOF

4)
hammer import content-host --verbose --csv-file system-profiles.csv --export-directory .


Note: during step 4) don't let hammer ask you for password - otherwise you would hit different bug

Comment 4 Lukas Pramuk 2016-11-25 12:07:15 UTC
It's not only hammer import content-host but also CLI/API host registration what is broken.

QE 6.3 Automation reported same traceback:

2016-11-02 20:03:27 - robottelo.ssh - DEBUG - >>> LANG=en_US.UTF-8  hammer -v -u admin -p changeme --output=csv host subscription register --content-view-id="319" --organization-id="387" --name="fqfZBVeUOtTbYSk" --lifecycle-environment-id="303"
2016-11-02 20:03:29 - robottelo.ssh - DEBUG - <<< stderr
[ERROR 2016-11-02 20:03:29 API] 500 Internal Server Error
[ERROR 2016-11-02 20:03:29 Exception] wrong number of arguments (3 for 2)
Failed to register host:
  wrong number of arguments (3 for 2)
[ERROR 2016-11-02 20:03:29 Exception] 

RestClient::InternalServerError (500 Internal Server Error):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in `return!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.18/lib/apipie_bindings/api.rb:312:in `block in rest_client_call_block'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:493:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:493:in `process_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:421:in `block in transmit'
    /opt/rh/rh-ruby22/root/usr/share/ruby/net/http.rb:853:in `start'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:413:in `transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/resource.rb:67:in `post'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.18/lib/apipie_bindings/api.rb:293:in `call_client'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.18/lib/apipie_bindings/api.rb:222:in `http_call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.18/lib/apipie_bindings/api.rb:172:in `call_action'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.18/lib/apipie_bindings/api.rb:167:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.18/lib/apipie_bindings/resource.rb:21:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/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'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.8.0/bin/hammer:125:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'```

Comment 5 Lukas Pramuk 2016-11-25 12:11:09 UTC
POST "/api/hosts/subscriptions" failing with ArgumentError: wrong number of arguments (3 for 2)

Comment 6 Justin Sherrill 2016-12-01 16:48:37 UTC

*** This bug has been marked as a duplicate of bug 1383793 ***


Note You need to log in before you can comment on or make changes to this bug.