summaryrefslogtreecommitdiff
path: root/lib/chef/provider/service.rb
diff options
context:
space:
mode:
authorDavide Cavalca <dcavalca@fb.com>2016-02-22 14:14:39 -0800
committerDavide Cavalca <dcavalca@fb.com>2016-02-22 14:27:36 -0800
commit55a4e8fd6d045fa4a62940983cc39c36e8d929f4 (patch)
tree3d763764055e2e244f7776f9e05b520b340f9e55 /lib/chef/provider/service.rb
parent29f3b3912113e818a201d91e44dccdd63d09da2a (diff)
downloadchef-55a4e8fd6d045fa4a62940983cc39c36e8d929f4.tar.gz
rework to use service resource directly instead of subclassing
Diffstat (limited to 'lib/chef/provider/service.rb')
-rw-r--r--lib/chef/provider/service.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index d716e44342..b848d33083 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -1,5 +1,6 @@
#
# Author:: AJ Christensen (<aj@hjksolutions.com>)
+# Author:: Davide Cavalca (<dcavalca@fb.com>)
# Copyright:: Copyright 2008-2016, Chef Software, Inc.
# License:: Apache License, Version 2.0
#
@@ -56,6 +57,9 @@ class Chef
if @new_resource.running.nil?
@new_resource.running(@current_resource.running)
end
+ if @new_resource.masked.nil?
+ @new_resource.masked(@current_resource.masked)
+ end
end
def shared_resource_requirements
@@ -97,6 +101,32 @@ class Chef
@new_resource.enabled(false)
end
+ def action_mask
+ if @current_resource.masked
+ Chef::Log.debug("#{@new_resource} already masked - nothing to do")
+ else
+ converge_by("mask service #{@new_resource}") do
+ mask_service
+ Chef::Log.info("#{@new_resource} masked")
+ end
+ end
+ load_new_resource_state
+ @new_resource.masked(true)
+ end
+
+ def action_unmask
+ if @current_resource.masked
+ converge_by("unmask service #{@new_resource}") do
+ unmask_service
+ Chef::Log.info("#{@new_resource} unmasked")
+ end
+ else
+ Chef::Log.debug("#{@new_resource} already unmasked - nothing to do")
+ end
+ load_new_resource_state
+ @new_resource.masked(false)
+ end
+
def action_start
unless @current_resource.running
converge_by("start service #{@new_resource}") do
@@ -150,6 +180,14 @@ class Chef
raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :disable"
end
+ def mask_service
+ raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :mask"
+ end
+
+ def unmask_service
+ raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :unmask"
+ end
+
def start_service
raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :start"
end