When one wants to use the parsedfile provider for a type with more than
one key_attribute (e.g. a type for entries in /etc/services with name
and protocol as key_attributes) the provider will not store all
key_attributes in property_hash and not all keyattributes will be
visible in the to_line function.

The create method of parsedfile will only put validproperties into the
propertyhash. As result :name and all the other key_attributes will not
be set.

In the flush method however the :name parameter is put in the
property_hash but the method does not handle other keyattributes.

This patch modifies flush to put all key_attributes into the property
hash
(Note: @resource.name is basically just an alias for @resource[:name])

Signed-off-by: Stefan Schulte <[email protected]>
---
 lib/puppet/provider/parsedfile.rb |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/provider/parsedfile.rb 
b/lib/puppet/provider/parsedfile.rb
index ffd36e5..75a215f 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -334,7 +334,9 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
       @property_hash[:target] = @resource.should(:target) || 
self.class.default_target
       self.class.modified(@property_hash[:target])
     end
-    @property_hash[:name] ||= @resource.name
+    @resource.class.key_attributes.each do |attr|
+      @property_hash[attr] ||= @resource[attr]
+    end
 
     self.class.flush(@property_hash)
 
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to