Class: Chef::Provider::Service::Solaris
- Inherits:
-
Chef::Provider::Service
- Object
- Chef::Provider
- Chef::Provider::Service
- Chef::Provider::Service::Solaris
- Includes:
- Mixin::ShellOut
- Defined in:
- lib/chef/provider/service/solaris.rb
Constant Summary
Constants included from Mixin::ShellOut
Mixin::ShellOut::DEPRECATED_OPTIONS
Instance Attribute Summary collapse
-
#maintenance ⇒ Object
readonly
Returns the value of attribute maintenance.
Attributes inherited from Chef::Provider
#action, #cookbook_name, #current_resource, #new_resource, #recipe_name, #run_context
Instance Method Summary collapse
- #disable_service ⇒ Object (also: #stop_service)
- #enable_service ⇒ Object (also: #start_service)
-
#initialize(new_resource, run_context = nil) ⇒ Solaris
constructor
A new instance of Solaris.
- #load_current_resource ⇒ Object
- #reload_service ⇒ Object
- #restart_service ⇒ Object
- #service_status ⇒ Object
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!
Methods inherited from Chef::Provider::Service
#action_disable, #action_enable, #action_reload, #action_restart, #action_start, #action_stop, #define_resource_requirements, #load_new_resource_state, #shared_resource_requirements, #whyrun_supported?
Methods included from Mixin::Command
#chdir_or_tmpdir, #handle_command_failures, #output_of_command, #run_command, #run_command_and_return_stdout_stderr, #run_command_with_systems_locale
Methods included from Mixin::Command::Windows
Methods included from Mixin::Command::Unix
Methods inherited from Chef::Provider
#action_nothing, #cleanup_after_converge, #converge_by, #define_resource_requirements, #events, #node, #process_resource_requirements, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, #whyrun_mode?, #whyrun_supported?
Methods included from DSL::Recipe
#build_resource, #declare_resource, #describe_self_for_error, #evaluate_resource_definition, #has_resource_definition?, #have_resource_class_for?, #method_missing, #resource_class_for
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Constructor Details
#initialize(new_resource, run_context = nil) ⇒ Solaris
Returns a new instance of Solaris.
30 31 32 33 34 35 |
# File 'lib/chef/provider/service/solaris.rb', line 30 def initialize(new_resource, run_context=nil) super @init_command = "/usr/sbin/svcadm" @status_command = "/bin/svcs -l" @maintenace = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::DSL::Recipe
Instance Attribute Details
#maintenance ⇒ Object (readonly)
Returns the value of attribute maintenance.
28 29 30 |
# File 'lib/chef/provider/service/solaris.rb', line 28 def maintenance @maintenance end |
Instance Method Details
#disable_service ⇒ Object Also known as: stop_service
53 54 55 |
# File 'lib/chef/provider/service/solaris.rb', line 53 def disable_service shell_out!("#{default_init_command} disable -s #{@new_resource.service_name}") end |
#enable_service ⇒ Object Also known as: start_service
48 49 50 51 |
# File 'lib/chef/provider/service/solaris.rb', line 48 def enable_service shell_out!("#{default_init_command} clear #{@new_resource.service_name}") if @maintenance shell_out!("#{default_init_command} enable -s #{@new_resource.service_name}") end |
#load_current_resource ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/chef/provider/service/solaris.rb', line 38 def load_current_resource @current_resource = Chef::Resource::Service.new(@new_resource.name) @current_resource.service_name(@new_resource.service_name) unless ::File.exists? "/bin/svcs" raise Chef::Exceptions::Service, "/bin/svcs does not exist!" end @status = service_status.enabled @current_resource end |
#reload_service ⇒ Object
60 61 62 |
# File 'lib/chef/provider/service/solaris.rb', line 60 def reload_service shell_out!("#{default_init_command} refresh #{@new_resource.service_name}") end |
#restart_service ⇒ Object
64 65 66 67 68 |
# File 'lib/chef/provider/service/solaris.rb', line 64 def restart_service ## svcadm restart doesn't supports sync(-s) option disable_service return enable_service end |
#service_status ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/chef/provider/service/solaris.rb', line 70 def service_status status = shell_out!("#{@status_command} #{@current_resource.service_name}") status.stdout.each_line do |line| case line when /state\s+online/ @current_resource.enabled(true) @current_resource.running(true) when /state\s+maintenance/ @maintenance = true end end unless @current_resource.enabled @current_resource.enabled(false) @current_resource.running(false) end @current_resource end |