Re: [libvirt] [PATCH 3/4] libvirt-guests: Check if URI is reachable before launching commands
On 02/29/2012 04:02 AM, Eric Blake wrote: On 02/28/2012 11:00 AM, Peter Krempa wrote: This patch adds a check to the libvirt-guests script to check for the URI to be alive before attempting any calls. This avoids nasty error messages and allows us to fail gracefuly and continue on other URIs s/gracefuly/gracefully/ configured in the script. --- tools/libvirt-guests.init.sh | 24 +++- 1 files changed, 19 insertions(+), 5 deletions(-) ACK. Thanks. I pushed patches 1,2 and 3 as they make sense without the last one and will send a fixed version soon. Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/4] libvirt-guests: Check if URI is reachable before launching commands
This patch adds a check to the libvirt-guests script to check for the URI to be alive before attempting any calls. This avoids nasty error messages and allows us to fail gracefuly and continue on other URIs configured in the script. --- tools/libvirt-guests.init.sh | 24 +++- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh index 21a7d31..47914e3 100644 --- a/tools/libvirt-guests.init.sh +++ b/tools/libvirt-guests.init.sh @@ -88,6 +88,20 @@ run_virsh_c() { ( export LC_ALL=C; run_virsh $@ ) } +# test_connect URI +# check if URI is reachable +test_connect() +{ +uri=$1 + +run_virsh $uri connect 2/dev/null +if [ $? -ne 0 ]; then +eval_gettext Can't connect to \$uri. Skipping. +echo +return 1 +fi +} + # list_guests URI PERSISTENT # List running guests on URI. # PERSISTENT argument options: @@ -172,6 +186,8 @@ start() { continue fi +test_connect $uri || continue + eval_gettext Resuming guests on \$uri URI...; echo for guest in $list; do name=$(guest_name $uri $guest) @@ -278,12 +294,10 @@ stop() { set -f for uri in $URIS; do set +f -eval_gettext Running guests on \$uri URI: -if [ x$uri = xdefault ] [ ! -x $libvirtd ]; then -gettext libvirtd not installed; skipping this URI.; echo -continue -fi +test_connect $uri || continue + +eval_gettext Running guests on \$uri URI: list=$(list_guests $uri) if [ $? -eq 0 ]; then -- 1.7.3.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] libvirt-guests: Check if URI is reachable before launching commands
On 02/28/2012 11:00 AM, Peter Krempa wrote: This patch adds a check to the libvirt-guests script to check for the URI to be alive before attempting any calls. This avoids nasty error messages and allows us to fail gracefuly and continue on other URIs s/gracefuly/gracefully/ configured in the script. --- tools/libvirt-guests.init.sh | 24 +++- 1 files changed, 19 insertions(+), 5 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list