Class: Kontena::Plugin::Vagrant::Master::CreateCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common
Defined in:
lib/kontena/plugin/vagrant/master/create_command.rb

Instance Method Summary collapse

Instance Method Details

#ask_instance_memoryObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kontena/plugin/vagrant/master/create_command.rb', line 31

def ask_instance_memory
  if self.memory.nil?
    prompt.select("Choose a size") do |menu|
      %w(512 1024 2048).each do |mem|
        menu.choice "#{mem}MB", mem
      end
    end
  else
    self.memory
  end
end

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kontena/plugin/vagrant/master/create_command.rb', line 17

def execute
  require_relative '../../../machine/vagrant'
  mem = ask_instance_memory
  provisioner.run!(
    name: name,
    memory: mem,
    version: version,
    vault_secret: vault_secret || SecureRandom.hex(24),
    vault_iv: vault_iv || SecureRandom.hex(24),
    initial_admin_code: SecureRandom.hex(16),
    coreos_channel: coreos_channel
  )
end

#provisionerObject



43
44
45
# File 'lib/kontena/plugin/vagrant/master/create_command.rb', line 43

def provisioner
  Kontena::Machine::Vagrant::MasterProvisioner.new
end