koma 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/lib/koma/backend/ssh.rb +10 -8
- data/lib/koma/cli.rb +7 -7
- data/lib/koma/version.rb +1 -1
- 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: 81a82ab20cf42d0d1961a641f0694c9e1e5ae68f
|
4
|
+
data.tar.gz: 44d1c6c6180fe5adeac4ceaf7da558fef6d9aff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add6325fa9970357a34053e2c90fac65ed276cfed461d69576d08237cef832cdc41a6e012ffb2e1c7e90ca0b32278f5df3dccd37938c602d7db89aac711baa95
|
7
|
+
data.tar.gz: 55faa2f2c085b3f4db78743bb6dc9acaabc5b87ea7b50832645f366b90ef87707492803ab3428aeb02f821b276d98df3b13f58b2f9ceb164c024f49f7fa18d1a
|
data/.travis.yml
CHANGED
data/lib/koma/backend/ssh.rb
CHANGED
@@ -20,16 +20,16 @@ module Koma
|
|
20
20
|
result
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def run_commands(commands)
|
24
24
|
if host.include?(',')
|
25
25
|
list = host.split(',').uniq
|
26
26
|
results = Parallel.map(list) do |h|
|
27
|
-
|
27
|
+
run_commands_via_ssh(h, options, commands)
|
28
28
|
end
|
29
29
|
arr = [list, results].transpose
|
30
30
|
result = Hash[*arr.flatten]
|
31
31
|
else
|
32
|
-
result =
|
32
|
+
result = run_commands_via_ssh(host, options, commands)
|
33
33
|
end
|
34
34
|
result
|
35
35
|
end
|
@@ -39,17 +39,19 @@ module Koma
|
|
39
39
|
out(options[:key])
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def run_commands_via_ssh(host, options, commands)
|
43
43
|
set :ssh_options, build_ssh_options(host, options)
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
results = {}
|
45
|
+
commands.each do |command|
|
46
|
+
result = Specinfra.backend.run_command(command)
|
47
|
+
results[command] = {
|
47
48
|
exit_signal: result.exit_signal,
|
48
49
|
exit_status: result.exit_status,
|
49
50
|
stderr: result.stderr,
|
50
51
|
stdout: result.stdout
|
51
52
|
}
|
52
|
-
|
53
|
+
end
|
54
|
+
results
|
53
55
|
end
|
54
56
|
|
55
57
|
private
|
data/lib/koma/cli.rb
CHANGED
@@ -34,25 +34,25 @@ module Koma
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
desc 'run-command <host1,host2,..> <
|
37
|
+
desc 'run-command <host1,host2,..> <command1> <command2> ...', 'run command on a remote machine'
|
38
38
|
option :yaml, type: :boolean, desc: 'stdout YAML', aliases: :Y
|
39
39
|
option :identity_file, type: :string, banner: '<identity_file>', desc: 'identity file', aliases: :i
|
40
40
|
option :port, type: :numeric, banner: '<port>', desc: 'port', aliases: :p
|
41
|
-
def run_command(host = nil,
|
41
|
+
def run_command(host = nil, *commands)
|
42
42
|
if host.nil?
|
43
43
|
STDERR.puts 'ERROR: "koma run-command" was called with no arguments'
|
44
44
|
STDERR.puts 'Usage: "koma run-command <host1,host2,..> <command>"'
|
45
45
|
return
|
46
46
|
end
|
47
|
-
if
|
48
|
-
|
47
|
+
if commands.empty?
|
48
|
+
commands = [host]
|
49
49
|
begin
|
50
50
|
stdin = timeout(1) { $stdin.read }
|
51
51
|
rescue Timeout::Error
|
52
52
|
end
|
53
53
|
if stdin.nil?
|
54
|
-
STDERR.puts 'ERROR: "koma run-
|
55
|
-
STDERR.puts 'Usage: "koma run-
|
54
|
+
STDERR.puts 'ERROR: "koma run-commands" was called with no arguments'
|
55
|
+
STDERR.puts 'Usage: "koma run-commands <host1,host2,..> <commands>"'
|
56
56
|
return
|
57
57
|
end
|
58
58
|
ret = stdin.split("\n").select { |line| line =~ /^Host ([^\s\*]+)/ }.map do |line|
|
@@ -63,7 +63,7 @@ module Koma
|
|
63
63
|
end
|
64
64
|
backend = Koma::Backend::Ssh.new(host, options)
|
65
65
|
backend.stdin = stdin if stdin
|
66
|
-
gathered = backend.
|
66
|
+
gathered = backend.run_commands(commands)
|
67
67
|
if options[:yaml]
|
68
68
|
puts YAML.dump(gathered)
|
69
69
|
else
|
data/lib/koma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|