Class: SimplePerf::CLI::CreateGatling

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/simple_perf/cli/create_gatling.rb

Instance Method Summary collapse

Methods included from Shared

pretty_print

Instance Method Details

#executeObject



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
50
51
# File 'lib/simple_perf/cli/create_gatling.rb', line 8

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

Creates CloudFormation stack for Gatling instances.

Usage:
simple_perf create_gatling -e ENVIRONMENT -p PROJECT_NAME -a AMI -i INSTANCE_TYPE -s S3_BUCKET -c COUNT
EOS
    opt :help, "Display Help"
    opt :environment, "Set the target environment", :type => :string
    opt :project, "Project name to manage", :type => :string
    opt :ami, "AWS ami", :type => :string
    opt :instancetype, "AWS instance type", :type => :string
    opt :s3bucket, "AWS s3 bucket", :type => :string
    opt :count, "Number of Gatling instances", :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]
  Trollop::die :ami, "is required but not specified" unless opts[:ami]
  Trollop::die :instancetype, "is required but not specified" unless opts[:instancetype]
  Trollop::die :s3bucket, "is required but not specified" unless opts[:s3bucket]
  Trollop::die :count, "is required but not specified" unless opts[:count]

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

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

  command = 'simple_deploy create' +
      ' -e ' + opts[:environment] +
      ' -n ' + 'simple-perf-' + opts[:project] +
      ' -t '+ gem_root + '/cloud_formation_templates/instance_group_gatling.json' +
      ' -a Description="EC2 Gatling Instance"' +
      ' -a KeyName=' +  config['aws_keypair'] +
      ' -a AmiId=' +  opts[:ami] +
      ' -a S3BucketName=' + opts[:s3bucket] +
      ' -a InstanceType=' + opts[:instancetype] +
      ' -a MinimumInstances=' + opts[:count] +
      ' -a MaximumInstances=' + opts[:count] +
      ' -a Abort=no'

  Shared::pretty_print `#{command}`
end