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



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

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

#create_image(image_spec) ⇒ Object



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

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



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

def load_current_resource
end

#new_driverObject

Get the driver specified in the resource



19
20
21
# File 'lib/chef/provider/machine_image.rb', line 19

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