Module: VagrantVbguest::Helpers::Rebootable
- Includes:
- VmCompatible
- Included in:
- Command, Middleware
- Defined in:
- lib/vagrant-vbguest/helpers/rebootable.rb
Constant Summary collapse
- @@rebooted =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #reboot(vm, options) ⇒ Object
-
#reboot!(vm, options) ⇒ Object
executes the whole reboot process.
- #reboot?(vm, options) ⇒ Boolean
- #rebooted?(vm) ⇒ Boolean
Methods included from VmCompatible
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/vagrant-vbguest/helpers/rebootable.rb', line 8 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#reboot(vm, options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vagrant-vbguest/helpers/rebootable.rb', line 31 def reboot(vm, ) if reboot? vm, simple_reboot = Vagrant::Action::Builder.new.tap do |b| b.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :poweroff, :running do |env2, b2| if !env2[:result] b2.use VagrantPlugins::ProviderVirtualBox::Action::ForcedHalt end end b.use VagrantPlugins::ProviderVirtualBox::Action::Boot if defined?(Vagrant::Action::Builtin::WaitForCommunicator) b.use Vagrant::Action::Builtin::WaitForCommunicator, [:starting, :running] end end @env[:action_runner].run(simple_reboot, @env) end end |
#reboot!(vm, options) ⇒ Object
executes the whole reboot process
49 50 51 52 53 |
# File 'lib/vagrant-vbguest/helpers/rebootable.rb', line 49 def reboot!(vm, ) if reboot? vm, vm.action(:reload, ) end end |
#reboot?(vm, options) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-vbguest/helpers/rebootable.rb', line 18 def reboot?(vm, ) if rebooted?(vm) vm.env.ui.error(I18n.t("vagrant_vbguest.restart_loop_guard_activated")) false elsif [:auto_reboot] vm.env.ui.warn(I18n.t("vagrant_vbguest.restart_vm")) @@rebooted[ self.class.vm_id(vm) ] = true else vm.env.ui.warn(I18n.t("vagrant_vbguest.suggest_restart", :name => vm.name)) false end end |
#rebooted?(vm) ⇒ Boolean
14 15 16 |
# File 'lib/vagrant-vbguest/helpers/rebootable.rb', line 14 def rebooted?(vm) !!@@rebooted[ self.class.vm_id(vm) ] end |