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
Instance Attribute Summary
Attributes inherited from Chef::Provider
#action, #current_resource, #new_resource, #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_with_systems_locale
Methods included from Mixin::Command::Windows
Methods included from Mixin::Command::Unix
Methods inherited from Chef::Provider
#action_nothing, build_from_file, #cleanup_after_converge, #converge, #cookbook_name, #define_resource_requirements, #events, #node, #process_resource_requirements, #requirements, #resource_collection, #run_action, #whyrun_mode?, #whyrun_supported?
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::EnforceOwnershipAndPermissions
#access_controls, #enforce_ownership_and_permissions
Methods included from Mixin::RecipeDefinitionDSLCore
Methods included from Mixin::Language
#data_bag, #data_bag_item, #platform?, #platform_family?, #search, #value_for_platform, #value_for_platform_family
Constructor Details
#initialize(new_resource, run_context = nil) ⇒ Solaris
Returns a new instance of Solaris.
27 28 29 30 31 |
# File 'lib/chef/provider/service/solaris.rb', line 27 def initialize(new_resource, run_context=nil) super @init_command = "/usr/sbin/svcadm" @status_command = "/bin/svcs -l" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore
Instance Method Details
#disable_service ⇒ Object Also known as: stop_service
49 50 51 52 |
# File 'lib/chef/provider/service/solaris.rb', line 49 def disable_service run_command(:command => "#{@init_command} disable #{@new_resource.service_name}") return service_status.enabled end |
#enable_service ⇒ Object Also known as: start_service
44 45 46 47 |
# File 'lib/chef/provider/service/solaris.rb', line 44 def enable_service run_command(:command => "#{@init_command} enable #{@new_resource.service_name}") return service_status.enabled end |
#load_current_resource ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/chef/provider/service/solaris.rb', line 34 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
57 58 59 |
# File 'lib/chef/provider/service/solaris.rb', line 57 def reload_service run_command(:command => "#{@init_command} refresh #{@new_resource.service_name}") end |
#restart_service ⇒ Object
61 62 63 64 |
# File 'lib/chef/provider/service/solaris.rb', line 61 def restart_service disable_service return enable_service end |
#service_status ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/chef/provider/service/solaris.rb', line 66 def service_status status = popen4("#{@status_command} #{@current_resource.service_name}") do |pid, stdin, stdout, stderr| stdout.each do |line| case line when /state\s+online/ @current_resource.enabled(true) @current_resource.running(true) end end end unless @current_resource.enabled @current_resource.enabled(false) @current_resource.running(false) end @current_resource end |