diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-01-25 20:54:01 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-02-06 21:58:49 +1100 |
commit | 361db45875768727d3c5f310c76850f350e6441f (patch) | |
tree | 87039f959187ecc630205c0468e076aa3c559114 /lib/puppet/parser/resource.rb | |
parent | 62cdeaaee7f7a878b6ca2db85fe34187d2c6c1ba (diff) | |
download | puppet-361db45875768727d3c5f310c76850f350e6441f.tar.gz puppet-361db45875768727d3c5f310c76850f350e6441f.tar.xz puppet-361db45875768727d3c5f310c76850f350e6441f.zip |
Change the way the tags and params are handled in rails
The rationale behind this patch is that it takes a lots of time
to let rails unserialize the ParamValue and ResourceTag object
on each compilation, just to throw them away the second after.
The idea is to fetch directly (and batched host per host) the
parameters and tags from the database and then returns them as
hash.
This allows the no-modification case to takes at least 2 times
less than before.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/resource.rb')
-rw-r--r-- | lib/puppet/parser/resource.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 92a90d871..d4c7a1f0f 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -181,11 +181,11 @@ class Puppet::Parser::Resource hash end - db_resource.ar_hash_merge(db_resource.get_params_hash(db_resource.param_values), updated_params, + db_resource.ar_hash_merge(db_resource.get_params_hash(), updated_params, :create => Proc.new { |name, parameter| parameter.to_rails(db_resource) }, :delete => Proc.new { |values| - values.each { |value| db_resource.param_values.delete(value) } + values.each { |value| Puppet::Rails::ParamValue.delete(value['id']) } }, :modify => Proc.new { |db, mem| mem.modify_rails_values(db) }) @@ -194,13 +194,13 @@ class Puppet::Parser::Resource hash[tag] = tag hash } - + db_resource.ar_hash_merge(db_resource.get_tag_hash(), updated_tags, :create => Proc.new { |name, tag| db_resource.add_resource_tag(name) }, :delete => Proc.new { |tag| - db_resource.resource_tags.delete(tag) + Puppet::Rails::ResourceTag.delete(tag['id']) }, :modify => Proc.new { |db, mem| # nothing here }) @@ -427,7 +427,7 @@ class Puppet::Parser::Resource # 'type' isn't a valid column name, so we have to use another name. to = (param == :type) ? :restype : param if value = self.send(param) - hash[to] = value + hash[to] = value end hash end |