summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Murawski <steven.murawski@gmail.com>2016-02-02 16:58:52 -0600
committerSteven Murawski <steven.murawski@gmail.com>2016-02-03 12:32:25 -0600
commit84bdd582a13a90e01a4fdb41bbd6aaae34806719 (patch)
treee6efe1a2d4c82844471168b09207d55edd21b5e4
parentab63cd4be967b5d01f6ec856244e4b9af4e896d9 (diff)
downloadchef-84bdd582a13a90e01a4fdb41bbd6aaae34806719.tar.gz
include verbose output from the set method and shared function for accessing verbose log info.
-rw-r--r--lib/chef/provider/dsc_resource.rb30
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb2
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb
index 56f6d7a6d9..1f6a8f0ef6 100644
--- a/lib/chef/provider/dsc_resource.rb
+++ b/lib/chef/provider/dsc_resource.rb
@@ -122,25 +122,31 @@ class Chef
def test_resource
result = invoke_resource(:test)
- @converge_description = result.stream(:verbose)
-
- # We really want this information from the verbose stream,
- # however in some versions of WMF, Invoke-DscResource is not correctly
- # writing to that stream and instead just dumping to stdout
- if @converge_description.empty?
- @converge_description = result.stdout
- end
-
+ add_dsc_verbose_log(result)
return_dsc_resource_result(result, "InDesiredState")
end
def set_resource
result = invoke_resource(:set)
- if return_dsc_resource_result(result, "RebootRequired")
- create_reboot_resource
- end
+ add_dsc_verbose_log(result)
+ create_reboot_resource if return_dsc_resource_result(result, "RebootRequired")
result.return_value
end
+
+ def add_dsc_verbose_log(result)
+ # We really want this information from the verbose stream,
+ # however in some versions of WMF, Invoke-DscResource is not correctly
+ # writing to that stream and instead just dumping to stdout
+ verbose_output = result.stream(:verbose)
+ verbose_output = result.stdout if verbose_output.empty?
+
+ if @converge_description.nil? || @converge_description.empty?
+ @converge_description = verbose_output
+ else
+ @converge_description << "\n"
+ @converge_description << verbose_output
+ end
+ end
def invoke_resource(method, output_format=:object)
properties = translate_type(@new_resource.properties)
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index e47da8a165..6a5063ac60 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -98,6 +98,7 @@ describe Chef::Provider::DscResource do
expect(provider).to receive(:test_resource).and_return(false)
expect(provider).to receive(:invoke_resource).
and_return(double(:stdout => "", :return_value =>nil))
+ expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(true)
expect(provider).to receive(:create_reboot_resource)
provider.run_action(:run)
@@ -108,6 +109,7 @@ describe Chef::Provider::DscResource do
expect(provider).to receive(:test_resource).and_return(false)
expect(provider).to receive(:invoke_resource).
and_return(double(:stdout => "", :return_value =>nil))
+ expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(false)
expect(provider).to_not receive(:create_reboot_resource)
provider.run_action(:run)