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

View file

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

View file

@ -33,6 +33,10 @@ en:
For more information on the failure, enable detailed logging by setting For more information on the failure, enable detailed logging by setting
the environment variable VAGRANT_LOG to DEBUG. 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: |- lxc_template_file_missing: |-
The template file used for creating the container was not found for %{name} The template file used for creating the container was not found for %{name}
box. box.