summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-12 07:08:19 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-12 07:08:19 +0000
commit1cf05ff2872231bd9bdb9ae51bcc062671502484 (patch)
treef7284478defac97fffb09e656948222a036a4ed8 /lib
parent4c4f530bb5f81ab793e93b5034bddd89f3ec677e (diff)
downloadpuppet-1cf05ff2872231bd9bdb9ae51bcc062671502484.tar.gz
puppet-1cf05ff2872231bd9bdb9ae51bcc062671502484.tar.xz
puppet-1cf05ff2872231bd9bdb9ae51bcc062671502484.zip
Services now work at least somewhat on solaris 10, and service testing is pretty different.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@809 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/type/service.rb4
-rwxr-xr-xlib/puppet/type/service/smf.rb52
2 files changed, 43 insertions, 13 deletions
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index 76bc8adb1..21f258f0b 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -70,7 +70,7 @@ module Puppet
should = :running
else
self.warning "%s: interpreting '%s' as false" %
- [self.class,should]
+ [self.class,should.inspect]
should = 0
end
self.debug "Service should is %s" % should
@@ -87,8 +87,10 @@ module Puppet
case self.should
when :running
@parent.start
+ self.info "started"
return :service_started
when :stopped
+ self.info "stopped"
@parent.stop
return :service_stopped
else
diff --git a/lib/puppet/type/service/smf.rb b/lib/puppet/type/service/smf.rb
index f16eb422a..b98e47eb4 100755
--- a/lib/puppet/type/service/smf.rb
+++ b/lib/puppet/type/service/smf.rb
@@ -2,27 +2,55 @@
# somewhat obvious.
Puppet.type(:service).newsvctype(:smf) do
def restartcmd
+ "svcadm restart %s" % self.name
end
- # The start command is just the init scriptwith 'start'.
def startcmd
- self.initscript + " start"
+ "svcadm enable %s" % self.name
end
- # If it was specified that the init script has a 'status' command, then
- # we just return that; otherwise, we return false, which causes it to
- # fallback to other mechanisms.
- def statuscmd
- if self[:hasstatus]
- return self.initscript + " status"
- else
- return false
+ def status
+ if self[:status]
+ super
+ return
+ end
+ %x{/usr/bin/svcs -l #{self.name} 2>/dev/null}.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
+ end
+ case var
+ when "state":
+ case value
+ when "online":
+ #self.warning "matched running %s" % line.inspect
+ return :running
+ when "offline", "disabled":
+ #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
+ }
+
+ if $? != 0
+ raise Puppet::Error,
+ "Could not get status on service %s" % self.name
end
end
- # The stop command is just the init script with 'stop'.
def stopcmd
- self.initscript + " stop"
+ "svcadm disable %s" % self.name
end
end