You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
940 B
34 lines
940 B
module Vagrant
|
|
module Lxd
|
|
module Action
|
|
class EnsureImage
|
|
def initialize(app, env)
|
|
@app = app
|
|
@logger = Log4r::Logger.new("vagrant::lxd::action::ensure_image")
|
|
end
|
|
|
|
def call(env)
|
|
box = env[:machine].box
|
|
driver = env[:machine].provider.driver
|
|
|
|
env[:ui].info "--- check image for #{env[:machine].name} ---",
|
|
:prefix => false
|
|
if driver.image?
|
|
env[:ui].info "--- Image found ---", :prefix => false
|
|
else
|
|
env[:ui].info "--- Image NOT found (downloading) ---",
|
|
:prefix => false
|
|
driver.get_image("images")
|
|
env[:ui].info "--- Image download done ---", :prefix => false
|
|
# TODO maybe we need to check again if the image really exists
|
|
# now.
|
|
end
|
|
|
|
@app.call(env)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
# vim: set et ts=2 sw=2:
|