Error out if LXC is not installed

This is enough to close #11
This commit is contained in:
Fabio Rehm 2013-07-28 02:54:58 -03:00
parent dee099ce96
commit 97f6edeed8
6 changed files with 15 additions and 19 deletions

View file

@ -15,7 +15,7 @@ FEATURES:
IMPROVEMENTS:
- Error out if `redir` is not installed but port forwarding was configured [#112](https://github.com/fgrehm/vagrant-lxc/issues/112)
- Error out if dependencies are not installed [#11](https://github.com/fgrehm/vagrant-lxc/issues/11) / [#112](https://github.com/fgrehm/vagrant-lxc/issues/112)
- Support for specifying host interface/ip for binding `redir` [#76](https://github.com/fgrehm/vagrant-lxc/issues/76)
- Add Vagrantfile VM name to the container name [#115](https://github.com/fgrehm/vagrant-lxc/issues/115)
- Properly handle forwarded port collisions [#5](https://github.com/fgrehm/vagrant-lxc/issues/5)

View file

@ -139,14 +139,6 @@ for a list of [pre built](https://github.com/fgrehm/vagrant-lxc/wiki/Base-boxes#
base boxes and information on [how to build your own](https://github.com/fgrehm/vagrant-lxc/wiki/Base-boxes#building-your-own).
## Current limitations
* [Does not tell you if dependencies are not met](https://github.com/fgrehm/vagrant-lxc/issues/11)
(will probably just throw up some random error)
* + bunch of other [core features](https://github.com/fgrehm/vagrant-lxc/issues?labels=core&milestone=&page=1&state=open)
and some known [bugs](https://github.com/fgrehm/vagrant-lxc/issues?labels=bug&page=1&state=open)
## More information
Please refer the [wiki](https://github.com/fgrehm/vagrant-lxc/wiki) for more

View file

@ -25,7 +25,6 @@ module Vagrant
# machine back up with the new configuration.
def self.action_reload
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
if !env1[:result]
b2.use Message, :not_created
@ -44,7 +43,6 @@ module Vagrant
# a bootup (i.e. not saved).
def self.action_boot
Vagrant::Action::Builder.new.tap do |b|
# b.use ClearForwardedPorts
b.use Vagrant::Action::Builtin::Provision
b.use Vagrant::Action::Builtin::EnvSet, :port_collision_repair => true
b.use Vagrant::Action::Builtin::HandleForwardedPortCollisions
@ -58,7 +56,6 @@ module Vagrant
# This action just runs the provisioners on the machine.
def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::ConfigValidate
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
if !env1[:result]
@ -82,7 +79,6 @@ module Vagrant
# A precondition of this action is that the container exists.
def self.action_start
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::ConfigValidate
b.use Vagrant::Action::Builtin::Call, IsRunning do |env, b2|
# If the VM is running, then our work here is done, exit
@ -97,7 +93,6 @@ module Vagrant
# container, configuring metadata, and booting.
def self.action_up
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::ConfigValidate
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
# If the VM is NOT created yet, then do the setup steps
@ -115,7 +110,6 @@ module Vagrant
# the virtual machine, gracefully or by force.
def self.action_halt
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
if env[:result]
# TODO: Remove this on / after 0.4
@ -138,7 +132,6 @@ module Vagrant
# freeing the resources of the underlying virtual machine.
def self.action_destroy
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
if !env1[:result]
b2.use Message, :not_created
@ -162,7 +155,6 @@ module Vagrant
# This action packages the virtual machine into a single box file.
def self.action_package
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
if !env1[:result]
b2.use Message, :not_created
@ -180,7 +172,6 @@ module Vagrant
# This is the action that will exec into an SSH shell.
def self.action_ssh
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use CheckCreated
b.use CheckRunning
b.use Vagrant::Action::Builtin::SSHExec
@ -190,7 +181,6 @@ module Vagrant
# This is the action that will run a single SSH command.
def self.action_ssh_run
Vagrant::Action::Builder.new.tap do |b|
# b.use CheckDependencies
b.use CheckCreated
b.use CheckRunning
b.use Vagrant::Action::Builtin::SSHRun

View file

@ -7,6 +7,10 @@ module Vagrant
error_key(:lxc_execute_error)
end
class LxcNotInstalled < Vagrant::Errors::VagrantError
error_key(:lxc_not_installed)
end
# Box related errors
class TemplateFileMissing < Vagrant::Errors::VagrantError
error_key(:lxc_template_file_missing)

View file

@ -14,6 +14,7 @@ module Vagrant
@logger = Log4r::Logger.new("vagrant::provider::lxc")
@machine = machine
ensure_lxc_installed!
machine_id_changed
end
@ -25,6 +26,12 @@ module Vagrant
end
end
def ensure_lxc_installed!
unless system("which lxc-version > /dev/null")
raise Errors::LxcNotInstalled
end
end
# If the machine ID changed, then we need to rebuild our underlying
# container.
def machine_id_changed

View file

@ -45,5 +45,8 @@ en:
The template file used for creating the container was not found for %{name}
box.
lxc_not_installed: |-
The `lxc` package does not seem to be installed or is not accessible on the PATH.
lxc_redir_not_installed: |-
`redir` is not installed or is not accessible on the PATH.