Lets be clear about box version error

This commit is contained in:
Fabio Rehm 2013-06-08 01:13:51 -03:00
parent b8d58d8a13
commit dcc0ce281f
3 changed files with 11 additions and 4 deletions

View file

@ -3,6 +3,7 @@ module Vagrant
module Action
# Prepare arguments to be used for lxc-create
class HandleBoxMetadata
SUPPORTED_VERSIONS = [2, 3]
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::lxc::action::handle_box_metadata")
@ -51,8 +52,10 @@ module Vagrant
end
def validate_box
if [2, 3].include? @box.metadata.fetch('version').to_i
raise Errors::InvalidBoxVersion.new name: @box.name
unless SUPPORTED_VERSIONS.include? @box.metadata.fetch('version').to_i
raise Errors::IncompatibleBox.new name: @box.name,
found: @box.metadata.fetch('version').to_i,
supported: SUPPORTED_VERSIONS.join(' and ')
end
unless File.exists?(template_src)

View file

@ -14,8 +14,8 @@ module Vagrant
class RootFSTarballMissing < Vagrant::Errors::VagrantError
error_key(:lxc_invalid_box_version)
end
class InvalidBoxVersion < Vagrant::Errors::VagrantError
error_key(:lxc_invalid_box_version)
class IncompatibleBox < Vagrant::Errors::VagrantError
error_key(:lxc_incompatible_box)
end
end
end

View file

@ -33,6 +33,10 @@ en:
For more information on the failure, enable detailed logging by setting
the environment variable VAGRANT_LOG to DEBUG.
lxc_incompatible_box: |-
The base box you are trying to use is not compatible with the installed
vagrant-lxc version. Supported box versions are %{supported} but %{found} was found.
lxc_template_file_missing: |-
The template file used for creating the container was not found for %{name}
box.