class VagrantPlugins::Openstack::Action::SnapshotRestore

Public Class Methods

new(app, _env) click to toggle source
# File lib/vagrant-openstack-provider/action/snapshot_restore.rb, line 7
def initialize(app, _env)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/vagrant-openstack-provider/action/snapshot_restore.rb, line 11
def call(env)
  nova = env[:openstack_client].nova
  machine_snapshots = nova.list_snapshots(env, env[:machine].id)

  snapshot = machine_snapshots.find { |s| s.name == env[:snapshot_name] }

  unless snapshot.nil?
    env[:ui].info(I18n.t('vagrant.actions.vm.snapshot.restoring',
                         name: snapshot.name))

    nova.restore_snapshot(env, env[:machine].id, snapshot.id)
  end

  @app.call env
end