knife-draw 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/knife-draw.gemspec +1 -1
- data/lib/knife/draw.rb +1 -0
- data/lib/knife_draw/chef_graph.rb +2 -2
- data/lib/knife_draw/draw_nodes.rb +11 -7
- data/lib/knife_draw/draw_roles.rb +7 -4
- data/lib/knife_draw/verbose_output.rb +7 -0
- data/lib/knife_draw/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44f2b0f02a6f729eba72b64658d0416a07597aed
|
4
|
+
data.tar.gz: f1aaca343239a4e07f346a40c1ea84c97cebd1ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a56f9c3af69377d1ffeff77366dc6ada5b4403e06b53b337ded72a887a9ed576e7dbc233b0e7c7254fa99a58fded6bc12af094eb053f8d331e0ab058c365eb0
|
7
|
+
data.tar.gz: dd8db3e1d96e796e2321637316051334dda70858018a5254ee0076a12ea823ac65966689451ef508c3c05548a313851231c938d803bf152435dd477629b3e623
|
data/knife-draw.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["joshuaflanagan@gmail.com"]
|
11
11
|
spec.summary = %q{Draws pictures using your Chef data}
|
12
12
|
spec.description = %q{Generates GraphViz diagrams based on your Chef environment}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/joshuaflanagan/knife-draw"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
data/lib/knife/draw.rb
CHANGED
@@ -41,9 +41,9 @@ module KnifeDraw
|
|
41
41
|
graph.add_edge(source, target, color: EDGE_COLOR)
|
42
42
|
end
|
43
43
|
|
44
|
-
def draw!(outputfile
|
44
|
+
def draw!(outputfile)
|
45
45
|
filename=outputfile
|
46
|
-
format = File.extname(filename)[1..-1]
|
46
|
+
format = File.extname(filename)[1..-1] || :png
|
47
47
|
graph.output format => filename
|
48
48
|
end
|
49
49
|
end
|
@@ -1,36 +1,40 @@
|
|
1
1
|
module KnifeDraw
|
2
2
|
class DrawNodes < Chef::Knife
|
3
|
+
include VerboseOutput
|
4
|
+
|
3
5
|
deps do
|
4
6
|
require 'graphviz'
|
5
7
|
end
|
6
8
|
|
7
|
-
banner "knife draw nodes [
|
9
|
+
banner "knife draw nodes [FILENAME]"
|
8
10
|
|
9
11
|
def run
|
10
|
-
|
12
|
+
filename = name_args.size > 0 ? name_args.first : "output.png"
|
13
|
+
environment = config[:environment]
|
11
14
|
|
12
15
|
graph = ChefGraph.new cluster_environments: environment.nil?
|
13
16
|
source = ChefServerSource.new
|
14
17
|
|
15
|
-
source.nodes.each do |name, node|
|
18
|
+
source.nodes(environment).each do |name, node|
|
16
19
|
node_box = graph.draw_node(name, node.chef_environment)
|
17
|
-
|
20
|
+
verbose_out "name: #{name} env: #{node.chef_environment}"
|
18
21
|
source.roles_for_node(node).each do |role_name|
|
22
|
+
verbose_out "\trole: #{role_name}"
|
19
23
|
role_box = graph.draw_role(role_name)
|
20
24
|
graph.connect(node_box, role_box)
|
21
25
|
|
22
26
|
source.runlist_for_role(role_name).each do |run_list|
|
23
27
|
runlist_box = graph.draw_runlist run_list.to_s
|
24
28
|
graph.connect(role_box, runlist_box)
|
25
|
-
|
29
|
+
verbose_out "\t\trunlist: #{run_list}"
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
29
|
-
graph.draw!
|
33
|
+
graph.draw! filename
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
33
37
|
class NodeDraw < DrawNodes
|
34
|
-
banner "knife node draw
|
38
|
+
banner "knife node draw"
|
35
39
|
end
|
36
40
|
end
|
@@ -1,24 +1,27 @@
|
|
1
1
|
module KnifeDraw
|
2
2
|
class DrawRoles < Chef::Knife
|
3
|
+
include VerboseOutput
|
4
|
+
|
3
5
|
deps do
|
4
6
|
require 'graphviz'
|
5
7
|
end
|
6
8
|
|
7
|
-
banner "knife draw roles"
|
9
|
+
banner "knife draw roles [FILENAME]"
|
8
10
|
|
9
11
|
def run
|
12
|
+
filename = name_args.size > 0 ? name_args.first : "output.png"
|
10
13
|
graph = ChefGraph.new
|
11
14
|
source = ChefServerSource.new
|
12
15
|
source.roles.each do |role_name, role|
|
13
|
-
|
16
|
+
verbose_out "name: #{role_name}"
|
14
17
|
role_box = graph.draw_role(role_name)
|
15
18
|
source.runlist_for_role(role_name).each do |run_list|
|
16
19
|
runlist_box = graph.draw_runlist run_list.to_s
|
17
20
|
graph.connect(role_box, runlist_box)
|
18
|
-
|
21
|
+
verbose_out "\t\trunlist: #{run_list}"
|
19
22
|
end
|
20
23
|
end
|
21
|
-
graph.draw!
|
24
|
+
graph.draw! filename
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
data/lib/knife_draw/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-draw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Flanagan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -84,8 +84,9 @@ files:
|
|
84
84
|
- lib/knife_draw/chef_server_source.rb
|
85
85
|
- lib/knife_draw/draw_nodes.rb
|
86
86
|
- lib/knife_draw/draw_roles.rb
|
87
|
+
- lib/knife_draw/verbose_output.rb
|
87
88
|
- lib/knife_draw/version.rb
|
88
|
-
homepage:
|
89
|
+
homepage: https://github.com/joshuaflanagan/knife-draw
|
89
90
|
licenses:
|
90
91
|
- MIT
|
91
92
|
metadata: {}
|