Project

General

Profile

Actions

Bug #8810

closed

Unable To Create New VMWare Host Using Hammer

Added by Jason Wever over 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Foreman commands (obsolete)
Target version:
-
Difficulty:
Triaged:
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

I've been attempting to use hammer to create hosts for VMWare, but it always returns:

[ERROR 2014-12-29 19:10:17 Exception] Failed to create a compute vsphere-foo (VMWare) instance foo.bar.com: failed to create vm: undefined method `new' for nil:NilClass

Could not create the host:
  Failed to create a compute vsphere-foo (VMWare) instance foo.bar.com: failed to create vm: undefined method `new' for nil:NilClass

Hammer is being run from the same host running The Foreman, which is running CentOS 6.6. I've encountered this with The Foreman 1.4, 1.5, 1.6 and 1.7, all installed via the official YUM repository. The Foreman has a compute resource configured for a VMWare vSphere 5.5.0 build 2001466. The Foreman can successfully provision VMs via the Web GUI.

The command I'm using to create hosts is:

hammer -v --show-ids host create \
  --architecture-id=1 \
  --build=false \
  --compute-attributes="cluster=QA,cpus=1,memory_mb=2048,path=/Datacenters/Foo/vm" \
  --compute-profile-id=8 \
  --compute-resource-id=3 \
  --domain-id=3 \
  --environment-id=1 \
  --hostgroup-id=8 \
  --interface="type=network,network=network-30" \
  --name="foo" \
  --operatingsystem-id=19 \
  --owner-id=8 \
  --partition-table-id=1 \
  --puppet-proxy-id=1 \
  --volume="datastore=mushka,name='Hard disk',size_gb=10" 

The latest log entry for this event from The Foreman 1.7.1 is:

Started POST "/api/hosts" for 127.0.0.1 at 2014-12-29 19:10:14 +0000
Processing by Api::V2::HostsController#create as JSON
  Parameters: {"host"=>{"compute_resource_id"=>"3", "ptable_id"=>"1", "compute_attributes"=>{"cpus"=>"1", "cluster"=>"QA", "interfaces_attributes"=>{"0"=>{"type"=>"network", "network"=>"network-30"}}, "path"=>"/Datacenters/Foo/vm", "volumes_attributes"=>{"0"=>{"data
store"=>"mushka", "size_gb"=>"10", "name"=>"'Hard disk'"}}, "memory_mb"=>"2048", "nics_attributes"=>{"0"=>{"type"=>"network", "network"=>"network-30"}}}, "owner_id"=>"8", "build"=>false, "puppet_proxy_id"=>"1", "environment_id"=>"1", "managed"=>true, "architecture_id"=>"1",
 "name"=>"qa7-proxy1", "host_parameters_attributes"=>{}, "enabled"=>true, "hostgroup_id"=>"8", "domain_id"=>"3", "compute_profile_id"=>"8", "operatingsystem_id"=>"19"}, "apiv"=>"v2"}
Authorized user apiuser(apiuser)
Adding Compute instance for foo.bar.com
Successfully decrypted field for Foreman::Model::Vmware vsphere-foo
Successfully decrypted field for Foreman::Model::Vmware vsphere-foo
Failed to create a compute vsphere-foo (VMWare) instance foo.bar.com: failed to create vm: undefined method `new' for nil:NilClass
 /opt/rh/ruby193/root/usr/share/gems/gems/fog-1.24.0/lib/fog/vsphere/requests/compute/create_vm.rb:28:in `rescue in create_vm'
/opt/rh/ruby193/root/usr/share/gems/gems/fog-1.24.0/lib/fog/vsphere/requests/compute/create_vm.rb:8:in `create_vm'
/opt/rh/ruby193/root/usr/share/gems/gems/fog-1.24.0/lib/fog/vsphere/models/compute/server.rb:232:in `save'
/usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:318:in `create_vm'
/usr/share/foreman/app/models/concerns/orchestration/compute.rb:74:in `setCompute'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `execute'
/usr/share/foreman/app/models/concerns/orchestration.rb:85:in `block in process'
/usr/share/foreman/app/models/concerns/orchestration.rb:77:in `each'
/usr/share/foreman/app/models/concerns/orchestration.rb:77:in `process'
/usr/share/foreman/app/models/concerns/orchestration.rb:18:in `on_save'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:671:in `_run__1256900671078961833__save__1483983808616611460__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:264:in `create_or_update'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/persistence.rb:84:in `save'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:50:in `save'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:241:in `block in save'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:240:in `save'
/usr/share/foreman/app/models/concerns/foreman/sti.rb:29:in `save_with_type'
/usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:83:in `create'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:539:in `block (4 levels) in _run__1469338906402411663__process_action__2924592222872804716__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_7325'
/usr/share/foreman/app/controllers/api/v2/base_controller.rb:151:in `disable_json_root'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_7325'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:516:in `block (3 levels) in _run__1469338906402411663__process_action__2924592222872804716__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_7324'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:326:in `around'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:310:in `_callback_around_1869'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_7324'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:493:in `block (2 levels) in _run__1469338906402411663__process_action__2924592222872804716__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_7323'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_7323'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:426:in `block in _run__1469338906402411663__process_action__2924592222872804716__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_7322'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:326:in `around'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:310:in `_callback_around_13'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_7322'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:414:in `_run__1469338906402411663__process_action__2924592222872804716__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:17:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:121:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:45:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal.rb:203:in `dispatch'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal.rb:246:in `block in action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:36:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/mapper.rb:42:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/opt/rh/ruby193/root/usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:600:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.2.6/lib/apipie/static_dispatcher.rb:65:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.2.6/lib/apipie/extractor/recorder.rb:97:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.2.6/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/conditionalget.rb:35:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:9:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:64:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__2453898334480783709__call__1483983808616611460__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
Rolling back due to a problem: [Set up compute instance foo.bar.com     2       failed  [#<Host::Managed id: nil, name: "foo.bar.com", ip: nil, last_compile: nil, last_freshcheck: nil, last_report: nil, updated_at: nil, source_file_id: nil, created_at: nil, mac: nil, root_pass: "$SUPERFAKEHASH", serial: nil, puppet_status: 0, domain_id: 3, architecture_id: 1, operatingsystem_id: 19, environment_id: 1, subnet_id: nil, ptable_id: 1, medium_id: 1, build: false, comment: nil, disk: nil, installed_at: nil, model_id: nil, hostgroup_id: 8, owner_id: 8, owner_type: "User", enabled: true, puppet_ca_proxy_id: 1, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 3, puppet_proxy_id: 1, certname: nil, image_id: nil, organization_id: nil, location_id: nil, type: "Host::Managed", compute_profile_id: 8, otp: nil, realm_id: nil, provision_method: nil, primary_interface: nil, grub_pass: "$SUPERFAKEHASH">, :setCompute]]
Unprocessable entity Host::Managed (id: new):
  Failed to create a compute vsphere-foo (VMWare) instance foo.bar.com: failed to create vm: undefined method `new' for nil:NilClass

  Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (1.2ms)
Completed 422 Unprocessable Entity in 2666ms (Views: 2.8ms | ActiveRecord: 23.1ms)

Please let me know if you need any additional information. Happy to help with troubleshooting, test patches, etc.

Thanks!


Files

hammer-not-working-debug-run.txt hammer-not-working-debug-run.txt 10.4 KB Jason Wever, 01/19/2015 10:05 AM
hammer-working-debug-run.txt hammer-working-debug-run.txt 16.6 KB Jason Wever, 01/19/2015 10:05 AM

Related issues 2 (0 open2 closed)

Related to Hammer CLI - Bug #11088: Hammer host create docs for wmware miss option for network typeClosed07/10/2015Actions
Related to Hammer CLI - Bug #11084: Send API params of type number as numbersDuplicateMartin Bacovsky07/10/2015Actions
Actions #1

Updated by Anonymous over 9 years ago

  • Category set to Compute resources - VMware
Actions #2

Updated by Jason Wever over 9 years ago

Some additional notes since I submitted this:

  • Upgrading to vSphere 5.5.0 Update 2 didn't change anything
  • To try and isolate things, I tried creating the VM via Fog directly. Both the version of Fog that ships with Foreman 1.7.x and the latest Fog installed via GEM (1.2.6, which was installed on another system that never had Fog installed) generated the following error when attempting to create the VM:
    /usr/lib/ruby/vendor_ruby/fog/vsphere/requests/compute/create_vm.rb:27:in `rescue in create_vm': failed to create vm: undefined method `empty?' for nil:NilClass (NoMethodError)
        from /usr/lib/ruby/vendor_ruby/fog/vsphere/requests/compute/create_vm.rb:8:in `create_vm'
        from /usr/lib/ruby/vendor_ruby/fog/vsphere/models/compute/server.rb:234:in `save'
        from /usr/lib/ruby/vendor_ruby/fog/core/collection.rb:52:in `create'
        from ./fog-test.rb:11:in `<main>'
    

    For reference, the ruby script I'm using to try to get Fog to create the VM is:
    require 'fog'
    
    compute  =Fog::Compute.new(credentials)
    
    server = compute.servers.create(
      :name               => "foo.bar.com",
      :cluster            => "Foo",
      :datacenter         => "Foo",
      :memoryMB           => "1024",
      :numCPUs            => "1",
      :numCoresPerSocket  => "1",
    )
    

Is this something better taken up with the Fog developers for now?

Actions #3

Updated by Jason Wever over 9 years ago

In further testing, I was able to get this working. The problem seems to be using --domain-id=3 instead of --domain=bar.com.

If I use the name, it's able to create the host, but if I use the ID option and use the ID that corresponds to the domain I want (based on the output of hammer domain list), I get the error previously listed about nil:NilClass.

Actions #4

Updated by Dominic Cleal over 9 years ago

Interesting. If you run "hammer -d host create ... --domain=bar.com" does it show domain_id being sent in the request? Perhaps if you could include that debug it would be useful.

#6343 did fix some issues with name to ID lookups not being sent to the API correctly, but it appears to be in Hammer 0.1.2 or higher.

Updated by Jason Wever over 9 years ago

Apparently I slightly mispoke. When I went back to test based on your comment, it turns out to be the --compute-resource-id vs --compute-resource option. Thought I had made sure that worked, but it doesn't seem to.

Similar to my previous comment however, the ID I was using for --compute-resource-id was derived from the output of "hammer compute-resource list", as well as the name to use for --compute-resource=.

When it works, the debug output shows it using the ID for the Compute Resource (3), but unlike the other parameters that are specified by ID on hammer's command line, the number 3 is not surrounded in double quotes.

I've attached debug runs of hammer, one for a working run with --compute-resource=vsphere-foo and one where it doesn't run with --compute-resource-id=3

Actions #6

Updated by Dominic Cleal over 9 years ago

  • Project changed from Foreman to Hammer CLI
  • Category changed from Compute resources - VMware to Foreman commands (obsolete)
Actions #7

Updated by salman butt almost 9 years ago

Think I'm hitting the same bug in theforeman 1.8.

Posted details, with trace here: https://groups.google.com/forum/#!topic/foreman-users/-x7VX9wen7M

Full trace can be found here: http://pastie.org/10126071

Using the compute-resource name instead of id did not work for me.

Actions #8

Updated by Martin Bacovsky almost 9 years ago

Thanks for detailed report.

It seems that somewhere down the road on the server the id parameters are not converted to numbers properly. It will need more investigation for the real cause.

As a workaround in hammer you could try this patch:
https://github.com/mbacovsky/hammer-cli-foreman/commit/d31a60f1bbf485ba9f391c0839be4cc2ed094cfa.diff

It will send values of id params as numbers. It would be great if you can test that it solves the issue.

Actions #9

Updated by salman butt almost 9 years ago

Martin,

I applied the patch and ran a test, but the result appears to be the same.

Debug info: http://pastie.org/10190864
Trace: http://pastie.org/10190882

OS version is: OEL 6.5 -- if it matters/helps.

Please let me know if I can provide any other info.

Actions #10

Updated by The Foreman Bot almost 9 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/hammer-cli/pull/171 added
  • Pull request deleted ()
Actions #11

Updated by Martin Bacovsky almost 9 years ago

Salman,
could you please retest with https://github.com/theforeman/hammer-cli-foreman/pull/184 and https://github.com/theforeman/hammer-cli/pull/171? From your last logs it seems, that only puppet_proxy_id was not converted. I fixed it in hammer core (the second PR).

Actions #12

Updated by Tomáš Strachota almost 9 years ago

I checked the proposed PR and I'm afraid it doesn't solve the problem. Detailed look at the logs showed it's actually combination of two problems:

  1. First thing is the network interface hammer command misses network type. There should be attribute compute_type. It's also a documentation issue because https://github.com/theforeman/hammer-cli-foreman/blob/master/doc/host_create.md#vmware doesn't mention such parameter. So the server side failure in fog is caused by the network type not being present.
  2. There's also a bug in hammer 0.1.3 that causes example from comment http://projects.theforeman.org/issues/8810#note-5 seemingly succeed. In fact, when the compute resource is specified by name, the network compute details are sent in a different data structure. They are silently ignored and defaults are used. See https://github.com/theforeman/hammer-cli-foreman/blob/35c21aa6d8c4d0fc0e15c15cd3e0dd77f81d39f1/lib/hammer_cli_foreman/host.rb#L79 for details. This is fixed in hammer 0.2.0.
The PR is still valuable but it fixes something else. I propose to:
  1. Create correct issue for the PR and merge it with that issue.
  2. Create an issue for updating the host create docs.
  3. Close this one as it's fixed in latest hammer.

The issues will follow.

Actions #13

Updated by Tomáš Strachota almost 9 years ago

  • Related to Bug #11088: Hammer host create docs for wmware miss option for network type added
Actions #14

Updated by Tomáš Strachota almost 9 years ago

  • Related to Bug #11084: Send API params of type number as numbers added
Actions #15

Updated by Tomáš Strachota over 8 years ago

  • Status changed from Ready For Testing to Closed
  • Pull request added
  • Pull request deleted (https://github.com/theforeman/hammer-cli/pull/171)

Fixed in hammer 0.2.0, closing.

Actions

Also available in: Atom PDF