>From 8b20ddeb9da14cd6f4c4f3af1ff81ee0539c13d3 Mon Sep 17 00:00:00 2001 From: Bill Peck Date: Fri, 16 Sep 2011 11:10:54 -0400 Subject: [PATCH] fix power_virsh template to check dom status before executing command. If you don't check the status and issue an off command to an already off dom it will fail with an error. Same thing with on. --- templates/power_virsh.template | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/templates/power_virsh.template b/templates/power_virsh.template index c116844..7b1116f 100644 --- a/templates/power_virsh.template +++ b/templates/power_virsh.template @@ -29,4 +29,7 @@ ## Perform requested action ## NOTE - may require additional setup by sys-admin to enable passwd-less operation -/usr/bin/virsh --connect $driver://$username$power_address/system $operation $power_id +domstate=\$(/usr/bin/virsh --connect $driver://$username$power_address/system domstate $power_id) +if [ "$operation" = "destroy" -a "$domstate" = "running" -o "$operation" = "start" -a "$domstate" = "shut off" ]; then + /usr/bin/virsh --connect $driver://$username$power_address/system $operation $power_id +fi -- 1.7.4.4