diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-12 17:52:34 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-12 17:52:34 +0000 |
commit | f217fbf3319b06359ad64b8926970eeddb776169 (patch) | |
tree | 65cdf4153a73fdde59715acd02ef5a03512f48f2 /lib/puppet | |
parent | edb1be2d7599c12a3116a17d17d5d87e7e45b4da (diff) | |
download | puppet-f217fbf3319b06359ad64b8926970eeddb776169.tar.gz puppet-f217fbf3319b06359ad64b8926970eeddb776169.tar.xz puppet-f217fbf3319b06359ad64b8926970eeddb776169.zip |
Fixing the instances method. It now works when there are already managed resources.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2685 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/metatype/instances.rb | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/puppet/metatype/instances.rb b/lib/puppet/metatype/instances.rb index d1c6d7732..7c951058c 100644 --- a/lib/puppet/metatype/instances.rb +++ b/lib/puppet/metatype/instances.rb @@ -257,17 +257,30 @@ class Puppet::Type end # Put the default provider first, then the rest of the suitable providers. - packages = {} + provider_instances = {} providers_by_source.collect do |provider| provider.instances.collect do |instance| - if other = packages[instance.name] - Puppet.warning "Package %s found in both %s and %s; skipping the %s version" % - [instance.name, other.class.name, instance.class.name, instance.class.name] + # 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 - packages[instance.name] = instance - create(:name => instance.name, :provider => instance, :check => :all) + # We always want to use the "first" provider instance we find, unless the resource + # is already managed and has a different provider set + if other = provider_instances[instance.name] + Puppet.warning "%s %s found in both %s and %s; skipping the %s version" % + [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name] + next + end + provider_instances[instance.name] = instance + + if resource + resource.provider = instance + resource + else + create(:name => instance.name, :provider => instance, :check => :all) + end end end.flatten.compact end |