Class: VagrantPlugins::Proxmox::Action::ShutdownVm
- Inherits:
-
ProxmoxAction
- Object
- ProxmoxAction
- VagrantPlugins::Proxmox::Action::ShutdownVm
- Defined in:
- lib/vagrant-proxmox/action/shutdown_vm.rb
Overview
This action shuts down the Proxmox virtual machine in env
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ShutdownVm
constructor
A new instance of ShutdownVm.
Constructor Details
#initialize(app, env) ⇒ ShutdownVm
Returns a new instance of ShutdownVm.
8 9 10 11 |
# File 'lib/vagrant-proxmox/action/shutdown_vm.rb', line 8 def initialize app, env @app = app @logger = Log4r::Logger.new 'vagrant_proxmox::action::shutdown_vm' end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vagrant-proxmox/action/shutdown_vm.rb', line 13 def call env env[:ui].info I18n.t('vagrant_proxmox.shut_down_vm') begin node, vm_id = env[:machine].id.split '/' exit_status = connection(env).shutdown_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::VMShutdownError, proxmox_exit_status: e. end env[:ui].info I18n.t('vagrant_proxmox.done') next_action env end |