[DRE-commits] [vagrant-libvirt] 20/77: Catches fog exception when machine could not be found

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:56:34 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 10c3ede74ad3480f8322c036de418b71ee1159b0
Author: Matthieu Coudron <mattator at gmail.com>
Date:   Sun Mar 16 01:20:00 2014 +0100

     Catches fog exception when machine could not be found
---
 lib/vagrant-libvirt/action/read_state.rb | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/vagrant-libvirt/action/read_state.rb b/lib/vagrant-libvirt/action/read_state.rb
index 4b06d3b..22d39c3 100644
--- a/lib/vagrant-libvirt/action/read_state.rb
+++ b/lib/vagrant-libvirt/action/read_state.rb
@@ -18,9 +18,15 @@ module VagrantPlugins
 
         def read_state(libvirt, machine)
           return :not_created if machine.id.nil?
-
+          
+          begin
+            server = libvirt.servers.get(machine.id)
+          rescue Libvirt::RetrieveError => e
+            server = nil
+            @logger.debug('Machine not found #{e}.')
+          end 
           # 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.')

-- 
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