Class: Rivet::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rivet/client.rb

Instance Method Summary collapse

Instance Method Details

#run(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rivet/client.rb', line 5

def run(options)
  AwsUtils.set_aws_credentials options.profile
  Rivet::Log.level options.log_level

  Rivet::Log.info "Using autoscale config path #{options.config_path}"

  unless Dir.exists?(options.config_path)
    Rivet::Utils.die 'The autoscale config path does not exist'
  end

  # Get config object for autoscaling group
  config = Rivet::Utils.get_config(
    options.group,
    options.config_path)

  unless config
    Rivet::Utils.list_groups(options.config_path)
    Rivet::Utils.die "The #{options.group} autoscale definition doesn't exist"
  end

  config.validate

  config = ConfigProxy.new(config)

  Rivet::Log.info "Checking #{options.group} autoscaling definition"

  autoscale_group = Rivet::Autoscale.new(config)
  autoscale_group.show_differences

  if options.sync
    autoscale_group.sync
  else
    Rivet::Log.info 'use the -s [--sync] flag to sync changes'
  end
end