summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-30 00:47:03 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-30 00:47:03 +0000
commit295b3571bbca407a86b2c79b6189004bc05e2eac (patch)
tree1be63382ce80064c89e45747fdbb69b4d60174df /lib
parent1e8e7ee55a11b0fe472e6efb3457cf7ce527cbed (diff)
downloadpuppet-295b3571bbca407a86b2c79b6189004bc05e2eac.tar.gz
puppet-295b3571bbca407a86b2c79b6189004bc05e2eac.tar.xz
puppet-295b3571bbca407a86b2c79b6189004bc05e2eac.zip
Renaming some methods so that we can generate a report on a transaction and then retrieve it later
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2372 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/network/client/master.rb2
-rw-r--r--lib/puppet/transaction.rb78
2 files changed, 41 insertions, 39 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index a4ffefea5..2dc71b45e 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -499,7 +499,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Send off the transaction report.
def report(transaction)
begin
- report = transaction.report()
+ report = transaction.generate_report()
if Puppet[:rrdgraph] == true
report.graph()
end
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 328921ed8..e211b0f5b 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -8,6 +8,8 @@ module Puppet
class Transaction
attr_accessor :component, :resources, :ignoreschedules, :ignoretags
attr_accessor :relgraph, :sorted_resources, :configurator
+
+ attr_reader :report
attr_writer :tags
@@ -395,6 +397,44 @@ class Transaction
end
end
+ # Generate a transaction report.
+ def generate_report
+ @resourcemetrics[:failed] = @failures.find_all do |name, num|
+ num > 0
+ end.length
+
+ # Get the total time spent
+ @timemetrics[:total] = @timemetrics.inject(0) do |total, vals|
+ total += vals[1]
+ total
+ end
+
+ # Unfortunately, RRD does not deal well with changing lists of values,
+ # so we have to pick a list of values and stick with it. In this case,
+ # that means we record the total time, the config time, and that's about
+ # it. We should probably send each type's time as a separate metric.
+ @timemetrics.dup.each do |name, value|
+ if Puppet::Type.type(name)
+ @timemetrics.delete(name)
+ end
+ end
+
+ # Add all of the metrics related to resource count and status
+ @report.newmetric(:resources, @resourcemetrics)
+
+ # Record the relative time spent in each resource.
+ @report.newmetric(:time, @timemetrics)
+
+ # Then all of the change-related metrics
+ @report.newmetric(:changes,
+ :total => @changes.length
+ )
+
+ @report.time = Time.now
+
+ return @report
+ end
+
# Produce the graph files if requested.
def graph(gr, name)
# We don't want to graph the configuration process.
@@ -522,44 +562,6 @@ class Transaction
return graph
end
- # Generate a transaction report.
- def report
- @resourcemetrics[:failed] = @failures.find_all do |name, num|
- num > 0
- end.length
-
- # Get the total time spent
- @timemetrics[:total] = @timemetrics.inject(0) do |total, vals|
- total += vals[1]
- total
- end
-
- # Unfortunately, RRD does not deal well with changing lists of values,
- # so we have to pick a list of values and stick with it. In this case,
- # that means we record the total time, the config time, and that's about
- # it. We should probably send each type's time as a separate metric.
- @timemetrics.dup.each do |name, value|
- if Puppet::Type.type(name)
- @timemetrics.delete(name)
- end
- end
-
- # Add all of the metrics related to resource count and status
- @report.newmetric(:resources, @resourcemetrics)
-
- # Record the relative time spent in each resource.
- @report.newmetric(:time, @timemetrics)
-
- # Then all of the change-related metrics
- @report.newmetric(:changes,
- :total => @changes.length
- )
-
- @report.time = Time.now
-
- return @report
- end
-
# Roll all completed changes back.
def rollback
@targets.clear