On Tue, Nov 23, 2010 at 12:36:07AM -0600, Luke Kanies wrote: > However, the multiple primary key solution is definitely actually the right > one, so if you can figure out how to make it work (directly CC'ing Markus in > hopes he'll chime in) that's definitely the "best" option (where "best" takes > no account of effort, just result).
I'm trying to implement it. Basically you can just use "isnamevar" for
multiple parameters. My tests showed that
Puppet::Type.type(:port).key_attributes is now [:name, :protocol]. OK
the next thing you have to do is to write a title_patterns function. So
you can write
port {'telnet:tcp':
description => 'Telnet'
number => '23'
ensure => present
}
This will set :name as well as :protocol.
At least I think this should work. My work so far:
http://pastie.org/1348263
But whenever I create an instance of my class
@class.new(:name => "whev", :protocol => :tcp, :ensure => :present)
I get:
FAILED
expected no Exception, got #<Puppet::Error: Resource type port does not
support parameter false>
I traced the cause of the problem to type.rb function namevar
def []=(name,value)
[...]
if name == :name
name = name_var ### <-- name is false now (see below)
end
[...]
property = self.newattr(name) # <-- raises exception cause "false"
# is no valid parameter
[...]
end
def name_var
key_attributes = self.class.key_attributes # [:name, :protocol]
# The following expression is always false cause length == 2
(key_attributes.length == 1) && key_attributes.first
end
I dont know where name_var is used so I can only guess that name_var has
a bug, but I'm not able to decide that.
-Stefan
pgpWhzAz3xG6k.pgp
Description: PGP signature
