Class: Kontena::Plugin::Upcloud::Nodes::CreateCommand

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

Instance Method Summary collapse

Methods included from Prompts::Create

included, #ssh_key

Instance Method Details

#default_countObject



42
43
44
# File 'lib/kontena/plugin/upcloud/nodes/create_command.rb', line 42

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

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kontena/plugin/upcloud/nodes/create_command.rb', line 16

def execute

  abort_unless_api_access

  require 'kontena/machine/upcloud'
  grid = fetch_grid
  provisioner = Kontena::Machine::Upcloud::NodeProvisioner.new(client, username, password)
  provisioner.run!(
    master_uri: api_url,
    grid_token: grid['token'],
    grid: current_grid,
    ssh_key: ssh_key,
    count: count,
    name: name,
    plan: plan,
    zone: zone,
    version: version
  )
end

#fetch_gridHash

Parameters:

  • id (String)

Returns:

  • (Hash)


38
39
40
# File 'lib/kontena/plugin/upcloud/nodes/create_command.rb', line 38

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