Sha256: de1f52e57dab8480d9a8193262bad40f5dd7d84a6d4f7fe79ff64e593278f2a8

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

require 'vagrant-openstack-illuin-provider/action/abstract_action'

module VagrantPlugins
  module Openstack
    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

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-openstack-illuin-provider-0.12.0 lib/vagrant-openstack-illuin-provider/action/snapshot_restore.rb