elasticDynamoDb 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bff72ed568398542c09761c32d3150a52f4cb15
4
- data.tar.gz: 107bf653d4a6e1e6b7d3e2bd7d5af4212f795d3a
3
+ metadata.gz: 339c4f206bd73da9fdd595f61aa53fbfe8e52064
4
+ data.tar.gz: ee1a49ee9881e9df6a8e03ae11ea1649fe371602
5
5
  SHA512:
6
- metadata.gz: 966408d598308dceb8ed0bd75f38b8841249a1b04cecd46539b78cc8191b23622ff2e10dd52735d75bfd3d433834d657e3d29fe28a3c15ecdf29ef4e1a55b1cd
7
- data.tar.gz: 4a51b001649f9e23eafd72556ad5b75b03306d65a5c0e5a89bf6367e8600fa542676a0923ecee2f1bc278c69420a6f781e2235a7db0e5dd34087b7ec285b0950
6
+ metadata.gz: 39f710fe5cf67fb2ba37a68defa3e495e8783f14b3a36738a9088856eafa0df7bc94545385db4b11d1e75277546efda7a7e0287eaaa88fe5fc3203ec5bf9125c
7
+ data.tar.gz: 4d4be8515e9846d0a8e2ed2eff0daabc5f34dedce73ded5c23821f16d683bad5d7e79700192ebc6456ad636cc0f959edc163615e927c7641f35476e411b75baf
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.4.0
2
+ -----
3
+
4
+ * add start_timer option to auto pilot and start in a future time
5
+
1
6
  1.3.0
2
7
  -----
3
8
 
@@ -1,5 +1,5 @@
1
1
  module ElasticDynamoDb
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  ABOUT = "ElasticDynamoDb v#{VERSION} (c) #{Time.now.strftime("2014-%Y")} @innovia"
4
4
 
5
5
  autoload :Cli, 'elasticDynamoDb/cli'
@@ -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=:green)
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
- confirmed = yes?("Overwrite the new config file? (yes/no)", color=:white)
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
- reason = ask("\nType the reason for the change: ", color=:magenta)
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=:green)
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
- confirmed = yes?("\nUpdate all tables with these values on DynamoDb? (yes/no)", color=:white)
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
- begin
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticDynamoDb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ami Mahloof