Sha256: 4085b44d095f6311c02e660eddf749eee081e572cc7d38de32fafa425792f69e

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require "log4r"

module VagrantPlugins
  module Vmpooler
    module Action
      # This reboots a running server, if there is one.
      class TakeSnapshot
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_vmpooler::action::take_snapshot")
        end

        def call(env)
          if env[:machine].id
            env[:ui].info(I18n.t("vagrant_vmpooler.snapshoting_server"))
            # make api call to snapshot server
            provider_config = env[:machine].provider_config

            token = provider_config.token
            url = provider_config.url
            verbose = provider_config.verbose
            hostname = env[:machine].id
            response = Pooler.snapshot(verbose, url, hostname, token)
            if response['ok'] == false
              env[:ui].info(I81n.t("vagrant_vmpooler.errors.failed_snapshot"))
              env[:ui].info(response)
            end
          end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-vmpooler-0.1.6 lib/vagrant-vmpooler/action/take_snapshot.rb
vagrant-vmpooler-0.1.5 lib/vagrant-vmpooler/action/take_snapshot.rb
vagrant-vmpooler-0.1.4 lib/vagrant-vmpooler/action/take_snapshot.rb
vagrant-vmpooler-0.1.2 lib/vagrant-vmpooler/action/take_snapshot.rb