diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-04 17:32:52 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-20 14:38:03 -0700 |
commit | 56020f7d7229802e6c21011330f92197bfcca399 (patch) | |
tree | 2affba95ada69b10b735854930a09767eb912cb4 /lib/chef | |
parent | b7676b756a5b19ec3641b6a05ddfbb17b5d02f8c (diff) | |
download | chef-56020f7d7229802e6c21011330f92197bfcca399.tar.gz |
Make things work
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/provider/dsc_resource.rb | 22 | ||||
-rw-r--r-- | lib/chef/providers.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/dsc_resource.rb | 6 |
3 files changed, 15 insertions, 14 deletions
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb index bfc3b2fecc..c85b4ae075 100644 --- a/lib/chef/provider/dsc_resource.rb +++ b/lib/chef/provider/dsc_resource.rb @@ -23,6 +23,7 @@ require 'chef/mixin/powershell_type_coercions' class Chef class Provider class DscResource < Chef::Provider + include Chef::Mixin::PowershellTypeCoercions provides :dsc_resource, os: "windows" @@ -35,7 +36,7 @@ class Chef def action_run if ! @resource_converged converge_by(generate_description) do - set_configuration + result = set_resource end end end @@ -59,7 +60,7 @@ class Chef end requirements.assert(:run) do |a| a.assertion { - local_configuration_manager.meta_configuration['RefreshMode'] == 'Disabled' + meta_configuration['RefreshMode'] == 'Disabled' } err = ["The LCM must have its RefreshMode set to Disabled. "] a.failure_message Chef::Exceptions::NoProviderAvailable, err.join(' ') @@ -71,8 +72,8 @@ class Chef protected def local_configuration_manager - @local_configuration_manager ||= Chef::Util::DSC::LocalConfigurationManager( - @run_context.node, + @local_configuration_manager ||= Chef::Util::DSC::LocalConfigurationManager.new( + node, nil ) end @@ -87,7 +88,7 @@ class Chef def test_resource result = invoke_resource(:test) - result.return_value["IsDesiredState"] + result.return_value[0]["InDesiredState"] end def set_resource @@ -95,20 +96,19 @@ class Chef result.return_value end - def invoke_resource(method) + def invoke_resource(method, output_format=:object) properties = translate_type(@new_resource.properties) - switches = "-Method #{method.to_s} -Name #{@new_resource.resource} -Property" - + "#{properties} -Verbose" + switches = "-Method #{method.to_s} -Name #{@new_resource.resource} -Property #{properties}" cmdlet = Chef::Util::Powershell::Cmdlet.new( - @node, + node, "Invoke-DscResource #{switches}", - :object + output_format ) cmdlet.run! end def meta_configuration - cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, "Get-DscLocalConfigurationManager", :object) + cmdlet = Chef::Util::Powershell::Cmdlet.new(node, "Get-DscLocalConfigurationManager", :object) result = cmdlet.run! result.return_value end diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb index 796a0f8fa6..a5f5386de3 100644 --- a/lib/chef/providers.rb +++ b/lib/chef/providers.rb @@ -25,6 +25,7 @@ require 'chef/provider/cron/aix' require 'chef/provider/deploy' require 'chef/provider/directory' require 'chef/provider/dsc_script' +require 'chef/provider/dsc_resource' require 'chef/provider/env' require 'chef/provider/erl_call' require 'chef/provider/execute' diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb index c0cf1d0315..67d7ae3b82 100644 --- a/lib/chef/resource/dsc_resource.rb +++ b/lib/chef/resource/dsc_resource.rb @@ -19,15 +19,15 @@ class Chef class Resource
class DscResource < Chef::Resource
- provides :dsc_resource, platform: "windows"
+ provides :dsc_resource, os: "windows"
def initialize(name, run_context)
super
@properties = {}
@resource_name = :dsc_resource
@resource = nil
- @allowed_actions.push(:set)
- @action = :set
+ @allowed_actions.push(:run)
+ @action = :run
end
def resource(value=nil)
|