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



61
62
63
# File 'lib/chef_metal/chef_run_data.rb', line 61

def add_machine_options(options, &block)
  with_machine_options(Chef::Mixin::DeepMerge.hash_only_merge(current_machine_options, options), &block)
end

#auto_batch_machinesObject



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_optionsObject



53
54
55
56
57
58
59
# File 'lib/chef_metal/chef_run_data.rb', line 53

def current_image_options
  if @current_image_options
    @current_image_options
  else
    {}
  end
end

#current_machine_optionsObject



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

def current_machine_options
  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, 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