Class: HibernateCli

Inherits:
Object
  • Object
show all
Defined in:
lib/hibernate/hibernate_cli.rb

Class Method Summary collapse

Class Method Details

.create_ec2_rule_command(options) ⇒ Object



23
24
25
26
27
# File 'lib/hibernate/hibernate_cli.rb', line 23

def self.create_ec2_rule_command(options)
  validate_options(options, i[instance_name], 'create')
  ec2_manager = EC2Manager.new(options[:instance_name])
  ec2_manager.create_event_rule(options[:start], options[:stop])
end

.create_lambda_functionObject



6
7
8
# File 'lib/hibernate/hibernate_cli.rb', line 6

def self.create_lambda_function
  LambdaSetup.new.run
end

.handle_rule_subcommand(subcmd, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hibernate/hibernate_cli.rb', line 10

def self.handle_rule_subcommand(subcmd, options)
  case subcmd
  when 'create'
    create_ec2_rule_command(options)
  when 'list'
    list_ec2_rule_command(options)
  when 'update'
    update_ec2_rule_command(options)
  when 'remove'
    remove_ec2_rule_command(options)
  end
end

.list_ec2_rule_command(options) ⇒ Object



29
30
31
32
# File 'lib/hibernate/hibernate_cli.rb', line 29

def self.list_ec2_rule_command(options)
  ec2_manager = EC2Manager.new(options[:instance_name])
  ec2_manager.list_event_rules(options)
end

.remove_ec2_rule_command(options) ⇒ Object



45
46
47
48
49
# File 'lib/hibernate/hibernate_cli.rb', line 45

def self.remove_ec2_rule_command(options)
  validate_options(options, [:rule], 'remove')
  ec2_manager = EC2Manager.new(options[:instance_name])
  ec2_manager.remove_event_rule(options[:rule])
end

.setup_profile(profile) ⇒ Object



2
3
4
# File 'lib/hibernate/hibernate_cli.rb', line 2

def self.setup_profile(profile)
  ENV['AWS_PROFILE'] = profile
end

.update_ec2_rule_command(options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/hibernate/hibernate_cli.rb', line 34

def self.update_ec2_rule_command(options)
  validate_options(options, i[rule], 'update')
  ec2_manager = EC2Manager.new(options[:instance_name])
  ec2_manager.update_event_rule(
    rule_name: options[:rule],
    start_cron: options[:start],
    stop_cron: options[:stop],
    state: options[:state]
  )
end