Class: VagrantPlugins::Proxmox::Action::StopVm
- Inherits:
-
ProxmoxAction
- Object
- ProxmoxAction
- VagrantPlugins::Proxmox::Action::StopVm
- Defined in:
- lib/vagrant-proxmox/action/stop_vm.rb
Overview
This action stops the Proxmox virtual machine in env
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ StopVm
constructor
A new instance of StopVm.
Constructor Details
#initialize(app, env) ⇒ StopVm
Returns a new instance of StopVm.
8 9 10 11 |
# File 'lib/vagrant-proxmox/action/stop_vm.rb', line 8 def initialize app, env @app = app @logger = Log4r::Logger.new 'vagrant_proxmox::action::stop_vm' end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-proxmox/action/stop_vm.rb', line 13 def call env begin node, vm_id = env[:machine].id.split '/' env[:ui].info I18n.t('vagrant_proxmox.stopping_vm') exit_status = connection(env).stop_vm vm_id exit_status == 'OK' ? exit_status : raise(VagrantPlugins::Proxmox::Errors::ProxmoxTaskFailed, proxmox_exit_status: exit_status) rescue StandardError => e raise VagrantPlugins::Proxmox::Errors::VMStopError, proxmox_exit_status: e. end env[:ui].info I18n.t('vagrant_proxmox.done') next_action env end |