bugfix: catch cases, where no service is available

This commit is contained in:
Christoph Hartmann 2015-09-18 10:51:18 +02:00 committed by Dominik Richter
parent 04ca75b6e7
commit 5019664d4d

View file

@ -311,8 +311,11 @@ class WindowsSrv < ServiceManager
return nil
end
service['Service']['Status'] == 4 ? (running = true) : (running = false)
service['WMI']['StartMode'] == 'Auto' ? (enabled = true) : (enabled = false)
# check that we got a response
return nil if service.nil? || service['Service'].nil?
(!service['Service'].nil? && !service['Service']['Status'].nil? && service['Service']['Status'] == 4) ? (running = true) : (running = false)
(!service['WMI'].nil? && !service['WMI']['StartMode'].nil? && service['WMI']['StartMode'] == 'Auto') ? (enabled = true) : (enabled = false)
{
name: service['Service']['Name'],