summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-10 23:57:59 -0600
committerLuke Kanies <luke@madstop.com>2007-12-10 23:57:59 -0600
commita8bf74b9170b3cb27216f9755a39f635f748fc0a (patch)
tree577474a89080ad64ea514db1cdd6b31622ec857e
parentb70f00abce1ca864f51f7baa4071526a3ebe3efe (diff)
downloadpuppet-a8bf74b9170b3cb27216f9755a39f635f748fc0a.tar.gz
puppet-a8bf74b9170b3cb27216f9755a39f635f748fc0a.tar.xz
puppet-a8bf74b9170b3cb27216f9755a39f635f748fc0a.zip
Fixing #946.
-rw-r--r--lib/puppet/metatype/instances.rb6
-rwxr-xr-xlib/puppet/provider/service/base.rb4
-rwxr-xr-xlib/puppet/provider/service/debian.rb4
-rwxr-xr-xlib/puppet/provider/service/init.rb43
-rw-r--r--lib/puppet/type/service.rb1
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
-