diff options
author | Luke Kanies <luke@madstop.com> | 2009-05-22 15:07:54 -0500 |
---|---|---|
committer | James Turnbull <james@ubuntu904.lovedthanlost.net> | 2009-05-26 13:43:39 +1000 |
commit | 1d69dbfd0351d3f4d23c15904061d98f8bf42ca6 (patch) | |
tree | e1f6dfe6067ab70d0bb236fa03b53fab82f5e675 | |
parent | 7650fb299768c23241784671e3abeb272ee87fab (diff) | |
download | puppet-1d69dbfd0351d3f4d23c15904061d98f8bf42ca6.tar.gz puppet-1d69dbfd0351d3f4d23c15904061d98f8bf42ca6.tar.xz puppet-1d69dbfd0351d3f4d23c15904061d98f8bf42ca6.zip |
Extracting a method from eval_resource in Transaction
Just cleaning up the code a bit before a modification.
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r-- | lib/puppet/transaction.rb | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 54163c521..80e0d49c5 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -202,43 +202,7 @@ class Transaction if checkskip and skip?(resource) @resourcemetrics[:skipped] += 1 else - @resourcemetrics[:scheduled] += 1 - - changecount = @changes.length - - # We need to generate first regardless, because the recursive - # actions sometimes change how the top resource is applied. - children = eval_generate(resource) - - if children and resource.depthfirst? - children.each do |child| - # The child will never be skipped when the parent isn't - events += eval_resource(child, false) - end - end - - # Perform the actual changes - seconds = thinmark do - events += apply(resource) - end - - if children and ! resource.depthfirst? - children.each do |child| - events += eval_resource(child, false) - end - end - - # A bit of hackery here -- if skipcheck is true, then we're the - # top-level resource. If that's the case, then make sure all of - # the changes list this resource as a proxy. This is really only - # necessary for rollback, since we know the generating resource - # during forward changes. - if children and checkskip - @changes[changecount..-1].each { |change| change.proxy = resource } - end - - # Keep track of how long we spend in each type of resource - @timemetrics[resource.class.name] += seconds + events += eval_children_and_apply_resource(resource, checkskip) end # Check to see if there are any events for this resource @@ -262,6 +226,50 @@ class Transaction events end + def eval_children_and_apply_resource(resource, checkskip) + events = [] + + @resourcemetrics[:scheduled] += 1 + + changecount = @changes.length + + # We need to generate first regardless, because the recursive + # actions sometimes change how the top resource is applied. + children = eval_generate(resource) + + if children and resource.depthfirst? + children.each do |child| + # The child will never be skipped when the parent isn't + events += eval_resource(child, false) + end + end + + # Perform the actual changes + seconds = thinmark do + events += apply(resource) + end + + if children and ! resource.depthfirst? + children.each do |child| + events += eval_resource(child, false) + end + end + + # A bit of hackery here -- if skipcheck is true, then we're the + # top-level resource. If that's the case, then make sure all of + # the changes list this resource as a proxy. This is really only + # necessary for rollback, since we know the generating resource + # during forward changes. + if children and checkskip + @changes[changecount..-1].each { |change| change.proxy = resource } + end + + # Keep track of how long we spend in each type of resource + @timemetrics[resource.class.name] += seconds + + events + end + # This method does all the actual work of running a transaction. It # collects all of the changes, executes them, and responds to any # necessary events. |