[DRE-commits] [vagrant-libvirt] 03/77: Catching exception on initial read_state

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:56:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.17
in repository vagrant-libvirt.

commit 03cd2c24f86ea3125426326647d13e3382c61c5e
Author: Ben Keith <keitwb at gmail.com>
Date:   Wed Feb 5 11:19:16 2014 -0500

    Catching exception on initial read_state
---
 lib/vagrant-libvirt/action/read_state.rb | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/vagrant-libvirt/action/read_state.rb b/lib/vagrant-libvirt/action/read_state.rb
index 4b06d3b..83d1cac 100644
--- a/lib/vagrant-libvirt/action/read_state.rb
+++ b/lib/vagrant-libvirt/action/read_state.rb
@@ -20,11 +20,16 @@ module VagrantPlugins
           return :not_created if machine.id.nil?
 
           # Find the machine
-          server = libvirt.servers.get(machine.id)
-          if server.nil? || [:'shutting-down', :terminated].include?(server.state.to_sym)
-            # The machine can't be found
-            @logger.info('Machine not found or terminated, assuming it got destroyed.')
-            machine.id = nil
+          begin
+            server = libvirt.servers.get(machine.id)
+            if server.nil? || [:'shutting-down', :terminated].include?(server.state.to_sym)
+              # The machine can't be found
+              @logger.info('Machine not found or terminated, assuming it got destroyed.')
+              machine.id = nil
+              return :not_created
+            end
+          rescue Libvirt::RetrieveError
+            @logger.info("Machine #{machine.id} not found.")
             return :not_created
           end
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list