diff options
Diffstat (limited to 'lib/chef/provider/service.rb')
-rw-r--r-- | lib/chef/provider/service.rb | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb index e048b2e43b..2f08697ed7 100644 --- a/lib/chef/provider/service.rb +++ b/lib/chef/provider/service.rb @@ -51,21 +51,21 @@ class Chef # XXX?: the #nil? check below will likely fail if this is a cloned resource or if # we just run multiple actions. def load_new_resource_state - if @new_resource.enabled.nil? - @new_resource.enabled(@current_resource.enabled) + if new_resource.enabled.nil? + new_resource.enabled(current_resource.enabled) end - if @new_resource.running.nil? - @new_resource.running(@current_resource.running) + if new_resource.running.nil? + new_resource.running(current_resource.running) end - if @new_resource.masked.nil? - @new_resource.masked(@current_resource.masked) + if new_resource.masked.nil? + new_resource.masked(current_resource.masked) end end # subclasses should override this if they do implement user services def user_services_requirements requirements.assert(:all_actions) do |a| - a.assertion { @new_resource.user.nil? } + a.assertion { new_resource.user.nil? } a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support user services" end end @@ -76,7 +76,7 @@ class Chef def define_resource_requirements requirements.assert(:reload) do |a| - a.assertion { supports[:reload] || @new_resource.reload_command } + a.assertion { supports[:reload] || new_resource.reload_command } a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support :reload" # if a service is not declared to support reload, that won't # typically change during the course of a run - so no whyrun @@ -85,97 +85,97 @@ class Chef end def action_enable - if @current_resource.enabled - Chef::Log.debug("#{@new_resource} already enabled - nothing to do") + if current_resource.enabled + Chef::Log.debug("#{new_resource} already enabled - nothing to do") else - converge_by("enable service #{@new_resource}") do + converge_by("enable service #{new_resource}") do enable_service - Chef::Log.info("#{@new_resource} enabled") + Chef::Log.info("#{new_resource} enabled") end end load_new_resource_state - @new_resource.enabled(true) + new_resource.enabled(true) end def action_disable - if @current_resource.enabled - converge_by("disable service #{@new_resource}") do + if current_resource.enabled + converge_by("disable service #{new_resource}") do disable_service - Chef::Log.info("#{@new_resource} disabled") + Chef::Log.info("#{new_resource} disabled") end else - Chef::Log.debug("#{@new_resource} already disabled - nothing to do") + Chef::Log.debug("#{new_resource} already disabled - nothing to do") end load_new_resource_state - @new_resource.enabled(false) + new_resource.enabled(false) end def action_mask - if @current_resource.masked - Chef::Log.debug("#{@new_resource} already masked - nothing to do") + if current_resource.masked + Chef::Log.debug("#{new_resource} already masked - nothing to do") else - converge_by("mask service #{@new_resource}") do + converge_by("mask service #{new_resource}") do mask_service - Chef::Log.info("#{@new_resource} masked") + Chef::Log.info("#{new_resource} masked") end end load_new_resource_state - @new_resource.masked(true) + new_resource.masked(true) end def action_unmask - if @current_resource.masked - converge_by("unmask service #{@new_resource}") do + if current_resource.masked + converge_by("unmask service #{new_resource}") do unmask_service - Chef::Log.info("#{@new_resource} unmasked") + Chef::Log.info("#{new_resource} unmasked") end else - Chef::Log.debug("#{@new_resource} already unmasked - nothing to do") + Chef::Log.debug("#{new_resource} already unmasked - nothing to do") end load_new_resource_state - @new_resource.masked(false) + new_resource.masked(false) end def action_start - unless @current_resource.running - converge_by("start service #{@new_resource}") do + unless current_resource.running + converge_by("start service #{new_resource}") do start_service - Chef::Log.info("#{@new_resource} started") + Chef::Log.info("#{new_resource} started") end else - Chef::Log.debug("#{@new_resource} already running - nothing to do") + Chef::Log.debug("#{new_resource} already running - nothing to do") end load_new_resource_state - @new_resource.running(true) + new_resource.running(true) end def action_stop - if @current_resource.running - converge_by("stop service #{@new_resource}") do + if current_resource.running + converge_by("stop service #{new_resource}") do stop_service - Chef::Log.info("#{@new_resource} stopped") + Chef::Log.info("#{new_resource} stopped") end else - Chef::Log.debug("#{@new_resource} already stopped - nothing to do") + Chef::Log.debug("#{new_resource} already stopped - nothing to do") end load_new_resource_state - @new_resource.running(false) + new_resource.running(false) end def action_restart - converge_by("restart service #{@new_resource}") do + converge_by("restart service #{new_resource}") do restart_service - Chef::Log.info("#{@new_resource} restarted") + Chef::Log.info("#{new_resource} restarted") end load_new_resource_state - @new_resource.running(true) + new_resource.running(true) end def action_reload - if @current_resource.running - converge_by("reload service #{@new_resource}") do + if current_resource.running + converge_by("reload service #{new_resource}") do reload_service - Chef::Log.info("#{@new_resource} reloaded") + Chef::Log.info("#{new_resource} reloaded") end end load_new_resource_state @@ -216,8 +216,8 @@ class Chef protected def default_init_command - if @new_resource.init_command - @new_resource.init_command + if new_resource.init_command + new_resource.init_command elsif instance_variable_defined?(:@init_command) @init_command end @@ -225,8 +225,8 @@ class Chef def custom_command_for_action?(action) method_name = "#{action}_command".to_sym - @new_resource.respond_to?(method_name) && - !!@new_resource.send(method_name) + new_resource.respond_to?(method_name) && + !!new_resource.send(method_name) end module ServicePriorityInit |