Project

General

Profile

Actions

Bug #5781

closed

provisioning new host by RESTAPI using foreman_discovery plugin duplicates request and fails

Added by Yaniv Bronhaim almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Using api v2: PUT request to "http://0.0.0.0:8080/api/v2/discovers/[:id]" with the following json request:

{
"host": {
"name": "5254002fe2f6",
"hostgroup_id": "3",
"environment_id": "0",
"operatingsystem_id": "2",
"puppet_ca_proxy_id": "1",
"puppet_proxy_id": "1",
"puppetclass_ids": [
""
],
"managed": "true",
"progress_report_id": "",
"type": "Host::Managed",
"domain_id": "0",
"realm_id": "",
"mac": "52:54:00:07:b8:e0",
"subnet_id": "0",
"ip": "192.168.223.46",
"interfaces_attributes": {
"new_interfaces": {
"_destroy": "false",
"type": "Nic::Managed",
"mac": "",
"name": "",
"domain_id": "",
"ip": "",
"provider": "IPMI"
}
},
"architecture_id": "1",
"provision_method": "build",
"build": "1",
"medium_id": "3",
"ptable_id": "6",
"disk": "",
"root_pass": "123123123",
"enabled": "1",
"model_id": "",
"comment": "",
"overwrite": "false"
}
}

from production log:

Started PUT "/api/v2/discovers/5254002fe2f6" for 192.168.223.1 at 2014-05-18 05:42:54 +0000
Processing by Api::DiscoversController#update as JSON
Parameters: {"host"=>{"name"=>"5254002fe2f6", "hostgroup_id"=>"3", "environment_id"=>"0", "puppet_ca_proxy_i
d"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]
", "type"=>"Host::Managed", "domain_id"=>"0", "realm_id"=>"", "mac"=>"52:54:00:07:b8:e0", "subnet_id"=>"0", "i
p"=>"192.168.223.46", "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", "type"=>"Nic::Managed"
, "mac"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", "operatingsy
stem_id"=>"2", "provision_method"=>"build", "build"=>"1", "medium_id"=>"3", "ptable_id"=>"6", "disk"=>"", "roo
t_pass"=>"[FILTERED]", "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"}, "id"=>"5254002fe2
f6", "apiv"=>"v2", "discover"=>{"host"=>{"name"=>"5254002fe2f6", "hostgroup_id"=>"3", "environment_id"=>"0", "
puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report
id"=>"[FILTERED]", "type"=>"Host::Managed", "domain_id"=>"0", "realm_id"=>"", "mac"=>"52:54:00:07:b8:e0", "su
bnet_id"=>"0", "ip"=>"192.168.223.46", "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", "type
"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>
"1", "operatingsystem_id"=>"2", "provision_method"=>"build", "build"=>"1", "medium_id"=>"3", "ptable_id"=>"6",
"disk"=>"", "root_pass"=>"[FILTERED]", "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"},
"id"=>"5254002fe2f6"}}
WARNING: Can't verify CSRF token authenticity
undefined method `boot_filename' for nil:NilClass (NoMethodError)
/home/ybronhei/foreman/app/models/concerns/orchestration/dhcp.rb:60:in `dhcp_attrs'
/home/ybronhei/foreman/app/models/concerns/orchestration/dhcp.rb:16:in `dhcp_record'
/home/ybronhei/foreman/app/models/concerns/orchestration/dhcp.rb:140:in `dhcp_conflict_detected?'
/home/ybronhei/foreman/vendor/ruby/gems/activesupport-3.2.18/lib/active_support/callbacks.rb:504:in `_run
_436
4184019066893064__validation__2257906483471258693__callbacks'
/home/ybronhei/foreman/vendor/ruby/gems/activesupport-3.2.18/lib/active_support/callbacks.rb:405:in `__run_cal
lback'
/home/ybronhei/foreman/vendor/ruby/gems/activesupport-3.2.18/lib/active_support/callbacks.rb:385:in `_run_vali
dation_callbacks'
/home/ybronhei/foreman/vendor/ruby/gems/activesupport-3.2.18/lib/active_support/callbacks.rb:81:in `run_callba
cks'
/home/ybronhei/foreman/vendor/ruby/gems/activemodel-3.2.18/lib/active_model/validations/callbacks.rb:53:in `ru
n_validations!'
/home/ybronhei/foreman/vendor/ruby/gems/activemodel-3.2.18/lib/active_model/validations.rb:195:in `valid?'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/validations.rb:69:in `valid?'
/home/ybronhei/foreman/app/models/concerns/orchestration.rb:47:in `valid?'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/validations.rb:77:in `perform_va
lidations'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/validations.rb:50:in `save'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/attribute_methods/dirty.rb:22:in
`save'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:208:in `transaction'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:259:in `block in save'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:258:in `save'
/home/ybronhei/foreman/app/models/concerns/foreman/sti.rb:29:in `save_with_type'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/persistence.rb:217:in `block in update_attributes'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:208:in `transaction'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/home/ybronhei/foreman/vendor/ruby/gems/activerecord-3.2.18/lib/active_record/persistence.rb:215:in `update_attributes'
/home/ybronhei/foreman_discovery/app/controllers/api/discovers_controller.rb:79:in `update'
/home/ybronhei/foreman/vendor/ruby/gems/actionpack-3.2.18/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/ybronhei/foreman/vendor/ruby/gems/actionpack-3.2.18/lib/abstract_controller/base.rb:167:in `process_action'
/home/ybronhei/foreman/vendor/ruby/gems/actionpack-3.2.18/lib/action_controller/metal/rendering.rb:10:in `process_action'
...
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/actionpack-3.2.18/lib/action_dispatch/middleware/static.rb:63:in `call
'
/home/ybronhei/foreman/vendor/ruby/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/home/ybronhei/foreman/vendor/ruby/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
/home/ybronhei/foreman/vendor/ruby/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
/home/ybronhei/foreman/vendor/ruby/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
/home/ybronhei/foreman/vendor/ruby/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/railties-3.2.18/lib/rails/engine.rb:484:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/railties-3.2.18/lib/rails/application.rb:231:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/railties-3.2.18/lib/rails/railtie/configurable.rb:30:in `method_missin
g'
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call'
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each'
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/railties-3.2.18/lib/rails/rack/log_tailer.rb:17:in `call'
/home/ybronhei/foreman/vendor/ruby/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
/usr/share/ruby/webrick/httpserver.rb:138:in `service'
/usr/share/ruby/webrick/httpserver.rb:94:in `run'
/usr/share/ruby/webrick/server.rb:295:in `block in start_thread'
Rendered api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout (0.6ms)
Completed 500 Internal Server Error in 266.7ms (Views: 2.0ms | ActiveRecord: 107.1ms)

Using v1 to http://0.0.0.0:8080/discovers/[:id] (as UI uses) returns:

Started PUT "/discovers/5254002fe2f6" for 192.168.223.1 at 2014-05-15 08:38:42 +0000
Processing by DiscoversController#update as HTML
Parameters: {"host"=>{"name"=>"5254002fe2f6", "hostgroup_id"=>"2", "environment_id"=>"0", "puppet_ca_proxy_i
d"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]
", "type"=>"Host::Managed", "mac"=>"52:54:00:2f:e2:f6", "domain_id"=>"0", "subnet_id"=>"0", "ip"=>"192.168.223.56", "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", "type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", "operatingsystem_id"=>"0", "provision_method"=>"build", "build"=>"1", "medium_id"=>"0", "ptable_id"=>"6", "disk"=>"", "root_pass"=>"[FILTERED]", "host_parameters_attributes"=>{""=>{"name"=>"host_id", "value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>""}}, "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"}, "id"=>"5254002fe2f6", "discover"=>{"host"=>{"name"=>"5254002fe2f6", "hostgroup_id"=>"2", "environment_id"=>"0", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "mac"=>"52:54:00:2f:e2:f6", "domain_id"=>"0", "subnet_id"=>"0", "ip"=>"192.168.223.56", "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", "type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", "operatingsystem_id"=>"0", "provision_method"=>"build", "build"=>"1", "medium_id"=>"0", "ptable_id"=>"6", "disk"=>"", "root_pass"=>"[FILTERED]", "host_parameters_attributes"=>{""=>{"name"=>"host_id", "value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>""}}, "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"}, "id"=>"5254002fe2f6"}}
WARNING: Can't verify CSRF token authenticity
Failed to save: Name must not include periods, Name is invalid
Rendered hosts/_progress.html.erb (0.5ms)
Rendered common/_domain.html.erb (1.8ms)

Actions #1

Updated by Dominic Cleal almost 10 years ago

  • Project changed from Foreman to Discovery
  • Priority changed from Urgent to Normal
Actions #2

Updated by Yaniv Bronhaim almost 10 years ago

the following pull request fix the issue: https://github.com/theforeman/foreman_discovery/pull/70

Actions #3

Updated by Lukas Zapletal almost 10 years ago

I believe this can be closed now.

Actions #4

Updated by Greg Sutcliffe almost 10 years ago

  • Status changed from New to Ready For Testing
Actions #5

Updated by Greg Sutcliffe almost 10 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF