santoku 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/santoku/helpers.rb +90 -0
- data/lib/santoku/printers.rb +49 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf7295813d610a5e5f36bc497af900d690b98c1
|
4
|
+
data.tar.gz: 95089cdb8cfe09bb57ad35c1fd2ce7a3894ec763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f756ff452d1f66604752a69107445e30728b7e8478284de23fbb5ae106626d778213bd6bc1a78dd7ceb7bdc2a1501d7bb1bacfc6ec769fd81b4041be8e0466
|
7
|
+
data.tar.gz: 84c3d165ba29d80644a1319468814be213461219fe12b89884d348f78d9ef6f6bfe7654e4a2cc170e994fc199fe2653a5c2e162aa011bcaf84f139e028428c84
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'ridley'
|
2
|
+
require 'net/ssh'
|
3
|
+
require 'santoku/printers'
|
4
|
+
|
5
|
+
class Santoku
|
6
|
+
class << self
|
7
|
+
def failed(reason)
|
8
|
+
failed_output_stream.push reason
|
9
|
+
print_fail
|
10
|
+
end
|
11
|
+
|
12
|
+
def succeeded(reason)
|
13
|
+
success_output_stream.push reason
|
14
|
+
print_success
|
15
|
+
end
|
16
|
+
|
17
|
+
def timed_out(reason)
|
18
|
+
timeout_output_stream.push reason
|
19
|
+
print_timeout
|
20
|
+
end
|
21
|
+
|
22
|
+
def timeout_output_stream
|
23
|
+
@timeout_output_stream ||= Array.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def failed_output_stream
|
27
|
+
@failed_output_stream ||= Array.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def success_output_stream
|
31
|
+
@success_output_stream ||= Array.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def verbose_success?
|
35
|
+
@verbose_success
|
36
|
+
end
|
37
|
+
|
38
|
+
def invert?
|
39
|
+
@invert
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def knife_config
|
44
|
+
if ::File.exist?(File.expand_path("../knife.rb", __FILE__))
|
45
|
+
Ridley::Chef::Config.from_file(File.expand_path("../knife.rb", __FILE__))
|
46
|
+
elsif ::File.exist?("#{ENV['HOME']}/.chef/knife.rb")
|
47
|
+
Ridley::Chef::Config.from_file("#{ENV['HOME']}/.chef/knife.rb")
|
48
|
+
else
|
49
|
+
raise 'Could not find knife.rb in current directory or home '
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def ridley
|
54
|
+
@ridley ||= Ridley.new(
|
55
|
+
server_url: knife_config.chef_server_url,
|
56
|
+
client_name: knife_config.node_name,
|
57
|
+
client_key: knife_config.client_key
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def ssh_exec!(ssh, command)
|
62
|
+
# I am not awesome enough to have made this method myself
|
63
|
+
# Originally submitted by 'flitzwald' over here: http://stackoverflow.com/a/3386375
|
64
|
+
stdout_data = ""
|
65
|
+
stderr_data = ""
|
66
|
+
exit_code = nil
|
67
|
+
|
68
|
+
ssh.open_channel do |channel|
|
69
|
+
channel.exec(command) do |ch, success|
|
70
|
+
unless success
|
71
|
+
abort "FAILED: couldn't execute command (ssh.channel.exec)"
|
72
|
+
end
|
73
|
+
channel.on_data do |ch,data|
|
74
|
+
stdout_data+=data
|
75
|
+
end
|
76
|
+
|
77
|
+
channel.on_extended_data do |ch,type,data|
|
78
|
+
stderr_data+=data
|
79
|
+
end
|
80
|
+
|
81
|
+
channel.on_request("exit-status") do |ch,data|
|
82
|
+
exit_code = data.read_long
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
ssh.loop
|
87
|
+
[stdout_data, stderr_data, exit_code]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
class Santoku
|
4
|
+
class << self
|
5
|
+
def print_fail
|
6
|
+
print 'F'.red
|
7
|
+
end
|
8
|
+
|
9
|
+
def print_success
|
10
|
+
print '.'.green
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_timeout
|
14
|
+
print '*'.yellow
|
15
|
+
end
|
16
|
+
|
17
|
+
def print_timeout_stream
|
18
|
+
timeout_output_stream.each do |output|
|
19
|
+
puts output.yellow
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def print_failed_stream
|
24
|
+
failed_output_stream.each do |output|
|
25
|
+
puts output.red
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def print_success_stream
|
30
|
+
success_output_stream.each do |output|
|
31
|
+
puts output.green
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def print_summary
|
36
|
+
print "\n"
|
37
|
+
print_timeout_stream
|
38
|
+
print_failed_stream
|
39
|
+
print_success_stream if verbose_success?
|
40
|
+
|
41
|
+
puts "\n---------------------------------------\n"
|
42
|
+
|
43
|
+
puts "#{'Success'.green}: #{success_output_stream.count}"
|
44
|
+
puts "#{'Timed out or does not resolve'.yellow}: #{timeout_output_stream.count}"
|
45
|
+
puts "#{'Failed'.red}: #{failed_output_stream.count}"
|
46
|
+
puts "#{'Total'.blue}: #{success_output_stream.count + timeout_output_stream.count + failed_output_stream.count}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: santoku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven De Coeyer
|
8
|
-
- Mike Morraye
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
@@ -76,6 +75,8 @@ extensions: []
|
|
76
75
|
extra_rdoc_files: []
|
77
76
|
files:
|
78
77
|
- lib/santoku.rb
|
78
|
+
- lib/santoku/helpers.rb
|
79
|
+
- lib/santoku/printers.rb
|
79
80
|
- bin/santoku
|
80
81
|
homepage: https://github.com/zhann/santoku
|
81
82
|
licenses:
|