diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 02:19:14 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 02:19:14 +0000 |
commit | 29b00fb744d2e27f835d0130b88ed4bda08c63f7 (patch) | |
tree | e00440d0e749c303331450e58eef7c34d9d7a31a /lib | |
parent | 411ab22588da2cbe76d186fbd4b59f6194766c4d (diff) | |
download | puppet-29b00fb744d2e27f835d0130b88ed4bda08c63f7.tar.gz puppet-29b00fb744d2e27f835d0130b88ed4bda08c63f7.tar.xz puppet-29b00fb744d2e27f835d0130b88ed4bda08c63f7.zip |
Adding "alias" metaparam; you can now create as many aliases as you want for any of your objects.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@806 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/type.rb | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index fa87de641..c061380bd 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -198,16 +198,16 @@ class Type < Puppet::Element raise Puppet::DevError, "must pass a Puppet::Type object" end - if @objects.has_key?(newobj.name) and self.isomorphic? + if @objects.has_key?(name) and self.isomorphic? raise Puppet::Error.new( "Object '%s' of type '%s' already exists with id '%s' vs. '%s'" % - [newobj.name,newobj.class.name, - @objects[newobj.name].object_id,newobj.object_id] + [name,newobj.class.name, + @objects[name].object_id,newobj.object_id] ) else - #debug("adding %s of type %s to class list" % - # [object.name,object.class]) - @objects[newobj.name] = newobj + #Puppet.info("adding %s of type %s to class list" % + # [name,object.class]) + @objects[name] = newobj end # and then add it to the master list @@ -1585,6 +1585,23 @@ class Type < Puppet::Element loglevel end end + + newmetaparam(:alias) do + desc "Creates an alias for the object. This simplifies lookup of the + object so is useful in the language. It is especially useful when + you are creating long commands using exec or when many different systems + call a given package different names." + + munge do |*aliases| + unless aliases.is_a?(Array) + aliases = [aliases] + end + @parent.info "Adding aliases %s" % aliases.join(", ") + aliases.each do |other| + @parent.class[other] = @parent + end + end + end end # Puppet::Type end |