summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMartin Englund <martin.englund@sun.com>2009-06-24 21:27:34 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-06-26 11:24:11 +1000
commit0f2d70dc91a10d38d088ad5d8a351187b143e144 (patch)
treee34cf565621a255e628137c80279399dc9823280 /lib
parent3f070c118b1ae2f3c76172d320ff04e92618a9b3 (diff)
downloadpuppet-0f2d70dc91a10d38d088ad5d8a351187b143e144.tar.gz
puppet-0f2d70dc91a10d38d088ad5d8a351187b143e144.tar.xz
puppet-0f2d70dc91a10d38d088ad5d8a351187b143e144.zip
Fixed #2087 and refactored the code that gets the smf service state
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/provider/service/smf.rb50
1 files changed, 19 insertions, 31 deletions
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index 7cdebe53d..60cf305cb 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -65,41 +65,29 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
end
begin
- output = svcs "-l", @resource[:name]
+ state = svcs "-H -o state", @resource[:name]
rescue Puppet::ExecutionFailure
- warning "Could not get status on service %s" % self.name
+ info "Could not get status on service %s" % self.name
return :stopped
end
- output.split("\n").each { |line|
- var = nil
- value = nil
- if line =~ /^(\w+)\s+(.+)/
- var = $1
- value = $2
- else
- Puppet.err "Could not match %s" % line.inspect
- next
- end
- case var
- when "state"
- case value
- when "online"
- #self.warning "matched running %s" % line.inspect
- return :running
- when "offline", "disabled", "uninitialized"
- #self.warning "matched stopped %s" % line.inspect
- return :stopped
- when "legacy_run"
- raise Puppet::Error,
- "Cannot manage legacy services through SMF"
- else
- raise Puppet::Error,
- "Unmanageable state '%s' on service %s" %
- [value, self.name]
- end
- end
- }
+
+ case state
+ when "online"
+ #self.warning "matched running %s" % line.inspect
+ return :running
+ when "offline", "disabled", "uninitialized"
+ #self.warning "matched stopped %s" % line.inspect
+ return :stopped
+ when "legacy_run"
+ raise Puppet::Error,
+ "Cannot manage legacy services through SMF"
+ else
+ raise Puppet::Error,
+ "Unmanageable state '%s' on service %s" %
+ [state, self.name]
+ end
+
end
def stopcmd