Class: Chef::Provider::MachineImage

Inherits:
LWRPBase
  • Object
show all
Defined in:
lib/chef/provider/machine_image.rb

Instance Method Summary collapse

Instance Method Details

#action_handlerObject



8
9
10
# File 'lib/chef/provider/machine_image.rb', line 8

def action_handler
  @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
end

#create_image(image_spec) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/chef/provider/machine_image.rb', line 38

def create_image(image_spec)
  # 1. Create the exemplar machine
  machine_provider = Chef::Provider::Machine.new(new_resource, run_context)
  machine_provider.load_current_resource
  machine_provider.action_converge

  # 2. Create the image
  new_driver.allocate_image(action_handler, image_spec, new_resource.image_options,
                            machine_provider.machine_spec)

  # 3. Save the linkage from name -> image id
  image_spec.save(action_handler)

  # 4. Wait for image to be ready
  new_driver.ready_image(action_handler, image_spec, new_resource.image_options)
end

#load_current_resourceObject



12
13
# File 'lib/chef/provider/machine_image.rb', line 12

def load_current_resource
end

#new_driverObject

Get the driver specified in the resource



16
17
18
# File 'lib/chef/provider/machine_image.rb', line 16

def new_driver
  @new_driver ||= run_context.chef_metal.driver_for(new_resource.driver)
end