hotdog 0.5.3 → 0.5.4
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/hotdog/application.rb +3 -2
- data/lib/hotdog/commands/down.rb +2 -2
- data/lib/hotdog/commands/help.rb +1 -1
- data/lib/hotdog/commands/hosts.rb +1 -1
- data/lib/hotdog/commands/pssh.rb +18 -24
- data/lib/hotdog/commands/search.rb +7 -9
- data/lib/hotdog/commands/ssh.rb +24 -30
- data/lib/hotdog/commands/tags.rb +1 -1
- data/lib/hotdog/commands/up.rb +1 -1
- data/lib/hotdog/commands.rb +2 -2
- data/lib/hotdog/version.rb +1 -1
- data/spec/parser/{tag_glob_expression_spec.rb → glob_expression_spec.rb} +0 -0
- data/spec/parser/{tag_regexp_expression_spec.rb → regexp_expression_spec.rb} +0 -0
- data/spec/parser/{tag_expression_spec.rb → string_expression_spec.rb} +0 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad54741d7b612af34df19f0ae934c938411a941
|
4
|
+
data.tar.gz: 951a0d2bafcf5edbc3262e9f1552b4aade13fc0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c4fdc6b65e2caa37150c2e47bf207cacfec32d775e7f23b9e7b79298935853b5c34dc094d75ee21b48187d9440b3d4d9ae787a212387a5ae3415e1e5caac7df
|
7
|
+
data.tar.gz: 8e71095cbea2abee8f03173cfda463b289326a4a2a0fa187bd45040856e32e287f8ab84c270bacaa785f15ec6dddb052e126941438c6a353ed9d5e417b74140c
|
data/lib/hotdog/application.rb
CHANGED
@@ -54,7 +54,8 @@ module Hotdog
|
|
54
54
|
begin
|
55
55
|
command = ( args.shift || "help" )
|
56
56
|
get_command(command).new(self).tap do |cmd|
|
57
|
-
|
57
|
+
@optparse.banner = "Usage: hotdog #{command} [options]"
|
58
|
+
cmd.define_options(@optparse, @options)
|
58
59
|
args = cmd.parse_options(@optparse, args)
|
59
60
|
unless options[:api_key]
|
60
61
|
raise("DATADOG_API_KEY is not set")
|
@@ -76,7 +77,7 @@ module Hotdog
|
|
76
77
|
options[:logger].level = Logger::INFO
|
77
78
|
end
|
78
79
|
|
79
|
-
cmd.run(args)
|
80
|
+
cmd.run(args, @options)
|
80
81
|
end
|
81
82
|
rescue Errno::EPIPE
|
82
83
|
# nop
|
data/lib/hotdog/commands/down.rb
CHANGED
@@ -5,7 +5,7 @@ require "fileutils"
|
|
5
5
|
module Hotdog
|
6
6
|
module Commands
|
7
7
|
class Down < BaseCommand
|
8
|
-
def define_options(optparse)
|
8
|
+
def define_options(optparse, options={})
|
9
9
|
@downtime = 86400
|
10
10
|
@start = Time.new
|
11
11
|
optparse.on("--downtime DURATION") do |v|
|
@@ -16,7 +16,7 @@ module Hotdog
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def run(args=[])
|
19
|
+
def run(args=[], options={})
|
20
20
|
args.each do |arg|
|
21
21
|
if arg.index(":").nil?
|
22
22
|
scope = "host:#{arg}"
|
data/lib/hotdog/commands/help.rb
CHANGED
@@ -5,7 +5,7 @@ require "rbconfig"
|
|
5
5
|
module Hotdog
|
6
6
|
module Commands
|
7
7
|
class Help < BaseCommand
|
8
|
-
def run(args=[])
|
8
|
+
def run(args=[], options={})
|
9
9
|
ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
|
10
10
|
exit(system(ruby, $0, "--help") ? 0 : 1)
|
11
11
|
end
|
data/lib/hotdog/commands/pssh.rb
CHANGED
@@ -9,37 +9,31 @@ require "parallel"
|
|
9
9
|
module Hotdog
|
10
10
|
module Commands
|
11
11
|
class Pssh < Search
|
12
|
-
def define_options(optparse)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
max_parallelism: nil,
|
19
|
-
})
|
12
|
+
def define_options(optparse, options={})
|
13
|
+
options[:options] = []
|
14
|
+
options[:user] = nil
|
15
|
+
options[:port] = nil
|
16
|
+
options[:identity_file] = nil
|
17
|
+
options[:max_parallelism] = nil
|
20
18
|
|
21
19
|
optparse.on("-o SSH_OPTION", "Passes this string to ssh command through shell. This option may be given multiple times") do |option|
|
22
|
-
|
20
|
+
options[:options] += [option]
|
23
21
|
end
|
24
22
|
optparse.on("-i SSH_IDENTITY_FILE", "SSH identity file path") do |path|
|
25
|
-
|
23
|
+
options[:identity_file] = path
|
26
24
|
end
|
27
25
|
optparse.on("-p PORT", "Port of the remote host", Integer) do |port|
|
28
|
-
|
26
|
+
options[:port] = port
|
29
27
|
end
|
30
28
|
optparse.on("-u SSH_USER", "SSH login user name") do |user|
|
31
|
-
|
29
|
+
options[:user] = user
|
32
30
|
end
|
33
31
|
optparse.on("-P PARALLELISM", "Max parallelism", Integer) do |n|
|
34
|
-
|
32
|
+
options[:max_parallelism] = n
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
|
-
def
|
39
|
-
optparse.order(args)
|
40
|
-
end
|
41
|
-
|
42
|
-
def run(args=[])
|
36
|
+
def run(args=[], options={})
|
43
37
|
use_color = STDOUT.tty?
|
44
38
|
expression = args.join(" ").strip
|
45
39
|
if expression.empty? || args.empty?
|
@@ -65,24 +59,24 @@ module Hotdog
|
|
65
59
|
|
66
60
|
# build ssh command
|
67
61
|
cmdline = ["ssh"]
|
68
|
-
|
62
|
+
options[:options].each do |option|
|
69
63
|
cmdline << "-o" << option
|
70
64
|
end
|
71
|
-
if path =
|
65
|
+
if path = options[:identity_file]
|
72
66
|
cmdline << "-i" << Shellwords.escape(path)
|
73
67
|
end
|
74
|
-
if port =
|
68
|
+
if port = options[:port]
|
75
69
|
cmdline << "-p" << port.to_s
|
76
70
|
end
|
77
|
-
if
|
71
|
+
if options[:forward_agent]
|
78
72
|
cmdline << "-A"
|
79
73
|
end
|
80
74
|
|
81
75
|
cmdline << "-o" << "BatchMode=yes"
|
82
76
|
|
83
|
-
user =
|
77
|
+
user = options[:user]
|
84
78
|
|
85
|
-
threads =
|
79
|
+
threads = options[:max_parallelism] || addresses.size
|
86
80
|
stats = Parallel.map(addresses, in_threads: threads) { |address,name|
|
87
81
|
if use_color
|
88
82
|
header = "\e[0;36m#{name}\e[00m"
|
@@ -6,15 +6,13 @@ require "parslet"
|
|
6
6
|
module Hotdog
|
7
7
|
module Commands
|
8
8
|
class Search < BaseCommand
|
9
|
-
def define_options(optparse)
|
10
|
-
@search_options = @options.merge({
|
11
|
-
})
|
9
|
+
def define_options(optparse, options={})
|
12
10
|
optparse.on("-n", "--limit LIMIT", "Limit result set to specified size at most", Integer) do |limit|
|
13
|
-
|
11
|
+
options[:limit] = limit
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
|
-
def run(args=[])
|
15
|
+
def run(args=[], options={})
|
18
16
|
expression = args.join(" ").strip
|
19
17
|
if expression.empty?
|
20
18
|
# return everything if given expression is empty
|
@@ -31,7 +29,7 @@ module Hotdog
|
|
31
29
|
result = evaluate(node, self)
|
32
30
|
if 0 < result.length
|
33
31
|
_result, fields = get_hosts_with_search_tags(result, node)
|
34
|
-
result = _result.take(
|
32
|
+
result = _result.take(options.fetch(:limit, _result.size))
|
35
33
|
STDOUT.print(format(result, fields: fields))
|
36
34
|
if _result.length == result.length
|
37
35
|
logger.info("found %d host(s)." % result.length)
|
@@ -53,10 +51,10 @@ module Hotdog
|
|
53
51
|
else []
|
54
52
|
end
|
55
53
|
}
|
56
|
-
if
|
54
|
+
if options[:display_search_tags]
|
57
55
|
identifiers = drilldown.call(node).map(&:to_s)
|
58
|
-
if
|
59
|
-
tags = [
|
56
|
+
if options[:primary_tag]
|
57
|
+
tags = [options[:primary_tag]] + identifiers
|
60
58
|
else
|
61
59
|
tags = identifiers
|
62
60
|
end
|
data/lib/hotdog/commands/ssh.rb
CHANGED
@@ -8,45 +8,39 @@ require "shellwords"
|
|
8
8
|
module Hotdog
|
9
9
|
module Commands
|
10
10
|
class Ssh < Search
|
11
|
-
def define_options(optparse)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
verbose: false,
|
20
|
-
})
|
11
|
+
def define_options(optparse, options={})
|
12
|
+
options[:index] = nil
|
13
|
+
options[:options] = []
|
14
|
+
options[:user] = nil
|
15
|
+
options[:port] = nil
|
16
|
+
options[:identity_file] = nil
|
17
|
+
options[:forward_agent] = false
|
18
|
+
options[:verbose] = false
|
21
19
|
|
22
20
|
optparse.on("-n", "--index INDEX", "Use this index of host if multiple servers are found", Integer) do |index|
|
23
|
-
|
21
|
+
options[:index] = index
|
24
22
|
end
|
25
23
|
optparse.on("-o SSH_OPTION", "Passes this string to ssh command through shell. This option may be given multiple times") do |option|
|
26
|
-
|
24
|
+
options[:options] += [option]
|
27
25
|
end
|
28
26
|
optparse.on("-i SSH_IDENTITY_FILE", "SSH identity file path") do |path|
|
29
|
-
|
27
|
+
options[:identity_file] = path
|
30
28
|
end
|
31
29
|
optparse.on("-A", "Enable agent forwarding", TrueClass) do |b|
|
32
|
-
|
30
|
+
options[:forward_agent] = b
|
33
31
|
end
|
34
32
|
optparse.on("-p PORT", "Port of the remote host", Integer) do |port|
|
35
|
-
|
33
|
+
options[:port] = port
|
36
34
|
end
|
37
35
|
optparse.on("-u SSH_USER", "SSH login user name") do |user|
|
38
|
-
|
36
|
+
options[:user] = user
|
39
37
|
end
|
40
38
|
optparse.on("-v", "--verbose", "Enable verbose ode") do |v|
|
41
|
-
|
39
|
+
options[:verbose] = v
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
|
-
def
|
46
|
-
optparse.order(args)
|
47
|
-
end
|
48
|
-
|
49
|
-
def run(args=[])
|
43
|
+
def run(args=[], options={})
|
50
44
|
expression = args.join(" ").strip
|
51
45
|
if expression.empty?
|
52
46
|
exit(1)
|
@@ -67,8 +61,8 @@ module Hotdog
|
|
67
61
|
STDERR.puts("no match found: #{search_args.join(" ")}")
|
68
62
|
exit(1)
|
69
63
|
else
|
70
|
-
if
|
71
|
-
host = result[
|
64
|
+
if options[:index] && result.length > options[:index]
|
65
|
+
host = result[options[:index]]
|
72
66
|
else
|
73
67
|
result, fields = get_hosts_with_search_tags(result, node)
|
74
68
|
|
@@ -87,22 +81,22 @@ module Hotdog
|
|
87
81
|
|
88
82
|
# build ssh command
|
89
83
|
cmdline = ["ssh"]
|
90
|
-
|
84
|
+
options[:options].each do |option|
|
91
85
|
cmdline << "-o" << option
|
92
86
|
end
|
93
|
-
if path =
|
87
|
+
if path = options[:identity_file]
|
94
88
|
cmdline << "-i" << Shellwords.escape(path)
|
95
89
|
end
|
96
|
-
if port =
|
90
|
+
if port = options[:port]
|
97
91
|
cmdline << "-p" << port.to_s
|
98
92
|
end
|
99
|
-
if
|
93
|
+
if options[:forward_agent]
|
100
94
|
cmdline << "-A"
|
101
95
|
end
|
102
|
-
if
|
96
|
+
if options[:verbose]
|
103
97
|
cmdline << "-v"
|
104
98
|
end
|
105
|
-
if user =
|
99
|
+
if user = options[:user]
|
106
100
|
cmdline << (user + "@" + address)
|
107
101
|
else
|
108
102
|
cmdline << address
|
data/lib/hotdog/commands/tags.rb
CHANGED
data/lib/hotdog/commands/up.rb
CHANGED
data/lib/hotdog/commands.rb
CHANGED
@@ -25,7 +25,7 @@ module Hotdog
|
|
25
25
|
attr_reader :logger
|
26
26
|
attr_reader :options
|
27
27
|
|
28
|
-
def run(args=[])
|
28
|
+
def run(args=[], options={})
|
29
29
|
raise(NotImplementedError)
|
30
30
|
end
|
31
31
|
|
@@ -52,7 +52,7 @@ module Hotdog
|
|
52
52
|
update_db(options)
|
53
53
|
end
|
54
54
|
|
55
|
-
def define_options(optparse)
|
55
|
+
def define_options(optparse, options={})
|
56
56
|
# nop
|
57
57
|
end
|
58
58
|
|
data/lib/hotdog/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -153,10 +153,10 @@ files:
|
|
153
153
|
- spec/formatter/text_spec.rb
|
154
154
|
- spec/formatter/tsv_spec.rb
|
155
155
|
- spec/formatter/yaml_spec.rb
|
156
|
+
- spec/parser/glob_expression_spec.rb
|
156
157
|
- spec/parser/parser_spec.rb
|
157
|
-
- spec/parser/
|
158
|
-
- spec/parser/
|
159
|
-
- spec/parser/tag_regexp_expression_spec.rb
|
158
|
+
- spec/parser/regexp_expression_spec.rb
|
159
|
+
- spec/parser/string_expression_spec.rb
|
160
160
|
- spec/spec_helper.rb
|
161
161
|
homepage: https://github.com/yyuu/hotdog
|
162
162
|
licenses:
|
@@ -192,9 +192,9 @@ test_files:
|
|
192
192
|
- spec/formatter/text_spec.rb
|
193
193
|
- spec/formatter/tsv_spec.rb
|
194
194
|
- spec/formatter/yaml_spec.rb
|
195
|
+
- spec/parser/glob_expression_spec.rb
|
195
196
|
- spec/parser/parser_spec.rb
|
196
|
-
- spec/parser/
|
197
|
-
- spec/parser/
|
198
|
-
- spec/parser/tag_regexp_expression_spec.rb
|
197
|
+
- spec/parser/regexp_expression_spec.rb
|
198
|
+
- spec/parser/string_expression_spec.rb
|
199
199
|
- spec/spec_helper.rb
|
200
200
|
has_rdoc:
|