"RbVmomi::Fault: NotSupported: The operation is not supported on the object." importing an Host

Problem:

Hi, I’m tring to importing some hosts using rest api. I get this error:

422; HTTP/1.1 422 Unprocessable Entity
{
  "error": {"id":null,"errors":{"base":["Failed to update a compute InfoCert vCenter (VMware) instance ip1cvliwsaut001.clint.infocert.it: NotSupported: The operation is not supported on the object."]},"full_messages":["Failed to update a compute InfoCert vCenter (VMware) instance ip1cvliwsaut001.clint.infocert.it: NotSupported: The operation is not supported on the object."]}
}

Thanks

Expected outcome:

The host is imported and visible on the “All Hosts” page.

Foreman and Proxy versions:

Foreman 1.20.0
Smart Proxy: 1.20.0

Foreman and Proxy plugin versions:

Other relevant data:

Example of JSON to import an host:

{
  "host": {
    "name": "ip1cvliwsaut001.clint.infocert.it",
    "build": false,
    "uuid": "503ce3a8-fdbb-e8ef-36eb-f254a75a7351",
    "operatingsystem_id": 1,
    "architecture_id": 1,
    "ip": "***.***.8.223",
    "mac": "00:50:56:bc:22:14",
    "environment_id": 1,
    "domain_id": 4,
    "subnet_id": 10,
    "owner_id": 2,
    "owner_type": "Usergroup",
    "compute_resource_id": 1,
    "compute_profile_id": 117,
    "hostgroup_id": 2,
    "comment": "test start script"
  }
}

Foreman Log:

2019-01-14T11:44:34 [I|app|] Started POST "/api/v2/hosts" for 10.113.116.124 at 2019-01-14 11:44:34 +0100
2019-01-14T11:44:34 [I|app|cf792] Processing by Api::V2::HostsController#create as JSON
2019-01-14T11:44:34 [I|app|cf792]   Parameters: {"host"=>{"name"=>"ip1cvliwsaut001.clint.infocert.it", "build"=>false, "uuid"=>"503ce3a8-fdbb-e8ef-36eb-f254a75a7351", "operatingsystem_id"=>1, "architecture_id"=>1, "ip"=>"***.***.8.223", "m
ac"=>"00:50:56:bc:22:14", "environment_id"=>1, "domain_id"=>4, "subnet_id"=>10, "owner_id"=>2, "owner_type"=>"Usergroup", "compute_resource_id"=>1, "compute_profile_id"=>117, "hostgroup_id"=>2, "comment"=>"test start script"}, "apiv"=>"v2
"}
2019-01-14T11:44:34 [I|app|cf792] Authorized user foreman_api_admin(API Admin)
2019-01-14T11:44:34 [D|app|cf792] Current user set to foreman_api_admin (admin)
2019-01-14T11:44:35 [D|app|cf792] Reading from compute resource cache: networks
2019-01-14T11:44:36 [D|app|cf792] Scheduling new DHCP reservations for ip1cvliwsaut001.clint.infocert.it
2019-01-14T11:44:36 [D|app|cf792] Enqueued task 'dhcp_create_00:50:56:bc:22:14' to 'Host::Managed Main' queue
2019-01-14T11:44:37 [D|app|cf792] Reading from compute resource cache: networks
2019-01-14T11:44:37 [D|app|cf792] Scheduling compute instance update because memory_mb changed it's value from '20148' (Integer) to '1' (String)
2019-01-14T11:44:37 [D|app|cf792] Detected a change is required for compute resource
2019-01-14T11:44:37 [D|app|cf792] Enqueued task 'Compute resource update for ' to 'Host::Managed Main' queue
2019-01-14T11:44:37 [D|app|cf792] Observed create hook on ip1cvliwsaut001.clint.infocert.it
2019-01-14T11:44:37 [D|app|cf792] Processing task 'Compute resource update for ' from 'Host::Managed Main'
2019-01-14T11:44:37 [I|app|cf792] Update Compute instance for ip1cvliwsaut001.clint.infocert.it
2019-01-14T11:44:38 [W|app|cf792] Failed to update a compute InfoCert vCenter (VMware) instance ip1cvliwsaut001.clint.infocert.it: NotSupported: The operation is not supported on the object.
RbVmomi::Fault: NotSupported: The operation is not supported on the object.
/opt/theforeman/tfm/root/usr/share/gems/gems/rbvmomi-1.10.0/lib/rbvmomi/vim/Task.rb:14:in `wait_for_completion'
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.3.0/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb:10:in `vm_reconfig_hardware'
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.3.0/lib/fog/vsphere/requests/compute/update_vm.rb:31:in `update_vm'
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.3.0/lib/fog/vsphere/models/compute/server.rb:298:in `save'
/usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:484:in `save_vm'
/usr/share/foreman/app/models/concerns/orchestration/compute.rb:214:in `setComputeUpdate'
/usr/share/foreman/app/models/concerns/orchestration.rb:222:in `execute'
/usr/share/foreman/app/models/concerns/orchestration.rb:145:in `block in process'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `each'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `process'
/usr/share/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:816:in `_run_save_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/callbacks.rb:342:in `create_or_update'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/persistence.rb:275:in `save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/validations.rb:46:in `save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:310:in `block (2 levels) in save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `block in transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/opt/rh/rh-ruby25/root/usr/share/ruby/monitor.rb:226:in `mon_synchronize'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:310:in `block in save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:325:in `rollback_active_record_state!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:309:in `save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/suppressor.rb:44:in `save'
/usr/share/foreman/app/models/concerns/foreman/sti.rb:26:in `save'
/usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:145:in `create'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/usr/share/foreman/app/controllers/api/v2/base_controller.rb:163:in `disable_json_root'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/app/controllers/concerns/application_shared.rb:15:in `set_timezone'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.7.1/lib/audited/sweeper.rb:14:in `around'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.7.1/lib/audited/sweeper.rb:14:in `around'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `block in instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:134:in `process'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/rendering.rb:32:in `process'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal.rb:191:in `dispatch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal.rb:252:in `dispatch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:34:in `serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/mapper.rb:48:in `serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:52:in `block in serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:840:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.9/lib/apipie/static_dispatcher.rb:65:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.9/lib/apipie/extractor/recorder.rb:136:in `call'
/usr/share/foreman/lib/middleware/telemetry.rb:9:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.9/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
/usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:8:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/tempfile_reaper.rb:15:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/etag.rb:25:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/conditional_get.rb:38:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
/usr/share/foreman/lib/middleware/logging_context.rb:23:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:in `context'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:28:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/engine.rb:524:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:68:in `block in call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `call'
/usr/share/passenger/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
/usr/share/passenger/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
/usr/share/passenger/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
/usr/share/passenger/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2019-01-14T11:44:38 [W|app|cf792] Rolling back due to a problem: [#<Orchestration::Task:0x00007fa7765be080 @name="Compute resource update for ", @id="Compute resource update for ", @status="failed", @priority=7, @action=[#<Host::Managed i
d: nil, name: "ip1cvliwsaut001.clint.infocert.it", last_compile: nil, last_report: nil, updated_at: nil, created_at: nil, root_pass: nil, architecture_id: 1, operatingsystem_id: 1, environment_id: 1, ptable_id: nil, medium_id: nil, build:
 false, comment: "test start script", disk: nil, installed_at: nil, model_id: nil, hostgroup_id: 2, owner_id: 2, owner_type: "Usergroup", enabled: true, puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil, uuid: "503ce
3a8-fdbb-e8ef-36eb-f254a75a7351", compute_resource_id: 1, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: nil, location_id: nil, type: "Host::Managed", otp: nil, realm_id: nil, compute_profile_id: 117, provision_metho
d: nil, grub_pass: "", global_status: 0, lookup_value_matcher: "fqdn=ip1cvliwsaut001.clint.infocert.it", pxe_loader: nil, initiated_at: nil, build_errors: nil>, :setComputeUpdate], @created=1547462677.2913363, @timestamp=2019-01-14 10:44:
38 UTC>]
2019-01-14T11:44:38 [I|app|cf792] Processed 1 tasks from queue 'Host::Managed Main', completed 0/2
2019-01-14T11:44:38 [E|app|cf792] Task 'Compute resource update for ' *failed*
2019-01-14T11:44:38 [E|app|cf792] Task 'Create DHCP Settings for ip1cvliwsaut001.clint.infocert.it' *canceled*
2019-01-14T11:44:38 [E|app|cf792] Unprocessable entity Host::Managed (id: new):
  Failed to update a compute InfoCert vCenter (VMware) instance ip1cvliwsaut001.clint.infocert.it: NotSupported: The operation is not supported on the object.

2019-01-14T11:44:38 [I|app|cf792]   Rendering api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout
2019-01-14T11:44:38 [I|app|cf792]   Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (1.6ms)
2019-01-14T11:44:38 [D|app|cf792] Body: {
  "error": {"id":null,"errors":{"base":["Failed to update a compute InfoCert vCenter (VMware) instance ip1cvliwsaut001.clint.infocert.it: NotSupported: The operation is not supported on the object."]},"full_messages":["Failed to update a 
compute InfoCert vCenter (VMware) instance ip1cvliwsaut001.clint.infocert.it: NotSupported: The operation is not supported on the object."]}
}

2019-01-14T11:44:38 [I|app|cf792] Completed 422 Unprocessable Entity in 3191ms (Views: 2.7ms | ActiveRecord: 63.4ms)