Class: Chef::Knife::VagrantServerUp

Inherits:
Chef::Knife show all
Includes:
VagrantBase
Defined in:
lib/chef/knife/vagrant_server_up.rb

Instance Method Summary collapse

Methods included from VagrantBase

#colored_vagrant_state, included, #locate_config_value, #msg_pair, #vagrant_exec, #vagrant_instance_list, #vagrant_instance_state, #vagrant_version, #vagrant_version_cmp, #write_insecure_key

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/chef/knife/vagrant_server_up.rb', line 11

def run
  $stdout.sync = true

  @name_args.each do |instance|
    unless vagrant_instance_list.detect { |i| i[:name] == instance }
      ui.error("No instance named #{instance}")
      next            
    end

    state, provider = vagrant_instance_state(instance)

    unless state == 'poweroff'
      ui.error("Instance #{instance} needs to be powered off for up. Current state is #{colored_vagrant_state(state)}")
      next
    end

    vagrant_exec(instance, 'up')
  end
end