From dcc0ce281f7e8465fcf77be250847e78d79c0661 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 8 Jun 2013 01:13:51 -0300 Subject: [PATCH] Lets be clear about box version error --- lib/vagrant-lxc/action/handle_box_metadata.rb | 7 +++++-- lib/vagrant-lxc/errors.rb | 4 ++-- locales/en.yml | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-lxc/action/handle_box_metadata.rb b/lib/vagrant-lxc/action/handle_box_metadata.rb index 91fbd13..73ceeb8 100644 --- a/lib/vagrant-lxc/action/handle_box_metadata.rb +++ b/lib/vagrant-lxc/action/handle_box_metadata.rb @@ -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) diff --git a/lib/vagrant-lxc/errors.rb b/lib/vagrant-lxc/errors.rb index bb056ee..169e567 100644 --- a/lib/vagrant-lxc/errors.rb +++ b/lib/vagrant-lxc/errors.rb @@ -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 diff --git a/locales/en.yml b/locales/en.yml index 1242a75..50edd3d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -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.