Class: Chef::Provider::MachineImage
- Inherits:
-
LWRPBase
- Object
- LWRPBase
- Chef::Provider::MachineImage
- Defined in:
- lib/chef/provider/machine_image.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action_handler ⇒ Object
- #chef_managed_entry_store ⇒ Object
- #create_image(image_spec, machine_options) ⇒ Object
- #load_current_resource ⇒ Object
-
#new_driver ⇒ Object
Get the driver specified in the resource.
- #new_image_options ⇒ Object
- #new_machine_options ⇒ Object
Class Method Details
.additional_image_option_keys ⇒ Object
96 97 98 |
# File 'lib/chef/provider/machine_image.rb', line 96 def self.additional_image_option_keys @@additional_image_option_keys ||= [] end |
Instance Method Details
#action_handler ⇒ Object
10 11 12 |
# File 'lib/chef/provider/machine_image.rb', line 10 def action_handler @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self) end |
#chef_managed_entry_store ⇒ Object
22 23 24 |
# File 'lib/chef/provider/machine_image.rb', line 22 def chef_managed_entry_store @chef_managed_entry_store ||= Provisioning.chef_managed_entry_store(new_resource.chef_server) end |
#create_image(image_spec, machine_options) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/chef/provider/machine_image.rb', line 56 def create_image(image_spec, ) # 1. Create the exemplar machine machine_provider = Chef::Provider::Machine.new(new_resource, run_context) machine_provider.action_handler = action_handler machine_provider.load_current_resource machine_provider.action_converge # 2. Create the image = new_driver.allocate_image(action_handler, image_spec, , machine_provider.machine_spec, ) image_spec.driver_url ||= new_driver.driver_url image_spec.from_image ||= new_resource.from_image if new_resource.from_image image_spec.run_list ||= machine_provider.machine_spec.node['run_list'] # 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, ) machine_provider.action_destroy end |
#load_current_resource ⇒ Object
14 15 |
# File 'lib/chef/provider/machine_image.rb', line 14 def load_current_resource end |
#new_driver ⇒ Object
Get the driver specified in the resource
18 19 20 |
# File 'lib/chef/provider/machine_image.rb', line 18 def new_driver @new_driver ||= run_context.chef_provisioning.driver_for(new_resource.driver) end |
#new_image_options ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/chef/provider/machine_image.rb', line 80 def @new_image_options ||= begin configs = [] configs << new_resource. if new_resource. # See documentation in machine.rb provider (self.class.additional_image_option_keys || []).each do |k| configs << { k => new_resource.send(k)} if new_resource.send(k) end Cheffish::MergedConfig.new(*configs) end end |
#new_machine_options ⇒ Object
92 93 94 |
# File 'lib/chef/provider/machine_image.rb', line 92 def @new_machine_options ||= new_resource. end |