Class: SimplePerf::CLI::CreateBucket

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_perf/cli/create_bucket.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



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
40
41
42
43
44
45
46
47
48
49
# File 'lib/simple_perf/cli/create_bucket.rb', line 6

def execute
  opts = Trollop::options do
    version SimplePerf::VERSION
    banner <<-EOS

Creates CloudFormation stack for s3 bucket.

Usage:
simple_perf create_bucket -e ENVIRONMENT -p PROJECT_NAME

EOS
    opt :help, "Display Help"
    opt :environment, "Set the target environment", :type => :string
    opt :project, "Project name to manage", :type => :string
  end
  Trollop::die :environment, "is required but not specified" unless opts[:environment]
  Trollop::die :project, "is required but not specified" unless opts[:project]

  gem_root = File.expand_path '../..', __FILE__

  config = Config.new.environment opts[:environment]

  command = 'simple_deploy create' +
      ' -e ' + opts[:environment] +
      ' -n ' + 'simple-perf-' + opts[:project] + '-s3-' + config['region'] +
      ' -t '+ gem_root + '/cloud_formation_templates/s3_bucket.json'

  `#{command}`

  command = 'simple_deploy outputs' +
      ' -e ' + opts[:environment] +
      ' -n ' + 'simple-perf-' + opts[:project] + '-s3-' + config['region']

  (0..5).each do |i|
    puts "Getting s3 bucket name..."
    sleep 10
    output = `#{command}`
    if output.length > 0
      puts output
      break
    end
  end

end