Module: CustomizationHelper

Included in:
Chef::Knife::VsphereVmClone, Chef::Knife::VsphereVmWaitSysprep
Defined in:
lib/chef/knife/customization_helper.rb

Class Method Summary collapse

Class Method Details

.query_customization_succeeded(vm, vem) ⇒ Object



34
35
36
37
38
39
# File 'lib/chef/knife/customization_helper.rb', line 34

def self.query_customization_succeeded(vm, vem)
  vem.QueryEvents(filter:
      RbVmomi::VIM::EventFilterSpec(entity:
      RbVmomi::VIM::EventFilterSpecByEntity(entity: vm, recursion:
      RbVmomi::VIM::EventFilterSpecRecursionOption(:self)), eventTypeId: ['CustomizationSucceeded']))
end

.wait_for_sysprep(vm, vim_connection, timeout, sleep_time) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chef/knife/customization_helper.rb', line 9

def self.wait_for_sysprep(vm, vim_connection, timeout, sleep_time)
  vem = vim_connection.serviceContent.eventManager

  wait = true
  waited_seconds = 0

  print 'Waiting for sysprep...'
  while wait
    events = query_customization_succeeded(vm, vem)

    if events.size > 0
      events.each do |e|
        puts "\n#{e.fullFormattedMessage}"
      end
      wait = false
    elsif waited_seconds >= timeout
      abort "\nCustomization of VM #{vm.name} not succeeded within #{timeout} seconds."
    else
      print '.'
      sleep(sleep_time)
      waited_seconds += sleep_time
    end
  end
end