summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-07-26 11:38:05 -0700
committerNick Lewis <nick@puppetlabs.com>2011-07-26 15:45:36 -0700
commit38c181d00e87ecc699c6a3e23dd2155f716a6602 (patch)
treeb821fafe66f5d004239b0c7be2c5e95488579111
parent0506874ebeac8f2fb7d6c754ed6b606eab56d216 (diff)
downloadpuppet-38c181d00e87ecc699c6a3e23dd2155f716a6602.tar.gz
puppet-38c181d00e87ecc699c6a3e23dd2155f716a6602.tar.xz
puppet-38c181d00e87ecc699c6a3e23dd2155f716a6602.zip
(#8272) Fixup logging in Windows service provider
We want to use self.debug for logging in the provider, so that log messages are properly associated with the resource, rather than generically coming from Puppet. Also fix the self.instances method to not use an unnecessary extra variable when collecting. Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
-rw-r--r--lib/puppet/provider/service/windows.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/puppet/provider/service/windows.rb b/lib/puppet/provider/service/windows.rb
index 09754ffda..56d56b0a9 100644
--- a/lib/puppet/provider/service/windows.rb
+++ b/lib/puppet/provider/service/windows.rb
@@ -41,7 +41,7 @@ Puppet::Type.type(:service).provide :windows do
def enabled?
w32ss = Win32::Service.config_info( @resource[:name] )
raise Puppet::Error.new("Win32 service query of #{@resource[:name]} failed" ) unless( !w32ss.nil? && w32ss.instance_of?( Struct::ServiceConfigInfo ) )
- Puppet.debug("Service #{@resource[:name]} start type is #{w32ss.start_type}")
+ debug("Service #{@resource[:name]} start type is #{w32ss.start_type}")
case w32ss.start_type
when Win32::Service.get_start_type(Win32::Service::SERVICE_AUTO_START),
Win32::Service.get_start_type(Win32::Service::SERVICE_BOOT_START),
@@ -84,7 +84,7 @@ Puppet::Type.type(:service).provide :windows do
else
raise Puppet::Error.new("Unknown service state '#{w32ss.current_state}' for service '#{@resource[:name]}'")
end
- Puppet.debug("Service #{@resource[:name]} is #{w32ss.current_state}")
+ debug("Service #{@resource[:name]} is #{w32ss.current_state}")
return state
rescue Win32::Service::Error => detail
raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" )
@@ -92,10 +92,6 @@ Puppet::Type.type(:service).provide :windows do
# returns all providers for all existing services and startup state
def self.instances
- srvcs = []
- Win32::Service.services.collect{ |s|
- srvcs << new(:name => s.service_name)
- }
- srvcs
+ Win32::Service.services.collect { |s| new(:name => s.service_name) }
end
end