class VagrantPlugins::OVirtProvider::Action::StartVM

Just start the VM.

Public Class Methods

new(app, env) click to toggle source
# File lib/vagrant-ovirt3/action/start_vm.rb, line 10
def initialize(app, env)
  @logger = Log4r::Logger.new("vagrant_ovirt::action::start_vm")
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/vagrant-ovirt3/action/start_vm.rb, line 15
def call(env)
  env[:ui].info(I18n.t("vagrant_ovirt3.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