Module: VagrantVbguest::Helpers::Rebootable

Included in:
CommandCommons, Middleware
Defined in:
lib/vagrant-vbguest/helpers.rb

Constant Summary collapse

@@rebooted =
{}

Instance Method Summary collapse

Instance Method Details

#reboot(vm, options) ⇒ Object



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

def reboot(vm, options)
  run_reboot = if rebooted?(vm)
    vm.env.ui.error(I18n.t("vagrant.plugins.vbguest.restart_loop_guard_activated"))
    false
  elsif options[:auto_reboot]
    vm.env.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
    @@rebooted[ VmCompatible.vm_id(vm) ] = true
  else
    vm.env.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => vm.name))
    false
  end
  return unless run_reboot

  if Vagrant::VERSION < '1.1.0'
    vm.reload(options)
  else
    vm.action(:reload, options)
  end
end

#rebooted?(vm) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/vagrant-vbguest/helpers.rb', line 7

def rebooted?(vm)
  !!@@rebooted[ VmCompatible.vm_id(vm) ]
end