Class: ChefMetal::ChefRunData

Inherits:
Object
  • Object
show all
Extended by:
Cheffish::WithPattern
Defined in:
lib/chef_metal/chef_run_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject (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_driverObject (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

#driversObject (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 add_machine_options(options, &block)
  with_machine_options(Chef::Mixin::DeepMerge.hash_only_merge(current_machine_options, options), &block)
end

#auto_batch_machinesObject



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_optionsObject



44
45
46
47
48
49
50
51
52
# File 'lib/chef_metal/chef_run_data.rb', line 44

def current_machine_options
  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, options = nil, &block)
  if drivers[driver] && options
    raise "Driver #{driver} has already been created, options #{options} would be ignored!"
  end
  @current_driver = driver
  @current_driver_options = options
end