Class: VagrantPlugins::Kubevirt::Action::StopVM
- Inherits:
-
Object
- Object
- VagrantPlugins::Kubevirt::Action::StopVM
- Defined in:
- lib/vagrant-kubevirt/action/stop_vm.rb
Overview
This stops the running instance.
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.
9 10 11 12 |
# File 'lib/vagrant-kubevirt/action/stop_vm.rb', line 9 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_kubevirt::action::stop_vm") end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vagrant-kubevirt/action/stop_vm.rb', line 14 def call(env) begin kubevirt = env[:kubevirt_compute] vm = kubevirt.vms.get(env[:machine].id.to_s) if vm == nil raise Errors::NoVMError, :vm_name => env[:domain_name] end if vm.status == :stopped env[:ui].info(I18n.t("vagrant_kubevirt.already_status", :status => env[:machine].state.id)) else env[:ui].info(I18n.t("vagrant_kubevirt.stopping")) vm.stop end rescue Fog::Errors::Error => e raise Errors::StopVMError, :message => e. end @app.call(env) end |