diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-10 08:44:56 -0600 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-10 07:11:33 -0800 |
commit | 20ecc2e5a5e19bdae106a5ccd8863adbde60eac6 (patch) | |
tree | c6774bec11574957b0dd6570d866c915433fff13 /lib/chef | |
parent | 68bab0b362c47e5a75492e57094f72ecee1171ae (diff) | |
download | chef-20ecc2e5a5e19bdae106a5ccd8863adbde60eac6.tar.gz |
dsc_script passes timeout to lcm shellout
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/provider/dsc_script.rb | 16 | ||||
-rw-r--r-- | lib/chef/util/dsc/local_configuration_manager.rb | 14 |
2 files changed, 18 insertions, 12 deletions
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index d1f62d7f0d..c183f871e9 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -32,11 +32,11 @@ class Chef @dsc_resource = dsc_resource @resource_converged = false @operations = { - :set => Proc.new { |config_manager, document| - config_manager.set_configuration(document) + :set => Proc.new { |config_manager, document, shellout_flags| + config_manager.set_configuration(document, shellout_flags) }, - :test => Proc.new { |config_manager, document| - config_manager.test_configuration(document) + :test => Proc.new { |config_manager, document, shellout_flags| + config_manager.test_configuration(document, shellout_flags) }} end @@ -89,9 +89,15 @@ class Chef config_manager = Chef::Util::DSC::LocalConfigurationManager.new(@run_context.node, config_directory) + shellout_flags = { + :cwd => @dsc_resource.cwd, + :environment => @dsc_resource.environment, + :timeout => @dsc_resource.timeout + } + begin configuration_document = generate_configuration_document(config_directory, configuration_flags) - @operations[operation].call(config_manager, configuration_document) + @operations[operation].call(config_manager, configuration_document, shellout_flags) rescue Exception => e Chef::Log.error("DSC operation failed: #{e.message.to_s}") raise e diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb index c3149429f9..f8398341e5 100644 --- a/lib/chef/util/dsc/local_configuration_manager.rb +++ b/lib/chef/util/dsc/local_configuration_manager.rb @@ -27,14 +27,14 @@ class Chef::Util::DSC clear_execution_time end - def test_configuration(configuration_document) - status = run_configuration_cmdlet(configuration_document) + def test_configuration(configuration_document, shellout_flags) + status = run_configuration_cmdlet(configuration_document, false, shellout_flags) log_what_if_exception(status.stderr) unless status.succeeded? configuration_update_required?(status.return_value) end - def set_configuration(configuration_document) - run_configuration_cmdlet(configuration_document, true) + def set_configuration(configuration_document, shellout_flags) + run_configuration_cmdlet(configuration_document, true, shellout_flags) end def last_operation_execution_time_seconds @@ -45,7 +45,7 @@ class Chef::Util::DSC private - def run_configuration_cmdlet(configuration_document, apply_configuration = false) + def run_configuration_cmdlet(configuration_document, apply_configuration, shellout_flags) Chef::Log.debug("DSC: Calling DSC Local Config Manager to #{apply_configuration ? "set" : "test"} configuration document.") test_only_parameters = ! apply_configuration ? '-whatif; if (! $?) { exit 1 }' : '' @@ -57,9 +57,9 @@ class Chef::Util::DSC save_configuration_document(configuration_document) cmdlet = ::Chef::Util::Powershell::Cmdlet.new(@node, "#{command_code}") if apply_configuration - status = cmdlet.run! + status = cmdlet.run!({}, shellout_flags) else - status = cmdlet.run + status = cmdlet.run({}, shellout_flags) end ensure end_operation_timing |