From 82fc9330af8c7af608daa3b6c011541c71ba2ea9 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 26 Nov 2013 20:09:20 -0200 Subject: [PATCH] provisioners/docker: Simplify raising of Docker related errors --- plugins/provisioners/docker/docker_installer.rb | 2 +- plugins/provisioners/docker/errors.rb | 11 ----------- plugins/provisioners/docker/provisioner.rb | 9 ++++++--- templates/locales/en.yml | 4 ++++ 4 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 plugins/provisioners/docker/errors.rb diff --git a/plugins/provisioners/docker/docker_installer.rb b/plugins/provisioners/docker/docker_installer.rb index 068bf6799..974f2b6d6 100644 --- a/plugins/provisioners/docker/docker_installer.rb +++ b/plugins/provisioners/docker/docker_installer.rb @@ -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 diff --git a/plugins/provisioners/docker/errors.rb b/plugins/provisioners/docker/errors.rb deleted file mode 100644 index 4866d3a40..000000000 --- a/plugins/provisioners/docker/errors.rb +++ /dev/null @@ -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 diff --git a/plugins/provisioners/docker/provisioner.rb b/plugins/provisioners/docker/provisioner.rb index d1da07714..63155e76c 100644 --- a/plugins/provisioners/docker/provisioner.rb +++ b/plugins/provisioners/docker/provisioner.rb @@ -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? diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 1c5562094..75dfd72b7 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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."