Nicely handles missing templates path (fixes GH-139)

This commit is contained in:
Fabio Rehm 2013-09-28 02:58:38 -03:00
parent c76df6358c
commit 18bb9482d5
4 changed files with 15 additions and 3 deletions

View file

@ -9,6 +9,7 @@ BUG FIXES:
- Fix various issues related to detecting whether the container is running
and is "SSHable" [#142](https://github.com/fgrehm/vagrant-lxc/issues/142)
- Nicely handle missing templates path [#139](https://github.com/fgrehm/vagrant-lxc/issues/139)
## [0.6.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.5.0...v0.6.0) (Sep 12, 2013)

View file

@ -156,7 +156,9 @@ module Vagrant
yield template_name
ensure
@logger.info 'Removing LXC template'
@sudo_wrapper.run('rm', tmp_template_path)
if tmp_template_path
@sudo_wrapper.run('rm', tmp_template_path)
end
end
TEMPLATES_PATH_LOOKUP = %w(
@ -169,8 +171,9 @@ module Vagrant
return @templates_path if @templates_path
path = TEMPLATES_PATH_LOOKUP.find { |candidate| File.directory?(candidate) }
# TODO: Raise an user friendly error
raise 'Unable to identify lxc templates path!' unless path
if !path
raise Errors::TemplatesDirMissing.new paths: TEMPLATES_PATH_LOOKUP.inspect
end
@templates_path = Pathname(path)
end

View file

@ -15,6 +15,9 @@ module Vagrant
class TemplateFileMissing < Vagrant::Errors::VagrantError
error_key(:lxc_template_file_missing)
end
class TemplatesDirMissing < Vagrant::Errors::VagrantError
error_key(:lxc_templates_dir_missing)
end
class RootFSTarballMissing < Vagrant::Errors::VagrantError
error_key(:lxc_invalid_box_version)
end

View file

@ -46,6 +46,11 @@ en:
The template file used for creating the container was not found for %{name}
box.
lxc_templates_dir_missing: |-
Unable to identify lxc templates path.
Looked up under: %{paths}
lxc_not_installed: |-
The `lxc` package does not seem to be installed or is not accessible on the PATH.