Class: Chef::Provider::Machine
- Inherits:
-
LWRPBase
- Object
- LWRPBase
- Chef::Provider::Machine
- Defined in:
- lib/chef/provider/machine.rb
Instance Attribute Summary collapse
-
#machine_spec ⇒ Object
readonly
Returns the value of attribute machine_spec.
Class Method Summary collapse
Instance Method Summary collapse
- #action_handler ⇒ Object
- #action_handler=(value) ⇒ Object
- #chef_managed_entry_store ⇒ Object
- #current_driver ⇒ Object
- #current_machine_options ⇒ Object
- #from_image_spec ⇒ Object
- #load_current_resource ⇒ Object
- #machine_options(driver) ⇒ Object
- #new_driver ⇒ Object
- #new_machine_options ⇒ Object
- #whyrun_supported? ⇒ Boolean
Instance Attribute Details
#machine_spec ⇒ Object (readonly)
Returns the value of attribute machine_spec.
100 101 102 |
# File 'lib/chef/provider/machine.rb', line 100 def machine_spec @machine_spec end |
Class Method Details
.upload_files(action_handler, machine, files) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/chef/provider/machine.rb', line 166 def self.upload_files(action_handler, machine, files) if files files.each_pair do |remote_file, local| if local.is_a?(Hash) if local[:local_path] machine.upload_file(action_handler, local[:local_path], remote_file) else machine.write_file(action_handler, remote_file, local[:content]) end else machine.upload_file(action_handler, local, remote_file) end end end end |
Instance Method Details
#action_handler ⇒ Object
10 11 12 |
# File 'lib/chef/provider/machine.rb', line 10 def action_handler @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self) end |
#action_handler=(value) ⇒ Object
13 14 15 |
# File 'lib/chef/provider/machine.rb', line 13 def action_handler=(value) @action_handler = value end |
#chef_managed_entry_store ⇒ Object
162 163 164 |
# File 'lib/chef/provider/machine.rb', line 162 def chef_managed_entry_store @chef_managed_entry_store ||= Provisioning.chef_managed_entry_store(new_resource.chef_server) end |
#current_driver ⇒ Object
106 107 108 109 110 |
# File 'lib/chef/provider/machine.rb', line 106 def current_driver if machine_spec.driver_url run_context.chef_provisioning.driver_for(machine_spec.driver_url) end end |
#current_machine_options ⇒ Object
126 127 128 |
# File 'lib/chef/provider/machine.rb', line 126 def (current_driver) end |
#from_image_spec ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/chef/provider/machine.rb', line 112 def from_image_spec @from_image_spec ||= begin if new_resource.from_image chef_managed_entry_store.get!(:machine_image, new_resource.from_image) else nil end end end |
#load_current_resource ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/chef/provider/machine.rb', line 154 def load_current_resource node_driver = Chef::Provider::ChefNode.new(new_resource, run_context) node_driver.load_current_resource json = node_driver.new_json json['normal']['chef_provisioning'] = node_driver.current_json['normal']['chef_provisioning'] @machine_spec = chef_managed_entry_store.new_entry(:machine, new_resource.name, json) end |
#machine_options(driver) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/chef/provider/machine.rb', line 130 def (driver) configs = [] configs << { :convergence_options => [ :chef_server, :allow_overwrite_keys, :source_key, :source_key_path, :source_key_pass_phrase, :private_key_options, :ohai_hints, :public_key_path, :public_key_format, :admin, :validator, :chef_config ].inject({}) do |result, key| result[key] = new_resource.send(key) result end } configs << new_resource. if new_resource. configs << driver.config[:machine_options] if driver.config[:machine_options] Cheffish::MergedConfig.new(*configs) end |
#new_driver ⇒ Object
102 103 104 |
# File 'lib/chef/provider/machine.rb', line 102 def new_driver run_context.chef_provisioning.driver_for(new_resource.driver) end |
#new_machine_options ⇒ Object
122 123 124 |
# File 'lib/chef/provider/machine.rb', line 122 def (new_driver) end |
#whyrun_supported? ⇒ Boolean
19 20 21 |
# File 'lib/chef/provider/machine.rb', line 19 def whyrun_supported? true end |