Sha256: ed7cbad64c18aa772c2a2a9a649effc12b79daa4b2031933d1808537b97e2b28
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require "fog/profitbricks" require "log4r" require 'vagrant/util/retryable' module VagrantPlugins module ProfitBricks module Action # Creates an Image class CreateImage include Vagrant::Util::Retryable attr_reader :env def initialize(app, env) @app, @env = app, env end def call(env) env[:ui].info(I18n.t("vagrant_profitbricks.creating_image")) server = env[:profitbricks_compute].servers.get(env[:machine].id) config = env[:machine].provider_config image_name = config.server_name || env[:machine].name image = server.create_image(image_name) retryable(:on => Fog::Errors::TimeoutError, :tries => 200) do # If we're interrupted don't worry about waiting next if env[:interrupted] env[:ui].clear_line env[:ui].report_progress(image.progress, 100, false) begin image.wait_for(5) { ready? } rescue RuntimeError => e # If we don't have an error about a state transition, then # we just move on. raise if e.message !~ /should have transitioned/ raise Errors::CreateBadState, :state => server.state end end env[:ui].info(I18n.t("vagrant_profitbricks.image_ready")) @app.call(env) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-profitbricks-1.0.0 | lib/vagrant-profitbricks/action/create_image.rb |