diff options
author | Luke Kanies <luke@madstop.com> | 2007-12-10 23:57:59 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-12-10 23:57:59 -0600 |
commit | a8bf74b9170b3cb27216f9755a39f635f748fc0a (patch) | |
tree | 577474a89080ad64ea514db1cdd6b31622ec857e /lib | |
parent | b70f00abce1ca864f51f7baa4071526a3ebe3efe (diff) | |
download | puppet-a8bf74b9170b3cb27216f9755a39f635f748fc0a.tar.gz puppet-a8bf74b9170b3cb27216f9755a39f635f748fc0a.tar.xz puppet-a8bf74b9170b3cb27216f9755a39f635f748fc0a.zip |
Fixing #946.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/metatype/instances.rb | 6 | ||||
-rwxr-xr-x | lib/puppet/provider/service/base.rb | 4 | ||||
-rwxr-xr-x | lib/puppet/provider/service/debian.rb | 4 | ||||
-rwxr-xr-x | lib/puppet/provider/service/init.rb | 43 | ||||
-rw-r--r-- | lib/puppet/type/service.rb | 1 |
5 files changed, 24 insertions, 34 deletions
diff --git a/lib/puppet/metatype/instances.rb b/lib/puppet/metatype/instances.rb index 16dd28433..f6773f0b3 100644 --- a/lib/puppet/metatype/instances.rb +++ b/lib/puppet/metatype/instances.rb @@ -259,10 +259,8 @@ class Puppet::Type providers_by_source.collect do |provider| provider.instances.collect do |instance| # First try to get the resource if it already exists - if resource = self[instance.name] and resource.provider.class != instance.class - # Skip instances that map to a managed resource with a different provider - next - end + # Skip instances that map to a managed resource with a different provider + next if resource = self[instance.name] and resource.provider.class != instance.class # We always want to use the "first" provider instance we find, unless the resource # is already managed and has a different provider set diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index 43e78e6e8..254b4fe4c 100755 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -8,6 +8,10 @@ Puppet::Type.type(:service).provide :base do commands :kill => "kill" + def self.instances + [] + end + # Get the process ID for a running process. Requires the 'pattern' # parameter. def getpid diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb index 0ba7e1a79..233242a1c 100755 --- a/lib/puppet/provider/service/debian.rb +++ b/lib/puppet/provider/service/debian.rb @@ -7,6 +7,10 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do commands :update => "/usr/sbin/update-rc.d" defaultfor :operatingsystem => :debian + def self.defpath + superclass.defpath + end + # Remove the symlinks def disable update "-f", @resource[:name], "remove" diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index ee4dbe95a..bc9fae7fb 100755 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -21,39 +21,24 @@ Puppet::Type.type(:service).provide :init, :parent => :base do #confine :exists => @defpath # List all services of this type. - def self.instances(name) - # We need to find all paths specified for our type or any parent types - paths = Puppet.type(:service).paths(name) - - # Now see if there are any included modules - included_modules.each do |mod| - next unless mod.respond_to? :name - - mname = mod.name - - if mpaths = Puppet.type(:service).paths(mname) and ! mpaths.empty? - paths += mpaths - end + def self.instances + path = self.defpath + unless FileTest.directory?(path) + Puppet.notice "Service path %s does not exist" % path + next end - paths.collect do |path| - unless FileTest.directory?(path) - Puppet.notice "Service path %s does not exist" % path - next - end - - check = [:ensure] + check = [:ensure] - if public_method_defined? :enabled? - check << :enable - end + if public_method_defined? :enabled? + check << :enable + end - Dir.entries(path).reject { |e| - fullpath = File.join(path, e) - e =~ /^\./ or ! FileTest.executable?(fullpath) - }.collect do |name| - new(:name => name, :path => path) - end + Dir.entries(path).reject { |e| + fullpath = File.join(path, e) + e =~ /^\./ or ! FileTest.executable?(fullpath) + }.collect do |name| + new(:name => name, :path => path) end end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index 473c91776..c41a7883b 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -181,4 +181,3 @@ module Puppet end end end - |