Class: VagrantPlugins::OVirtProvider::Action::StartVM

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ovirt/action/start_vm.rb

Overview

Just start the VM.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ StartVM

Returns a new instance of StartVM.



10
11
12
13
# File 'lib/vagrant-ovirt/action/start_vm.rb', line 10

def initialize(app, env)
  @logger = Log4r::Logger.new("vagrant_ovirt::action::start_vm")
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-ovirt/action/start_vm.rb', line 15

def call(env)
  env[:ui].info(I18n.t("vagrant_ovirt.starting_vm"))

  machine = env[:ovirt_compute].servers.get(env[:machine].id.to_s)
  if machine == nil
    raise Errors::NoVMError,
      :vm_name => env[:machine].id.to_s
  end

  # Start VM.
  begin
    machine.start
  rescue OVIRT::OvirtException => e
    raise Errors::StartVMError,
      :error_message => e.message
  end

  @app.call(env)
end