MiQ connecting directly to ESXi


#1

All,

We were wondering if it’s possible to connect directly to an ESXi server using ManageIQ, basically going around vCenter? Has anyone done this?

Cheers,
Derek


Can standalone ESXi OS be added as VMWare provider?
Adding free esxi to manageiq - data collection is not happening
#2

Not 100% sure as I haven’t tried in forever, but you should be able to add an ESXi box as an Infra Provider. The refresh should create 1 Host, and everything else will work the same after that. ESXi and vCenter have the same API, so that works out nice.


#3

Hi @dthurston,

I can confirm that it is possible to connect ManageIQ directly to the ESXi 5.5. I can monitor the VMs, but still have issues with managing them (starting, stopping, etc). I’m not sure what is wrong. There is some log output when start VM is initiated, if anyone is interested.

[----] I, [2015-01-15T10:30:31.214839 #6366:5ffe9c]  INFO -- : MIQ(ScheduleWorker.do_work) Number of scheduled items to be processed: 0.
[----] I, [2015-01-15T10:30:34.198275 #6370:dbfeac]  INFO -- : MIQ(MiqQueue.put)Message id: [32486],  id: [], Zone: [default], Role: [], Server: [], Ident: [generic], Target id: [], Instance
 id: [], Task id: [], Command: [Vm.invoke_tasks], Timeout: [600], Priority: [100], State: [ready], Deliver On: [], Data: [], Args: [{:ids=>["2"], :task=>"start", :userid=>"admin"}]
[----] I, [2015-01-15T10:30:39.034636 #6065:cebea4]  INFO -- : MIQ(MiqServer.populate_queue_messages) Fetched 1 miq_queue rows for queue_name=generic, wcount=4, priority=200
[----] I, [2015-01-15T10:30:41.285934 #6336:3c7ea4]  INFO -- : MIQ(MiqQueue.get_via_drb) Message id: [32486], MiqWorker id: [2], Zone: [default], Role: [], Server: [], Ident: [generic], Target id: [
], Instance id: [], Task id: [], Command: [Vm.invoke_tasks], Timeout: [600], Priority: [100], State: [dequeue], Deliver On: [], Data: [], Args: [{:ids=>["2"], :task=>"start", :userid=>"admin"}], Deq
ueued in: [7.098072014] seconds
[----] I, [2015-01-15T10:30:41.286091 #6336:3c7ea4]  INFO -- : MIQ(MiqQueue.deliver)Message id: [32486], Delivering...
[----] I, [2015-01-15T10:30:41.319266 #6336:3c7ea4]  INFO -- : MIQ(MiqQueue.put)Message id: [32487],  id: [], Zone: [default], Role: [ems_operations], Server: [], Ident: [generic], Target id
: [], Instance id: [2], Task id: [], Command: [VmOrTemplate.start], Timeout: [600], Priority: [100], State: [ready], Deliver On: [], Data: [], Args: []
[----] I, [2015-01-15T10:30:41.326551 #6336:3c7ea4]  INFO -- : <AuditSuccess> MIQ(VmOrTemplate.block in invoke_tasks_local) userid: [admin] - ubuntu-server-12.04-amd64: 'start' successfully initiate
d
[----] I, [2015-01-15T10:30:41.326649 #6336:3c7ea4]  INFO -- : MIQ(MiqTask.update_status) Task: [144] [Queued] [Ok] [Task has been queued]
[----] I, [2015-01-15T10:30:41.333394 #6336:3c7ea4]  INFO -- : MIQ(MiqQueue.delivered)  Message id: [32486], State: [ok], Delivered in [0.047304617] seconds
[----] I, [2015-01-15T10:30:44.058712 #6065:cebea4]  INFO -- : MIQ(MiqServer.populate_queue_messages) Fetched 1 miq_queue rows for queue_name=generic, wcount=4, priority=200
[----] I, [2015-01-15T10:30:44.354625 #6336:3c7ea4]  INFO -- : MIQ(MiqQueue.get_via_drb) Message id: [32487], MiqWorker id: [2], Zone: [default], Role: [ems_operations], Server: [], Ident: [generic], Target id: [], Instance id: [2], Task id: [], Command: [VmOrTemplate.start], Timeout: [600], Priority: [100], State: [dequeue], Deliver On: [], Data: [], Args: [], Dequeued in: [3.043124337] seconds
[----] I, [2015-01-15T10:30:44.354853 #6336:3c7ea4]  INFO -- : MIQ(MiqQueue.deliver)Message id: [32487], Delivering...
[----] I, [2015-01-15T10:30:44.363571 #6336:3c7ea4]  INFO -- : MIQ(Event.raise_evm_event): Event Raised [request_vm_start]
[----] I, [2015-01-15T10:30:44.385840 #6336:3c7ea4]  INFO -- : MIQ(Event.raise_evm_event): Alert for Event [request_vm_start]
[----] I, [2015-01-15T10:30:44.386005 #6336:3c7ea4]  INFO -- : MIQ(MiqAlert.evaluate_alerts) [request_vm_start] Target: VmVmware Name: [ubuntu-server-12.04-amd64], Id: [2]
[----] I, [2015-01-15T10:30:44.409345 #6336:3c7ea4]  INFO -- : MIQ(VmVmware#run_command_via_parent) Invoking [vm_start] through EMS: [VMware]
[----] I, [2015-01-15T10:30:44.409764 #6336:3c7ea4]  INFO -- : MIQ(EmsVmware.with_provider_connection) Connecting through EmsVmware: [VMware]
[----] I, [2015-01-15T10:30:44.433820 #6336:3c7ea4]  INFO -- : MIQ(MiqFaultTolerantVim._connect) EMS: [VMware] [Broker] Connecting with address: [172.16.117.148], userid: [root]...
[----] I, [2015-01-15T10:30:44.456144 #6336:3c7ea4]  INFO -- : MIQ(MiqFaultTolerantVim._connect) EMS: [VMware] [Broker] 172.16.117.148 is ESX, API version: 5.5
[----] I, [2015-01-15T10:30:44.456299 #6336:3c7ea4]  INFO -- : MIQ(MiqFaultTolerantVim._connect) EMS: [VMware] [Broker] Connected
[----] E, [2015-01-15T10:30:44.466107 #6336:3c7ea4] ERROR -- : MIQ(MiqQueue.deliver)Message id: [32487], Error: [Could not find VM: ha-host]
[----] E, [2015-01-15T10:30:44.466323 #6336:3c7ea4] ERROR -- : [MiqException::MiqVimResourceNotFound]: Could not find VM: ha-host  Method:[rescue in deliver]
[----] E, [2015-01-15T10:30:44.466416 #6336:3c7ea4] ERROR -- : (druby://127.0.0.1:58266) /var/www/miq/lib/VMwareWebService/MiqVim.rb:42:in `block in getVimVmByMor'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/sync.rb:233:in `block in sync_synchronize'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/sync.rb:230:in `handle_interrupt'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/sync.rb:230:in `sync_synchronize'
(druby://127.0.0.1:58266) /var/www/miq/lib/VMwareWebService/MiqVim.rb:41:in `getVimVmByMor'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/drb/drb.rb:1588:in `perform_without_block'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/drb/drb.rb:1548:in `perform'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/drb/drb.rb:1626:in `block (2 levels) in main_loop'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/drb/drb.rb:1622:in `loop'
(druby://127.0.0.1:58266) /opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/drb/drb.rb:1622:in `block in main_loop'
(druby://127.0.0.1:58266) /var/www/miq/vmdb/lib/extensions/ar_thread.rb:22:in `block in start_with_release'
/var/www/miq/lib/util/miq_fault_tolerant_vim.rb:41:in `block in method_missing'
/var/www/miq/lib/util/miq_fault_tolerant_vim.rb:86:in `_execute_with_broker'
/var/www/miq/lib/util/miq_fault_tolerant_vim.rb:75:in `_execute'
/var/www/miq/lib/util/miq_fault_tolerant_vim.rb:41:in `method_missing'
/var/www/miq/vmdb/app/models/vm_or_template/vmware_shared.rb:33:in `provider_object'
/var/www/miq/vmdb/app/models/mixins/provider_object_mixin.rb:15:in `block in with_provider_object'
/var/www/miq/vmdb/app/models/mixins/vim_connect_mixin.rb:39:in `with_provider_connection'
/var/www/miq/vmdb/app/models/mixins/provider_object_mixin.rb:13:in `with_provider_object'
/var/www/miq/vmdb/app/models/ems_vmware.rb:405:in `invoke_vim_ws'
/var/www/miq/vmdb/app/models/ems_vmware.rb:125:in `vm_start'
/var/www/miq/vmdb/app/models/vm_or_template.rb:336:in `run_command_via_parent'
/var/www/miq/vmdb/app/models/vm_or_template/operations/power.rb:3:in `raw_start'
/var/www/miq/vmdb/app/models/vm_or_template/operations/power.rb:7:in `start'
/var/www/miq/vmdb/app/models/miq_queue.rb:360:in `block in deliver'
/opt/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
/var/www/miq/vmdb/app/models/miq_queue.rb:356:in `deliver'
/var/www/miq/vmdb/lib/workers/queue_worker_base.rb:107:in `deliver_queue_message'
/var/www/miq/vmdb/lib/workers/queue_worker_base.rb:135:in `deliver_message'
/var/www/miq/vmdb/lib/workers/queue_worker_base.rb:152:in `block in do_work'
/var/www/miq/vmdb/lib/workers/queue_worker_base.rb:146:in `loop'
/var/www/miq/vmdb/lib/workers/queue_worker_base.rb:146:in `do_work'
/var/www/miq/vmdb/lib/workers/worker_base.rb:317:in `block in do_work_loop'
/var/www/miq/vmdb/lib/workers/worker_base.rb:314:in `loop'
/var/www/miq/vmdb/lib/workers/worker_base.rb:314:in `do_work_loop'
/var/www/miq/vmdb/lib/workers/worker_base.rb:135:in `run'
/var/www/miq/vmdb/lib/workers/worker_base.rb:123:in `start'
/var/www/miq/vmdb/lib/workers/worker_base.rb:23:in `start_worker'
/var/www/miq/vmdb/lib/workers/bin/worker.rb:5:in `<top (required)>'
/opt/rubies/ruby-2.0.0-p598/lib/ruby/gems/2.0.0/bundler/gems/rails-cab310aeee22/railties/lib/rails/commands/runner.rb:52:in `eval'
/opt/rubies/ruby-2.0.0-p598/lib/ruby/gems/2.0.0/bundler/gems/rails-cab310aeee22/railties/lib/rails/commands/runner.rb:52:in `<top (required)>'
/opt/rubies/ruby-2.0.0-p598/lib/ruby/gems/2.0.0/bundler/gems/rails-cab310aeee22/railties/lib/rails/commands.rb:64:in `require'
/opt/rubies/ruby-2.0.0-p598/lib/ruby/gems/2.0.0/bundler/gems/rails-cab310aeee22/railties/lib/rails/commands.rb:64:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'

#4

Hi lads,

I figured out what was wrong here. VM management works with a small change in https://github.com/ManageIQ/manageiq/blob/master/vmdb/app/models/vm_or_template/vmware_shared.rb

The direct connection to ESXi works, if the line “connection.hostSystemsByMor.keys.first” in case option “HostAgent” is changed to “self.ems_ref”. In this case both options ’ when “VirtualCenter” ’ and ’ when"HostAgent" ’ will have the same code, which is surely wrong, and could brick something else. But at least VM management (starting/stopping virtual machines) in ESXi 5.5 works.


#5

Interesting find @cankarm. Can you open another bug issue on the ManageIQ github repo with the details here? Thanks!