hotdog 0.15.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hotdog/commands.rb +12 -0
- data/lib/hotdog/commands/down.rb +2 -12
- data/lib/hotdog/commands/scp.rb +3 -0
- data/lib/hotdog/commands/sftp.rb +3 -0
- data/lib/hotdog/commands/ssh.rb +7 -0
- data/lib/hotdog/commands/tag.rb +19 -4
- data/lib/hotdog/commands/untag.rb +38 -11
- data/lib/hotdog/commands/up.rb +2 -22
- data/lib/hotdog/version.rb +1 -1
- 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: b815e449286ca6604e3f3b04fdd18c5588dd07ee
|
4
|
+
data.tar.gz: e022e85d07a01c4738861a85f3285937949a5390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c6f2faf19be1bb5350abf82b119fcf80ba2ae30a608a58bf387d8a3fec849de226559d4434f335bbdceab98305c9880d952d8df3e6fe56896dc3c458efcf5fc
|
7
|
+
data.tar.gz: 4d75ceaba7bef826c9e86ecd68d51230325f7353960ac91a251b1152a84e2673e0c01fc7d458fd4b5e801847652ff85fe97d5fa3ab56731140b12286535ac126
|
data/lib/hotdog/commands.rb
CHANGED
@@ -344,6 +344,18 @@ module Hotdog
|
|
344
344
|
backup.step(-1)
|
345
345
|
backup.finish
|
346
346
|
end
|
347
|
+
|
348
|
+
def with_retry(options={}, &block)
|
349
|
+
(options[:retry] || 1).times do |i|
|
350
|
+
begin
|
351
|
+
return yield
|
352
|
+
rescue => error
|
353
|
+
logger.warn(error.to_s)
|
354
|
+
sleep(options[:retry_delay] || (1<<i))
|
355
|
+
end
|
356
|
+
end
|
357
|
+
raise("retry count exceeded")
|
358
|
+
end
|
347
359
|
end
|
348
360
|
end
|
349
361
|
end
|
data/lib/hotdog/commands/down.rb
CHANGED
@@ -7,8 +7,8 @@ module Hotdog
|
|
7
7
|
class Down < BaseCommand
|
8
8
|
def define_options(optparse, options={})
|
9
9
|
default_option(options, :downtime, 86400)
|
10
|
-
default_option(options, :start, Time.new)
|
11
10
|
default_option(options, :retry, 5)
|
11
|
+
default_option(options, :start, Time.new)
|
12
12
|
optparse.on("--downtime DURATION") do |v|
|
13
13
|
options[:downtime] = v.to_i
|
14
14
|
end
|
@@ -30,17 +30,7 @@ module Hotdog
|
|
30
30
|
else
|
31
31
|
scope = arg
|
32
32
|
end
|
33
|
-
|
34
|
-
options[:retry].times do |i|
|
35
|
-
begin
|
36
|
-
schedule_downtime(scope, options)
|
37
|
-
break
|
38
|
-
rescue => error
|
39
|
-
logger.warn(error.to_s)
|
40
|
-
sleep(options[:retry_delay] || (1<<i))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
else
|
33
|
+
with_retry(options) do
|
44
34
|
schedule_downtime(scope, options)
|
45
35
|
end
|
46
36
|
end
|
data/lib/hotdog/commands/scp.rb
CHANGED
data/lib/hotdog/commands/sftp.rb
CHANGED
data/lib/hotdog/commands/ssh.rb
CHANGED
@@ -17,6 +17,10 @@ module Hotdog
|
|
17
17
|
default_option(options, :color, :auto)
|
18
18
|
default_option(options, :max_parallelism, Parallel.processor_count)
|
19
19
|
default_option(options, :shuffle, false)
|
20
|
+
default_option(options, :ssh_config, nil)
|
21
|
+
optparse.on("-F SSH_CONFIG", "Specifies an alternative per-user SSH configuration file.") do |configfile|
|
22
|
+
options[:ssh_config] = configfile
|
23
|
+
end
|
20
24
|
optparse.on("-o SSH_OPTION", "Passes this string to ssh command through shell. This option may be given multiple times") do |option|
|
21
25
|
options[:options] += [option]
|
22
26
|
end
|
@@ -115,6 +119,9 @@ module Hotdog
|
|
115
119
|
if options[:forward_agent]
|
116
120
|
cmdline << "-A"
|
117
121
|
end
|
122
|
+
if options[:ssh_config]
|
123
|
+
cmdline << "-F" << options[:ssh_config]
|
124
|
+
end
|
118
125
|
if options[:identity_file]
|
119
126
|
cmdline << "-i" << options[:identity_file]
|
120
127
|
end
|
data/lib/hotdog/commands/tag.rb
CHANGED
@@ -6,12 +6,19 @@ module Hotdog
|
|
6
6
|
module Commands
|
7
7
|
class Tag < BaseCommand
|
8
8
|
def define_options(optparse, options={})
|
9
|
+
default_option(options, :retry, 5)
|
9
10
|
default_option(options, :tag_source, "user")
|
10
11
|
default_option(options, :tags, [])
|
12
|
+
optparse.on("--retry NUM") do |v|
|
13
|
+
options[:retry] = v.to_i
|
14
|
+
end
|
15
|
+
optparse.on("--retry-delay SECONDS") do |v|
|
16
|
+
options[:retry_delay] = v.to_i
|
17
|
+
end
|
11
18
|
optparse.on("--source SOURCE") do |v|
|
12
19
|
options[:tag_source] = v
|
13
20
|
end
|
14
|
-
optparse.on("--tag TAG") do |v|
|
21
|
+
optparse.on("-a TAG", "-t TAG", "--tag TAG", "Use specified tag name/value") do |v|
|
15
22
|
options[:tags] << v
|
16
23
|
end
|
17
24
|
end
|
@@ -24,9 +31,8 @@ module Hotdog
|
|
24
31
|
# nop
|
25
32
|
else
|
26
33
|
# add all as user tags
|
27
|
-
|
28
|
-
|
29
|
-
raise("dog.add_tags(#{host_name.inspect}, #{options[:tags].inspect}, source=#{options[:tag_source].inspect}) returns [#{code.inspect}, #{add_tags.inspect}]")
|
34
|
+
with_retry(options) do
|
35
|
+
add_tags(host_name, options[:tags], source=options[:tag_source])
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
@@ -37,6 +43,15 @@ module Hotdog
|
|
37
43
|
end
|
38
44
|
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
39
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def add_tags(host_name, tags, options={})
|
49
|
+
code, resp = dog.add_tags(host_name, tags, options)
|
50
|
+
if code.to_i / 100 != 2
|
51
|
+
raise("dog.add_tags(#{host_name.inspect}, #{tags.inspect}, #{options.inspect}) returns [#{code.inspect}, #{resp.inspect}]")
|
52
|
+
end
|
53
|
+
resp
|
54
|
+
end
|
40
55
|
end
|
41
56
|
end
|
42
57
|
end
|
@@ -6,12 +6,19 @@ module Hotdog
|
|
6
6
|
module Commands
|
7
7
|
class Untag < BaseCommand
|
8
8
|
def define_options(optparse, options={})
|
9
|
+
default_option(options, :retry, 5)
|
9
10
|
default_option(options, :tag_source, "user")
|
10
11
|
default_option(options, :tags, [])
|
12
|
+
optparse.on("--retry NUM") do |v|
|
13
|
+
options[:retry] = v.to_i
|
14
|
+
end
|
15
|
+
optparse.on("--retry-delay SECONDS") do |v|
|
16
|
+
options[:retry_delay] = v.to_i
|
17
|
+
end
|
11
18
|
optparse.on("--source SOURCE") do |v|
|
12
19
|
options[:tag_source] = v
|
13
20
|
end
|
14
|
-
optparse.on("--tag TAG") do |v|
|
21
|
+
optparse.on("-a TAG", "-t TAG", "--tag TAG", "Use specified tag name/value") do |v|
|
15
22
|
options[:tags] << v
|
16
23
|
end
|
17
24
|
end
|
@@ -22,23 +29,18 @@ module Hotdog
|
|
22
29
|
|
23
30
|
if options[:tags].empty?
|
24
31
|
# delete all user tags
|
25
|
-
|
26
|
-
|
27
|
-
raise("dog.detach_tags(#{host_name.inspect}, source=#{options[:tag_source].inspect}) returns [#{code.inspect}, #{detach_tags.inspect}]")
|
32
|
+
with_retry do
|
33
|
+
detach_tags(host_name, source=options[:tag_source])
|
28
34
|
end
|
29
35
|
else
|
30
|
-
|
31
|
-
if code.to_i / 100 != 2
|
32
|
-
raise("dog.host_tags(#{host_name.inspect}, source=#{options[:tag_source].inspect}) returns [#{code.inspect}, #{host_tags.inspect}]")
|
33
|
-
end
|
36
|
+
host_tags = with_retry { host_tags(host_name, source=options[:tag_source]) }
|
34
37
|
old_tags = host_tags["tags"]
|
35
38
|
new_tags = old_tags - options[:tags]
|
36
39
|
if old_tags == new_tags
|
37
40
|
# nop
|
38
41
|
else
|
39
|
-
|
40
|
-
|
41
|
-
raise("dog.update_tags(#{host_name.inspect}, #{new_tags.inspect}, source=#{options[:tag_source].inspect}) returns [#{code.inspect}, #{update_tags.inspect}]")
|
42
|
+
with_retry do
|
43
|
+
update_tags(host_name, new_tags, source=options[:tag_source])
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -50,6 +52,31 @@ module Hotdog
|
|
50
52
|
end
|
51
53
|
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
52
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def detach_tags(host_name, options={})
|
58
|
+
code, detach_tags = dog.detach_tags(host_name, options)
|
59
|
+
if code.to_i / 100 != 2
|
60
|
+
raise("dog.detach_tags(#{host_name.inspect}, #{options.inspect}) returns [#{code.inspect}, #{detach_tags.inspect}]")
|
61
|
+
end
|
62
|
+
detach_tags
|
63
|
+
end
|
64
|
+
|
65
|
+
def host_tags(host_name, options={})
|
66
|
+
code, host_tags = dog.host_tags(host_name, options)
|
67
|
+
if code.to_i / 100 != 2
|
68
|
+
raise("dog.host_tags(#{host_name.inspect}, #{options.inspect}) returns [#{code.inspect}, #{host_tags.inspect}]")
|
69
|
+
end
|
70
|
+
host_tags
|
71
|
+
end
|
72
|
+
|
73
|
+
def update_tags(host_name, tags, options={})
|
74
|
+
code, update_tags = dog.update_tags(host_name, tags, options)
|
75
|
+
if code.to_i / 100 != 2
|
76
|
+
raise("dog.update_tags(#{host_name.inspect}, #{tags.inspect}, #{options.inspect}) returns [#{code.inspect}, #{update_tags.inspect}]")
|
77
|
+
end
|
78
|
+
update_tags
|
79
|
+
end
|
53
80
|
end
|
54
81
|
end
|
55
82
|
end
|
data/lib/hotdog/commands/up.rb
CHANGED
@@ -24,17 +24,7 @@ module Hotdog
|
|
24
24
|
end
|
25
25
|
}
|
26
26
|
all_downtimes = nil
|
27
|
-
|
28
|
-
options[:retry].times do |i|
|
29
|
-
begin
|
30
|
-
all_downtimes = get_all_downtimes(options)
|
31
|
-
break
|
32
|
-
rescue => error
|
33
|
-
logger.warn(error.to_s)
|
34
|
-
sleep(options[:retry_delay] || (1<<i))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
else
|
27
|
+
with_retry(options) do
|
38
28
|
all_downtimes = get_all_downtimes(options)
|
39
29
|
end
|
40
30
|
|
@@ -43,17 +33,7 @@ module Hotdog
|
|
43
33
|
}
|
44
34
|
|
45
35
|
cancel_downtimes.each do |downtime|
|
46
|
-
|
47
|
-
options[:retry].times do |i|
|
48
|
-
begin
|
49
|
-
cancel_downtime(downtime["id"], options)
|
50
|
-
break
|
51
|
-
rescue => error
|
52
|
-
logger.warn(error.to_s)
|
53
|
-
sleep(options[:retry_delay] || (1<<i))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
else
|
36
|
+
with_retry(options) do
|
57
37
|
cancel_downtime(downtime["id"], options)
|
58
38
|
end
|
59
39
|
end
|
data/lib/hotdog/version.rb
CHANGED
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.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -263,3 +263,4 @@ test_files:
|
|
263
263
|
- spec/parser/regexp_expression_spec.rb
|
264
264
|
- spec/parser/string_expression_spec.rb
|
265
265
|
- spec/spec_helper.rb
|
266
|
+
has_rdoc:
|