Class: Chef::Provider::Service::Solaris
- Inherits:
-
Chef::Provider::Service
- Object
- Chef::Provider
- Chef::Provider::Service
- Chef::Provider::Service::Solaris
- 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 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, node_map, #process_resource_requirements, provides, provides?, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, supports?, #whyrun_mode?, #whyrun_supported?
Methods included from Mixin::DescendantsTracker
#descendants, descendants, direct_descendants, #direct_descendants, find_descendants_by_name, #find_descendants_by_name, #inherited, store_inherited
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!, #shell_out_with_systems_locale, #shell_out_with_systems_locale!
Constructor Details
#initialize(new_resource, run_context = nil) ⇒ Solaris
Returns a new instance of Solaris.
31 32 33 34 35 36 |
# File 'lib/chef/provider/service/solaris.rb', line 31 def initialize(new_resource, run_context=nil) super @init_command = "/usr/sbin/svcadm" @status_command = "/bin/svcs -l" @maintenace = false end |
Instance Attribute Details
#maintenance ⇒ Object (readonly)
Returns the value of attribute maintenance.
27 28 29 |
# File 'lib/chef/provider/service/solaris.rb', line 27 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_with_systems_locale!("#{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}", :returns => [0, 1]) 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 |