Class: Chef::Provisioning::ChefRunData
- Inherits:
-
Object
- Object
- Chef::Provisioning::ChefRunData
- Defined in:
- lib/chef/provisioning/chef_run_data.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current_driver ⇒ Object
readonly
Returns the value of attribute current_driver.
-
#current_image_options ⇒ Object
Returns the value of attribute current_image_options.
-
#current_load_balancer_options ⇒ Object
Returns the value of attribute current_load_balancer_options.
-
#current_machine_options ⇒ Object
Returns the value of attribute current_machine_options.
-
#drivers ⇒ Object
readonly
Returns the value of attribute drivers.
Instance Method Summary collapse
- #add_machine_options(options, &block) ⇒ Object
- #connect_to_machine(name, chef_server = nil) ⇒ Object
- #driver_for(driver) ⇒ Object
-
#initialize(config) ⇒ ChefRunData
constructor
A new instance of ChefRunData.
- #with_driver(driver, options = nil, &block) ⇒ Object
- #with_image_options(value) ⇒ Object
- #with_machine_options(value) ⇒ Object
Constructor Details
#initialize(config) ⇒ ChefRunData
Returns a new instance of ChefRunData.
8 9 10 11 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 8 def initialize(config) @config = config @drivers = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 13 def config @config end |
#current_driver ⇒ Object (readonly)
Returns the value of attribute current_driver.
15 16 17 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 15 def current_driver @current_driver end |
#current_image_options ⇒ Object
Returns the value of attribute current_image_options.
18 19 20 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 18 def @current_image_options end |
#current_load_balancer_options ⇒ Object
Returns the value of attribute current_load_balancer_options.
17 18 19 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 17 def @current_load_balancer_options end |
#current_machine_options ⇒ Object
Returns the value of attribute current_machine_options.
16 17 18 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 16 def @current_machine_options end |
#drivers ⇒ Object (readonly)
Returns the value of attribute drivers.
14 15 16 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 14 def drivers @drivers end |
Instance Method Details
#add_machine_options(options, &block) ⇒ Object
79 80 81 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 79 def (, &block) (Chef::Mixin::DeepMerge.hash_only_merge(, ), &block) end |
#connect_to_machine(name, chef_server = nil) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 87 def connect_to_machine(name, chef_server = nil) if name.is_a?(ManagedEntry) machine_spec = name else machine_spec = Provisioning.chef_managed_entry_store(chef_server).get(:machine, name) end Chef::Provisioning.connect_to_machine(machine_spec, config) end |
#driver_for(driver) ⇒ Object
83 84 85 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 83 def driver_for(driver) driver.is_a?(String) ? driver_for_url(driver) : driver end |
#with_driver(driver, options = nil, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 44 def with_driver(driver, = nil, &block) if drivers[driver] && raise "Driver #{driver} has already been created, options #{} would be ignored!" end old_driver, = @current_driver, @current_driver_options @current_driver, @current_driver_options = driver, if block_given? begin yield ensure @current_driver, @current_driver_options = old_driver, end end end |
#with_image_options(value) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 32 def (value) old_value = self. self. = value if block_given? begin yield ensure self. = old_value end end end |
#with_machine_options(value) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chef/provisioning/chef_run_data.rb', line 20 def (value) old_value = self. self. = value if block_given? begin yield ensure self. = old_value end end end |