Class: VagrantPlugins::ProviderKvm::Action::Resume

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-kvm/action/resume.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Resume

Returns a new instance of Resume.



5
6
7
# File 'lib/vagrant-kvm/action/resume.rb', line 5

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-kvm/action/resume.rb', line 9

def call(env)
  current_state = env[:machine].provider.state.id

  if current_state == :paused
    env[:ui].info I18n.t("vagrant.actions.vm.resume.unpausing")
    env[:machine].provider.driver.resume
  elsif current_state == :saved
    env[:ui].info I18n.t("vagrant.actions.vm.resume.resuming")
    env[:action_runner].run(Boot, env)
  end

  @app.call(env)
end