Sha256: 209d9b4f1b51dab6ed4e5bad8dbb932a3dd58cd8f95238cac5b1d0c9b511b37a

Contents?: true

Size: 752 Bytes

Versions: 3

Compression:

Stored size: 752 Bytes

Contents

require 'vagrant-conoha/action/abstract_action'

module VagrantPlugins
  module ConoHa
    module Action
      class SnapshotRestore < AbstractAction
        def initialize(app, _env)
          @app = app
        end

        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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 lib/vagrant-conoha/action/snapshot_restore.rb
vagrant-conoha-0.1.9 lib/vagrant-conoha/action/snapshot_restore.rb
vagrant-conoha-0.1.8 lib/vagrant-conoha/action/snapshot_restore.rb