diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-31 22:10:42 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-31 22:10:42 +0000 |
| commit | b8f798f0ad88c990b5f9fe4c2d7b830aeb36a446 (patch) | |
| tree | b39ef323763b33e3b82bbdb80954e92388e680c1 /lib | |
| parent | 0a1dd1ae8e5d77c22596579fbedfbe1db19b4445 (diff) | |
| download | puppet-b8f798f0ad88c990b5f9fe4c2d7b830aeb36a446.tar.gz puppet-b8f798f0ad88c990b5f9fe4c2d7b830aeb36a446.tar.xz puppet-b8f798f0ad88c990b5f9fe4c2d7b830aeb36a446.zip | |
Fixing #390. You can now add --graph to produce dot files, and you can then produce pngs or whatever from those.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2007 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/transaction.rb | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 6b19902cf..b6d0bfa3f 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -13,6 +13,16 @@ class Transaction include Puppet::Util + Puppet.config.setdefaults(:puppet, + :graph => [false, "Whether to create dot graph files for the different + configuration graphs. These dot files can be interpreted by tools + like OmniGraffle or dot (which is part of ImageMagick)."], + :graphdir => { :default => "$statedir/graphs", + :mode => 0775, + :owner => "$user", + :group => "$group", + } + ) Puppet.config.setdefaults(:transaction, :tags => ["", "Tags to use to find resources. If this is set, then only resources tagged with the specified tags will be applied. @@ -334,6 +344,16 @@ class Transaction end end + # Produce the graph files if requested. + def graph(gr, name) + return unless Puppet[:graph] + + file = File.join(Puppet[:graphdir], "%s.dot" % name.to_s) + File.open(file, "w") { |f| + f.puts gr.to_dot + } + end + # this should only be called by a Puppet::Type::Component resource now # and it should only receive an array def initialize(resources) @@ -343,6 +363,8 @@ class Transaction @resources = resources.to_graph end + graph(@resources, :resources) + @resourcemetrics = { :total => @resources.vertices.length, :out_of_sync => 0, # The number of resources that had changes @@ -420,9 +442,8 @@ class Transaction graph.add_edge!(edge) end end - - # Then splice in the container information - graph.splice!(@resources, Puppet::Type::Component) + + graph(graph, :relationships) # Lastly, add in any autorequires graph.vertices.each do |vertex| @@ -433,6 +454,11 @@ class Transaction end end + # Then splice in the container information + graph.splice!(@resources, Puppet::Type::Component) + + graph(graph, :expanded_relationships) + return graph end |
