diff options
author | tylercloke <tyler@opscode.com> | 2012-08-21 17:00:41 -0700 |
---|---|---|
committer | tylercloke <tyler@opscode.com> | 2012-09-20 12:51:39 -0700 |
commit | f99c0e9a7dd12fca887d40bf86750edd1290547c (patch) | |
tree | 743f7cb31f7333195ca3c3d12c10c19c17b73b3c | |
parent | f04193d6150afed346977c3ebaa942acf1a974a7 (diff) | |
download | chef-f99c0e9a7dd12fca887d40bf86750edd1290547c.tar.gz |
Added state reporting to service provider.
-rw-r--r-- | chef/lib/chef/provider/file.rb | 1 | ||||
-rw-r--r-- | chef/lib/chef/provider/service.rb | 22 | ||||
-rw-r--r-- | chef/lib/chef/resource_reporter.rb | 1 |
3 files changed, 23 insertions, 1 deletions
diff --git a/chef/lib/chef/provider/file.rb b/chef/lib/chef/provider/file.rb index d397449825..0be39339b5 100644 --- a/chef/lib/chef/provider/file.rb +++ b/chef/lib/chef/provider/file.rb @@ -141,7 +141,6 @@ class Chef def load_current_resource_attrs if ::File.exist?(@new_resource.path) - Chef::Log.info("passed exists") stat = ::File.stat(@new_resource.path) @current_resource.owner(stat.uid) @current_resource.mode(stat.mode & 07777) diff --git a/chef/lib/chef/provider/service.rb b/chef/lib/chef/provider/service.rb index 22098a0d6b..decca7fd7c 100644 --- a/chef/lib/chef/provider/service.rb +++ b/chef/lib/chef/provider/service.rb @@ -34,6 +34,17 @@ class Chef true end + def load_new_resource_state + # If the user didn't specify a change in enabled state, + # it will be the same as the old resource + if ( @new_resource.enabled.nil? ) + @new_resource.enabled(@current_resource.enabled) + end + if ( @new_resource.running.nil? ) + @new_resource.running(@current_resource.running) + end + end + def shared_resource_requirements end @@ -56,6 +67,8 @@ class Chef Chef::Log.info("#{@new_resource} enabled") end end + load_new_resource_state + @new_resource.enabled(true) end def action_disable @@ -67,6 +80,8 @@ class Chef else Chef::Log.debug("#{@new_resource} already disabled - nothing to do") end + load_new_resource_state + @new_resource.enabled(false) end def action_start @@ -78,6 +93,8 @@ class Chef else Chef::Log.debug("#{@new_resource} already running - nothing to do") end + load_new_resource_state + @new_resource.running(true) end def action_stop @@ -89,6 +106,8 @@ class Chef else Chef::Log.debug("#{@new_resource} already stopped - nothing to do") end + load_new_resource_state + @new_resource.running(false) end def action_restart @@ -96,6 +115,8 @@ class Chef restart_service Chef::Log.info("#{@new_resource} restarted") end + load_new_resource_state + @new_resource.running(true) end def action_reload @@ -105,6 +126,7 @@ class Chef Chef::Log.info("#{@new_resource} reloaded") end end + load_new_resource_state end def enable_service diff --git a/chef/lib/chef/resource_reporter.rb b/chef/lib/chef/resource_reporter.rb index bdf12fde46..f3f0196cde 100644 --- a/chef/lib/chef/resource_reporter.rb +++ b/chef/lib/chef/resource_reporter.rb @@ -58,6 +58,7 @@ class Chef as_hash["duration"] = (elapsed_time * 1000).to_i.to_s as_hash["delta"] = new_resource.diff if new_resource.respond_to?("diff") as_hash["delta"] = "" if as_hash["delta"].nil? + # TODO: rename as "action" as_hash["result"] = action.to_s if success? |