summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-13 21:34:22 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-13 21:34:22 +0000
commit22e70f069cec86f94e17774c9c2b84b1bb9cda6c (patch)
tree23848807bd8e719ca6e0029d06eb6c542162d64d
parent637cc71296f96fd1d5f2ca83aa7e20c73757f8dd (diff)
downloadpuppet-22e70f069cec86f94e17774c9c2b84b1bb9cda6c.tar.gz
puppet-22e70f069cec86f94e17774c9c2b84b1bb9cda6c.tar.xz
puppet-22e70f069cec86f94e17774c9c2b84b1bb9cda6c.zip
Made a *huge* performance difference in storing hosts -- down from about 25 seconds per host to about 5 seconds on my machine. I will almost definitely still use forking or something to make this not affect the clients
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1191 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet.rb22
-rw-r--r--lib/puppet/parser/interpreter.rb12
-rw-r--r--lib/puppet/rails/host.rb15
-rw-r--r--lib/puppet/rails/rails_object.rb6
-rw-r--r--lib/puppet/type/pfile.rb4
5 files changed, 39 insertions, 20 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index a2e3d4334..d752655d8 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -100,10 +100,28 @@ module Puppet
conf = "/etc/puppet"
var = "/var/puppet"
end
+
self.setdefaults(:puppet,
:confdir => [conf, "The main Puppet configuration directory."],
- :vardir => [var, "Where Puppet stores dynamic and growing data."],
- :logdir => ["$vardir/log", "The Puppet log directory."],
+ :vardir => [var, "Where Puppet stores dynamic and growing data."]
+ )
+
+ if self.name == "puppetmasterd"
+ self.setdefaults(:puppetmasterd,
+ :logdir => {:default => "$vardir/log",
+ :mode => 0750,
+ :owner => "$user",
+ :group => "$group",
+ :desc => "The Puppet log directory."
+ }
+ )
+ else
+ self.setdefaults(:puppet,
+ :logdir => ["$vardir/log", "The Puppet log directory."]
+ )
+ end
+
+ self.setdefaults(:puppet,
:statedir => { :default => "$vardir/state",
:mode => 01777,
:desc => "The directory where Puppet state is stored. Generally,
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 5ddd82829..ee447076f 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -251,11 +251,13 @@ module Puppet
Puppet::Rails.init
# We store all of the objects, even the collectable ones
- Puppet::Rails::Host.store(
- :objects => objects,
- :host => client,
- :facts => facts
- )
+ benchmark(:info, "Stored configuration for #{client}") do
+ Puppet::Rails::Host.store(
+ :objects => objects,
+ :host => client,
+ :facts => facts
+ )
+ end
# Now that we've stored everything, we need to strip out
# the collectable objects so that they are not sent on
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index 65be5294b..ace906117 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -1,6 +1,6 @@
require 'puppet/rails/rails_object'
-RailsObject = Puppet::Rails::RailsObject
+#RailsObject = Puppet::Rails::RailsObject
class Puppet::Rails::Host < ActiveRecord::Base
Host = self
serialize :facts, Hash
@@ -45,11 +45,13 @@ class Puppet::Rails::Host < ActiveRecord::Base
host[param] = hostargs[param]
end
end
+ host.addobjects(objects)
else
- host = Host.new(hostargs)
+ host = Host.new(hostargs) do |hostobj|
+ hostobj.addobjects(objects)
+ end
end
- host.addobjects(objects)
host.save
@@ -69,15 +71,12 @@ class Puppet::Rails::Host < ActiveRecord::Base
end
end
- robj = RailsObject.new(args)
+ robj = rails_objects.build(args)
+ robj.addparams(params)
if tobj.collectable
robj.toggle(:collectable)
end
-
- self.rails_objects << robj
-
- robj.addparams(params)
end
end
end
diff --git a/lib/puppet/rails/rails_object.rb b/lib/puppet/rails/rails_object.rb
index 22d37fca0..1b725c984 100644
--- a/lib/puppet/rails/rails_object.rb
+++ b/lib/puppet/rails/rails_object.rb
@@ -1,7 +1,7 @@
require 'puppet'
require 'puppet/rails/rails_parameter'
-RailsParameter = Puppet::Rails::RailsParameter
+#RailsParameter = Puppet::Rails::RailsParameter
class Puppet::Rails::RailsObject < ActiveRecord::Base
has_many :rails_parameters, :dependent => :delete_all
serialize :tags, Array
@@ -11,12 +11,12 @@ class Puppet::Rails::RailsObject < ActiveRecord::Base
# Add a set of parameters.
def addparams(params)
params.each do |pname, pvalue|
- pobj = RailsParameter.new(
+ rails_parameters.build(
:name => pname,
:value => pvalue
)
- self.rails_parameters << pobj
+ #self.rails_parameters << pobj
end
end
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 33593a42b..b30cd1df3 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -68,9 +68,9 @@ module Puppet
munge do |value|
case value
- when false, "false":
+ when false, "false", :false:
false
- when true, "true", ".puppet-bak":
+ when true, "true", ".puppet-bak", :true:
".puppet-bak"
when String:
# We can't depend on looking this up right now,