lib/chef/provisioning/chef_run_data.rb in chef-provisioning-0.19 vs lib/chef/provisioning/chef_run_data.rb in chef-provisioning-0.20

- old
+ new

@@ -1,8 +1,7 @@ require 'chef/mixin/deep_merge' require 'cheffish/merged_config' -require 'chef/provisioning/chef_machine_spec' class Chef module Provisioning class ChefRunData @@ -15,11 +14,10 @@ attr_reader :drivers attr_reader :current_driver attr_accessor :current_machine_options attr_accessor :current_load_balancer_options attr_accessor :current_image_options - attr_accessor :current_data_center def with_machine_options(value) old_value = self.current_machine_options self.current_machine_options = value if block_given? @@ -41,30 +39,25 @@ self.current_image_options = old_value end end end - def with_data_center(value) - old_value = self.current_data_center - self.current_data_center = value + def with_driver(driver, options = nil, &block) + if drivers[driver] && options + raise "Driver #{driver} has already been created, options #{options} would be ignored!" + end + old_driver, old_options = @current_driver, @current_driver_options + @current_driver, @current_driver_options = driver, options if block_given? begin yield ensure - self.current_data_center = old_value + @current_driver, @current_driver_options = old_driver, old_options end end end - 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 - def current_driver @current_driver || config[:driver] end def current_machine_options @@ -90,13 +83,13 @@ def driver_for(driver) driver.is_a?(String) ? driver_for_url(driver) : driver end def connect_to_machine(name, chef_server = nil) - if name.is_a?(MachineSpec) + if name.is_a?(ManagedEntry) machine_spec = name else - machine_spec = Chef::Provisioning::ChefMachineSpec.get(name, chef_server) + machine_spec = Provisioning.chef_managed_entry_store(chef_server).get(:machine, name) end Chef::Provisioning.connect_to_machine(machine_spec, config) end private