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
- #connect_to_machine(name, chef_server = nil) ⇒ Object
- #current_image_options ⇒ 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
61 62 63 |
# File 'lib/chef_metal/chef_run_data.rb', line 61 def (, &block) (Chef::Mixin::DeepMerge.hash_only_merge(, ), &block) end |
#auto_batch_machines ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/chef_metal/chef_run_data.rb', line 29 def auto_batch_machines if !@auto_batch_machines.nil? @auto_batch_machines else config[:auto_batch_machines] end end |
#auto_batch_machines=(value) ⇒ Object
37 38 39 |
# File 'lib/chef_metal/chef_run_data.rb', line 37 def auto_batch_machines=(value) @auto_batch_machines = value end |
#connect_to_machine(name, chef_server = nil) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/chef_metal/chef_run_data.rb', line 69 def connect_to_machine(name, chef_server = nil) if name.is_a?(MachineSpec) machine_spec = name else machine_spec = ChefMetal::ChefMachineSpec.get(name, chef_server) end ChefMetal.connect_to_machine(machine_spec, config) end |
#current_image_options ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/chef_metal/chef_run_data.rb', line 53 def if @current_image_options @current_image_options else {} end end |
#current_machine_options ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/chef_metal/chef_run_data.rb', line 45 def if @current_machine_options @current_machine_options else {} end end |
#driver_for(driver) ⇒ Object
65 66 67 |
# File 'lib/chef_metal/chef_run_data.rb', line 65 def driver_for(driver) driver.is_a?(String) ? driver_for_url(driver) : driver end |
#with_driver(driver, options = nil, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/chef_metal/chef_run_data.rb', line 21 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 |