Class: ChefMetal::ChefRunData
- Inherits:
-
Object
- Object
- ChefMetal::ChefRunData
- Extended by:
- Cheffish::WithPattern
- Defined in:
- lib/chef_metal/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.
-
#drivers ⇒ Object
readonly
Returns the value of attribute drivers.
Instance Method Summary collapse
- #add_machine_options(options, &block) ⇒ Object
- #auto_batch_machines ⇒ Object
- #auto_batch_machines=(value) ⇒ Object
- #current_machine_options ⇒ Object
- #driver_for(driver) ⇒ Object
-
#initialize(config) ⇒ ChefRunData
constructor
A new instance of ChefRunData.
- #with_driver(driver, options = nil, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ ChefRunData
Returns a new instance of ChefRunData.
9 10 11 12 |
# File 'lib/chef_metal/chef_run_data.rb', line 9 def initialize(config) @config = config @drivers = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/chef_metal/chef_run_data.rb', line 14 def config @config end |
#current_driver ⇒ Object (readonly)
Returns the value of attribute current_driver.
16 17 18 |
# File 'lib/chef_metal/chef_run_data.rb', line 16 def current_driver @current_driver end |
#drivers ⇒ Object (readonly)
Returns the value of attribute drivers.
15 16 17 |
# File 'lib/chef_metal/chef_run_data.rb', line 15 def drivers @drivers end |
Instance Method Details
#add_machine_options(options, &block) ⇒ Object
54 55 56 |
# File 'lib/chef_metal/chef_run_data.rb', line 54 def (, &block) (Chef::Mixin::DeepMerge.hash_only_merge(, ), &block) end |
#auto_batch_machines ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/chef_metal/chef_run_data.rb', line 28 def auto_batch_machines if !@auto_batch_machines.nil? @auto_batch_machines else config[:auto_batch_machines] end end |
#auto_batch_machines=(value) ⇒ Object
36 37 38 |
# File 'lib/chef_metal/chef_run_data.rb', line 36 def auto_batch_machines=(value) @auto_batch_machines = value end |
#current_machine_options ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/chef_metal/chef_run_data.rb', line 44 def if @current_machine_options @current_machine_options elsif current_driver driver_for(current_driver).config[:machine_options] || {} else {} end end |
#driver_for(driver) ⇒ Object
58 59 60 |
# File 'lib/chef_metal/chef_run_data.rb', line 58 def driver_for(driver) driver.is_a?(String) ? driver_for_url(driver) : driver end |
#with_driver(driver, options = nil, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/chef_metal/chef_run_data.rb', line 20 def with_driver(driver, = nil, &block) if drivers[driver] && raise "Driver #{driver} has already been created, options #{} would be ignored!" end @current_driver = driver @current_driver_options = end |