stackadmin 0.2.0 → 1.0.0
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/CHANGELOG +23 -2
- data/lib/stackadmin/log.rb +39 -7
- data/lib/stackadmin/version.rb +1 -1
- data/test/stackadmin_test.rb +27 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff7b29f7a0a1d1de8c0f8dee4a92d4871815ce65
|
4
|
+
data.tar.gz: b3472c1a8c7f0b2884e688ef076c8ab07ff5e088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ebbbec1bb8949ea298d94b4b3807237d9c88c2fc691e7f9f297870c5155b6397a5749b13c77e8a97fee90efbdb2b7664a5e811bb86c53ad9356b1e794a95397
|
7
|
+
data.tar.gz: 70f7ade17b8cfedcaf30efc9343a9f006a6ba10a47212495dcb20e8ecbca3de815e00f66b8cd295fbfa4882ed3cefa7d91f896915697ead76955d90d681af77d
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0 (2015-03-16)
|
2
|
+
==================
|
3
|
+
|
4
|
+
New
|
5
|
+
---
|
6
|
+
- Full cluster reporting
|
7
|
+
- Download reports as tarballs
|
8
|
+
- Return path to report as string with ::report
|
9
|
+
- Debug output for ::report
|
10
|
+
|
11
|
+
Changes
|
12
|
+
-------
|
13
|
+
- Refactored method prototype for ::report
|
14
|
+
- Refactored tests
|
15
|
+
|
16
|
+
Fix
|
17
|
+
---
|
18
|
+
- Typos in CHANGELOG
|
19
|
+
- Typo in ::decompress_report docs
|
20
|
+
|
21
|
+
|
22
|
+
0.2.0 (2015-03-13)
|
2
23
|
==================
|
3
24
|
|
4
25
|
New
|
@@ -6,7 +27,7 @@ New
|
|
6
27
|
- Basic support for kato report
|
7
28
|
|
8
29
|
|
9
|
-
0.1.1 (
|
30
|
+
0.1.1 (2015-03-11)
|
10
31
|
==================
|
11
32
|
|
12
33
|
New
|
data/lib/stackadmin/log.rb
CHANGED
@@ -11,21 +11,52 @@ require_relative 'net-ssh'
|
|
11
11
|
|
12
12
|
class Stackadmin
|
13
13
|
# Retrieve a report from the targeted Stackato
|
14
|
-
# @
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
# @option args [Symbol] :tarball retrieve report as a tarball
|
15
|
+
# @option args [Symbol] :cluster retrieve full cluster report
|
16
|
+
# @option args [String] :destination where to save the report
|
17
|
+
# @return [String] path to the report
|
18
|
+
def report(*args)
|
19
|
+
opts = (args.last.class == Hash) ? args.pop : Hash.new
|
20
|
+
opts[:destination] = '.' unless opts.has_key?(:destination)
|
21
|
+
|
22
|
+
cmd = 'kato report'
|
23
|
+
query = /^Report generated at (.+)\. /
|
24
|
+
output = nil
|
25
|
+
|
26
|
+
if args.include?(:cluster)
|
27
|
+
cmd += ' --cluster'
|
28
|
+
query = /^Your cluster 'kato report' is available at (.+)\.$/
|
29
|
+
end
|
30
|
+
|
31
|
+
log "Generating #{'cluster ' if args.include?(:cluster)}report at #{@id}"
|
32
|
+
ssh = Net::SSH.start(@id, 'stackato', port: @port)
|
33
|
+
location = ssh.exec_sc!(cmd)[:stdout].match(query)[1]
|
34
|
+
log "Report located at: #{@id}:#{location}"
|
35
|
+
|
36
|
+
if args.include?(:tarball)
|
37
|
+
filename = location.split('/').last
|
38
|
+
output = File.expand_path(File.join(opts[:destination], filename))
|
39
|
+
|
40
|
+
log "Downloading tarball to: #{output}"
|
41
|
+
ssh.scp.download!(location, opts[:destination])
|
42
|
+
else
|
43
|
+
log 'Downloading report'
|
19
44
|
tarball = StringIO.new(ssh.scp.download!(location))
|
45
|
+
|
46
|
+
log "Decompressing report to: #{opts[:destination]}"
|
47
|
+
decompress_report(tarball, opts[:destination])
|
48
|
+
output = File.expand_path(opts[:destination])
|
49
|
+
output = File.join(output, 'stackato-report') unless args.include?(:cluster)
|
20
50
|
end
|
21
51
|
|
22
|
-
|
52
|
+
ssh.close
|
53
|
+
output
|
23
54
|
end
|
24
55
|
|
25
56
|
private
|
26
57
|
|
27
58
|
# Decompresses a report tarball to a specified location
|
28
|
-
# @param
|
59
|
+
# @param tarball [StringIO] in-memory buffer of the report tarball
|
29
60
|
# @param destination [String] where to decompress the report
|
30
61
|
# @see http://old.thoughtsincomputation.com/posts/tar-and-a-few-feathers-in-ruby Yanked from TiC
|
31
62
|
def decompress_report(tarball, destination)
|
@@ -45,6 +76,7 @@ class Stackadmin
|
|
45
76
|
destination_directory = File.dirname(destination_file)
|
46
77
|
FileUtils.mkdir_p(destination_directory) unless File.directory?(destination_directory)
|
47
78
|
File.open(destination_file, 'wb') do |f|
|
79
|
+
log "Extracting #{destination_file}"
|
48
80
|
f.print tarfile.read
|
49
81
|
end
|
50
82
|
end
|
data/lib/stackadmin/version.rb
CHANGED
data/test/stackadmin_test.rb
CHANGED
@@ -44,10 +44,35 @@ describe Stackadmin do
|
|
44
44
|
describe 'report' do
|
45
45
|
it 'downloads a report to the current directory by default' do
|
46
46
|
Dir.chdir(TEMP_DIR) do
|
47
|
-
|
48
|
-
|
47
|
+
path = File.join(TEMP_DIR, 'stackato-report')
|
48
|
+
subject.report.must_equal path
|
49
|
+
assert File.directory?(path)
|
49
50
|
end
|
50
51
|
end
|
52
|
+
|
53
|
+
it 'downloads a report to a specified directory' do
|
54
|
+
path = File.join(TEMP_DIR, 'stackato-report')
|
55
|
+
subject.report(destination: TEMP_DIR).must_equal path
|
56
|
+
assert File.directory?(path)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'downloads the report as a tarball' do
|
60
|
+
path = File.join(TEMP_DIR, 'stackato-report.tgz')
|
61
|
+
subject.report(:tarball, destination: TEMP_DIR).must_equal path
|
62
|
+
assert File.file?(path)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'generates a full cluster report' do
|
66
|
+
subject.report(:cluster, destination: TEMP_DIR).must_equal TEMP_DIR
|
67
|
+
assert File.directory?(File.join(TEMP_DIR, '10.0.2.15'))
|
68
|
+
assert File.file?(File.join(TEMP_DIR, 'node_list.txt'))
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'generates a full cluster report as a tarball' do
|
72
|
+
path = File.join(TEMP_DIR, 'stackato-cluster-report.tgz')
|
73
|
+
subject.report(:cluster, :tarball, destination: TEMP_DIR).must_equal path
|
74
|
+
assert File.file?(path)
|
75
|
+
end
|
51
76
|
end
|
52
77
|
end
|
53
78
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackadmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andres Rojas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|