Class: VagrantPlugins::Deltacloud::Action::Suspend

Inherits:
AbstractAction show all
Defined in:
lib/vagrant-deltacloud-provider/action/suspend.rb

Instance Method Summary collapse

Methods inherited from AbstractAction

#call

Constructor Details

#initialize(app, _env) ⇒ Suspend

Returns a new instance of Suspend.



8
9
10
11
# File 'lib/vagrant-deltacloud-provider/action/suspend.rb', line 8

def initialize(app, _env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_deltacloud::action::suspend_server')
end

Instance Method Details

#execute(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-deltacloud-provider/action/suspend.rb', line 13

def execute(env)
  env[:deltacloud_client] = Deltacloud::DeltacloudClient.instance
  if env[:machine].id
    @logger.info "Saving VM #{env[:machine].id} state and suspending execution..."
    env[:ui].info I18n.t('vagrant.actions.vm.suspend.suspending')
    env[:deltacloud_client].stop_instance(env, env[:machine].id)
  end

  @app.call(env)
end