elasticDynamoDb 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/elasticDynamoDb.rb +1 -1
- data/lib/elasticDynamoDb/cli.rb +36 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 339c4f206bd73da9fdd595f61aa53fbfe8e52064
|
4
|
+
data.tar.gz: ee1a49ee9881e9df6a8e03ae11ea1649fe371602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39f710fe5cf67fb2ba37a68defa3e495e8783f14b3a36738a9088856eafa0df7bc94545385db4b11d1e75277546efda7a7e0287eaaa88fe5fc3203ec5bf9125c
|
7
|
+
data.tar.gz: 4d4be8515e9846d0a8e2ed2eff0daabc5f34dedce73ded5c23821f16d683bad5d7e79700192ebc6456ad636cc0f959edc163615e927c7641f35476e411b75baf
|
data/CHANGES.md
CHANGED
data/lib/elasticDynamoDb.rb
CHANGED
data/lib/elasticDynamoDb/cli.rb
CHANGED
@@ -9,7 +9,7 @@ class ElasticDynamoDb::Cli < Thor
|
|
9
9
|
include Thor::Actions
|
10
10
|
default_task :onDemand
|
11
11
|
attr_accessor :restore_in_progress, :backup_folder, :config_file_name, :original_config_file, :config, :ddb,
|
12
|
-
:log_file
|
12
|
+
:log_file, :automated_reason
|
13
13
|
|
14
14
|
desc "onDemand", "Ease autoscale by schedule or scale factor"
|
15
15
|
class_option :factor, :type => :numeric, :banner => 'scale factor can be decimal too 0.5 for instance'
|
@@ -20,12 +20,20 @@ class ElasticDynamoDb::Cli < Thor
|
|
20
20
|
class_option :schedule_restore, :type => :numeric, :default => 0, :banner => 'number of minutes for ElasticDynamoDb to restore original values'
|
21
21
|
class_option :timestamp, :default => Time.now.utc.strftime("%m%d%Y-%H%M%S")
|
22
22
|
class_option :local, :type => :boolean, :default => false, :desc => 'run on DynamoDBLocal'
|
23
|
+
class_option :start_timer, :type => :numeric, :desc => 'when to start the upscale automatically! value in minutes'
|
23
24
|
def onDemand
|
24
25
|
raise Thor::RequiredArgumentMissingError, 'You must supply a scale factor' if options[:factor].nil?
|
25
26
|
raise Thor::RequiredArgumentMissingError, 'You must supply the path to the dynamic-dyanmodb config file' if options[:config_file].nil?
|
26
27
|
init
|
27
28
|
aws_init
|
28
29
|
|
30
|
+
if options[:start_timer]
|
31
|
+
say "Auto pilot will start in #{options[:start_timer]} minutes (#{Time.now + options[:start_timer] * 60})"
|
32
|
+
self.automated_reason = ask("\nType the reason for the change: ", color = :magenta)
|
33
|
+
say "Waiting here for #{options[:start_timer]} minutes to start fully automated"
|
34
|
+
sleep options[:start_timer] * 60
|
35
|
+
end
|
36
|
+
|
29
37
|
process_config(options[:config_file], options[:factor])
|
30
38
|
|
31
39
|
if options[:schedule_restore] > 0 && !restore_in_progress
|
@@ -131,7 +139,7 @@ private
|
|
131
139
|
say("------------------------------------------------")
|
132
140
|
end
|
133
141
|
else
|
134
|
-
say("Need a factor to scale by,(i.e scale --factor 2)", color
|
142
|
+
say("Need a factor to scale by,(i.e scale --factor 2)", color = :green)
|
135
143
|
exit
|
136
144
|
end
|
137
145
|
end
|
@@ -143,11 +151,15 @@ private
|
|
143
151
|
restore = "Backup will be save to #{self.original_config_file}"
|
144
152
|
end
|
145
153
|
|
146
|
-
if self.restore_in_progress
|
154
|
+
if self.restore_in_progress
|
147
155
|
confirmed = true
|
148
156
|
else
|
149
157
|
say "#{restore}", color = :white
|
150
|
-
|
158
|
+
if options[:start_timer]
|
159
|
+
confirmed = true
|
160
|
+
else
|
161
|
+
confirmed = yes?("Overwrite the new config file? (yes/no)", color = :white)
|
162
|
+
end
|
151
163
|
end
|
152
164
|
|
153
165
|
if confirmed
|
@@ -171,7 +183,11 @@ private
|
|
171
183
|
save_file(str_to_write)
|
172
184
|
|
173
185
|
if !self.restore_in_progress
|
174
|
-
|
186
|
+
if options[:start_timer]
|
187
|
+
reason = self.automated_reason
|
188
|
+
else
|
189
|
+
reason = ask("\nType the reason for the change: ", color = :magenta)
|
190
|
+
end
|
175
191
|
else
|
176
192
|
reason = "Auto restore to #{self.original_config_file}"
|
177
193
|
end
|
@@ -180,7 +196,7 @@ private
|
|
180
196
|
|
181
197
|
say("New config changes commited to file")
|
182
198
|
else
|
183
|
-
say("Not doing antything - Goodbye...", color
|
199
|
+
say("Not doing antything - Goodbye...", color = :green)
|
184
200
|
exit
|
185
201
|
end
|
186
202
|
end
|
@@ -209,7 +225,11 @@ private
|
|
209
225
|
if self.restore_in_progress
|
210
226
|
confirmed = true
|
211
227
|
else
|
212
|
-
|
228
|
+
if options[:start_timer]
|
229
|
+
confirmed = true
|
230
|
+
else
|
231
|
+
confirmed = yes?("\nUpdate all tables with these values on DynamoDb? (yes/no)", color = :white)
|
232
|
+
end
|
213
233
|
end
|
214
234
|
|
215
235
|
if confirmed
|
@@ -234,28 +254,28 @@ private
|
|
234
254
|
end
|
235
255
|
acc
|
236
256
|
}
|
257
|
+
|
237
258
|
log_changes("Update AWS via api call with the following data:\n #{provisioning}\n")
|
259
|
+
|
238
260
|
say "\nWill update: #{provisioning.keys.size} tables\n\n\n", color = :blue
|
261
|
+
|
239
262
|
update_tables(provisioning)
|
240
263
|
else
|
264
|
+
|
241
265
|
if self.restore_in_progress
|
242
266
|
confirmed = true
|
243
267
|
end
|
244
268
|
|
245
|
-
if options[:start_cmd]
|
269
|
+
if options[:start_timer] && options[:start_cmd]
|
270
|
+
confirmed = true
|
271
|
+
elsif options[:start_cmd] && !options[:start_timer]
|
246
272
|
confirmed = yes?("Send the start command #{options[:start_cmd]} ? (yes/no)")
|
247
273
|
end
|
248
274
|
|
249
275
|
if confirmed
|
250
|
-
|
251
|
-
if options[:start_cmd]
|
252
|
-
say "Starting up dynamic-dynamodb service using the command #{options[:start_cmd]}", color = :white
|
253
|
-
system(options[:start_cmd])
|
254
|
-
end
|
255
|
-
rescue Exception => e
|
256
|
-
say "Error trying the start command: #{e.message}", color = :red
|
257
|
-
end
|
276
|
+
process_ctrl('Starting', options[:start_cmd])
|
258
277
|
end
|
278
|
+
|
259
279
|
exit
|
260
280
|
end
|
261
281
|
end
|