Class: Kontena::Plugin::Aws::Nodes::CreateCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common, Cli::GridOptions, Prompts, Prompts::Common
Defined in:
lib/kontena/plugin/aws/nodes/create_command.rb

Instance Method Summary collapse

Methods included from Prompts::Common

included

Methods included from Prompts

#ask_node, #aws_client, #resolve_region

Instance Method Details

#default_countObject



60
61
62
# File 'lib/kontena/plugin/aws/nodes/create_command.rb', line 60

def default_count
  prompt.ask('How many instances?: ', default: 1)
end

#executeObject



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
# File 'lib/kontena/plugin/aws/nodes/create_command.rb', line 18

def execute
  require_current_grid
  require_relative '../../../machine/aws'

  grid = fetch_grid(current_grid)
  provisioner.run!(
    master_uri: api_url,
    grid_token: grid['token'],
    grid: current_grid,
    name: name,
    type: type,
    vpc: vpc_id,
    zone: zone,
    subnet: subnet_id,
    storage: storage,
    version: version,
    key_pair: key_pair,
    count: count,
    associate_public_ip: associate_public_ip?,
    security_groups: security_groups,
    ami: ami
  )
rescue Seahorse::Client::NetworkingError => ex
  raise ex unless ex.message.match(/certificate verify failed/)
  exit_with_error Kontena::Machine::Aws.ssl_fail_message(aws_bundled_cert?)
end

#fetch_grid(id) ⇒ Hash

Parameters:

  • id (String)

Returns:

  • (Hash)


47
48
49
# File 'lib/kontena/plugin/aws/nodes/create_command.rb', line 47

def fetch_grid(id)
  client.get("grids/#{id}")
end

#provisionerKontena::Machine::Aws::NodeProvisioner

Parameters:

  • client (Kontena::Client)
  • access_key (String)
  • secret_key (String)
  • region (String)

Returns:



56
57
58
# File 'lib/kontena/plugin/aws/nodes/create_command.rb', line 56

def provisioner
  Kontena::Machine::Aws::NodeProvisioner.new(client, access_key, secret_key, region)
end