Class: ElasticDynamoDb::Cli

Inherits:
Thor
  • Object
show all
Includes:
CloudWatch, Thor::Actions
Defined in:
lib/elasticDynamoDb/cli.rb

Defined Under Namespace

Modules: CloudWatch

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CloudWatch

#put_metric_alarm, #set_cloudwatch_alarms, #set_default_options

Instance Attribute Details

#automated_reasonObject

Returns the value of attribute automated_reason.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def automated_reason
  @automated_reason
end

#backup_folderObject

Returns the value of attribute backup_folder.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def backup_folder
  @backup_folder
end

#configObject

Returns the value of attribute config.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def config
  @config
end

#config_file_nameObject

Returns the value of attribute config_file_name.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def config_file_name
  @config_file_name
end

#cwObject

Returns the value of attribute cw.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def cw
  @cw
end

#ddbObject

Returns the value of attribute ddb.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def ddb
  @ddb
end

#log_fileObject

Returns the value of attribute log_file.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def log_file
  @log_file
end

#original_config_fileObject

Returns the value of attribute original_config_file.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def original_config_file
  @original_config_file
end

#restore_in_progressObject

Returns the value of attribute restore_in_progress.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def restore_in_progress
  @restore_in_progress
end

#skip_cloudwatchObject

Returns the value of attribute skip_cloudwatch.



15
16
17
# File 'lib/elasticDynamoDb/cli.rb', line 15

def skip_cloudwatch
  @skip_cloudwatch
end

Instance Method Details

#onDemandObject

Raises:

  • (Thor::RequiredArgumentMissingError)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/elasticDynamoDb/cli.rb', line 28

def onDemand
  raise Thor::RequiredArgumentMissingError, 'You must supply a scale factor' if options[:factor].nil?
  raise Thor::RequiredArgumentMissingError, 'You must supply the path to the dynamic-dyanmodb config file' if options[:config_file].nil?
  init
  aws_init

  if options[:start_timer]
    say "Auto pilot will start in #{options[:start_timer]} minutes (#{Time.now + options[:start_timer] * 60})"
    self.automated_reason = ask("\nType the reason for the change: ", color = :magenta)
    say "Waiting here for #{options[:start_timer]} minutes to start fully automated"
    sleep options[:start_timer] * 60
  end
  
  process_config(options[:config_file], options[:factor])    
  
  if options[:schedule_restore] > 0 && !restore_in_progress
    say("#{Time.now} - Waiting here for #{options[:schedule_restore]} minutes until restore")
    sleep options[:schedule_restore] * 60
    
    self.restore_in_progress = true
    say "#{Time.now} - Restoring to original config file (#{self.original_config_file})"
    process_config(self.original_config_file, 1)
  end
  
  unless options[:start_cmd] || options[:stop_cmd]  
    say "All done! you may restart the dynamic-dynamodb process manually", color = :white
  end
end

#versionObject



59
60
61
# File 'lib/elasticDynamoDb/cli.rb', line 59

def version
  say ElasticDynamoDb::ABOUT
end