Class: CloudSpec::AMZN_CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/cloudspec/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.shared_optionsObject



7
8
9
10
11
12
# File 'lib/cloudspec/cli.rb', line 7

def self.shared_options
  method_option :mock, type: :boolean, desc: 'Mock all cloud calls', aliases: '-m'
  method_option :dry_run, type: :boolean, desc: 'Non-destructive run', aliases: '-d'
  method_option :yaml, type: :string, required: true, aliases: '-y', desc: 'The path to the clould credentials yaml file'
  method_option :rules, type: :string, required: true, aliases: '-r', desc: 'The path to the rules'
end

Instance Method Details

#allObject



27
28
29
30
31
32
33
34
35
# File 'lib/cloudspec/cli.rb', line 27

def all
  validate

  invoke :instances
  invoke :groups
rescue => e
  CloudSpec.log.error e.to_s
  exit 1
end

#groupsObject



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cloudspec/cli.rb', line 53

def groups
  validate

  groups = CloudSpec::AMZN::SecurityGroups.new
  CloudSpec.log.info 'Beginning group harvest ...'
  groups.harvest
  CloudSpec.log.info 'Group harvest complete.'
rescue => e
  CloudSpec.log.error e.to_s
  exit 1
end

#instancesObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cloudspec/cli.rb', line 39

def instances
  validate

  instances = CloudSpec::AMZN::Instances.new
  CloudSpec.log.info 'Beginning instance harvest ...'
  instances.harvest
  CloudSpec.log.info 'Instance harvest complete.'
rescue => e
  CloudSpec.log.error e.to_s
  exit 1
end