provisioners/docker: Simplify raising of Docker related errors

This commit is contained in:
Fabio Rehm 2013-11-26 20:09:20 -02:00
parent 0536817e90
commit 82fc9330af
4 changed files with 11 additions and 15 deletions

View File

@ -22,7 +22,7 @@ module VagrantPlugins
@machine.guest.capability(:docker_install, @version)
if !@machine.guest.capability(:docker_installed)
raise Errors::DockerInstallFailed
raise DockerError, :install_failed
end
end

View File

@ -1,11 +0,0 @@
module VagrantPlugins
module Docker
module Errors
class DockerInstallFailed < ::Vagrant::Errors::VagrantError
end
class DockerNotRunning < ::Vagrant::Errors::VagrantError
end
end
end
end

View File

@ -1,9 +1,12 @@
require_relative "errors"
require_relative "docker_client"
require_relative "docker_installer"
module VagrantPlugins
module Docker
class DockerError < Vagrant::Errors::VagrantError
error_namespace("vagrant.provisioners.docker")
end
# TODO: Improve handling of vagrant-lxc specifics (like checking for apparmor
# profile stuff + autocorrection)
class Provisioner < Vagrant.plugin("2", :provisioner)
@ -15,7 +18,7 @@ module VagrantPlugins
end
def provision
@logger = Log4r::Logger.new("vagrant::provisioners::vocker")
@logger = Log4r::Logger.new("vagrant::provisioners::docker")
@logger.info("Checking for Docker installation...")
@installer.ensure_installed
@ -23,7 +26,7 @@ module VagrantPlugins
# Attempt to start service if not running
@client.start_service
unless @client.daemon_running?
raise Errors::DockerNotRunning
raise DockerError, :not_running
end
if config.images.any?

View File

@ -1295,3 +1295,7 @@ en:
playbook_path_invalid: "`playbook` for the Ansible provisioner does not exist on the host system: %{path}"
inventory_path_invalid: "`inventory_path` for the Ansible provisioner does not exist on the host system: %{path}"
extra_vars_invalid: "`extra_vars` for the Ansible provisioner must be a hash or a path to an existing file. Received: %{value} (as %{type})"
docker:
not_running: "Docker is not running on the guest VM."
install_failed: "Docker installation failed."