Yedidyah Bar David has uploaded a new change for review.

Change subject: bin: destroy VM on vm-start if it's down
......................................................................

bin: destroy VM on vm-start if it's down

Bug-Url: https://bugzilla.redhat.com/1024710
Change-Id: I49aa7b1cdd8eac6e99852dc02af2e888023f73f3
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M src/bin/hosted-engine.in
1 file changed, 21 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/19/23219/1

diff --git a/src/bin/hosted-engine.in b/src/bin/hosted-engine.in
index 232e891..322e29a 100644
--- a/src/bin/hosted-engine.in
+++ b/src/bin/hosted-engine.in
@@ -97,6 +97,27 @@
 
     # TODO: Check first the sanlock status, and if allows:
     if [ -r "${conf}" ] ; then
+        if [ -n "${vmid}" ] ; then
+            local down=
+            local status=
+            listoutput=$(${VDSCOMMAND} list vms:"${vmid}")
+            while read param eq value; do
+                if [ "${param}" = 'Status' ]; then
+                    status="${value}"
+                    [ "${status}" = "Down" ] && down=1
+                fi
+            done << __EOF__
+${listoutput}
+__EOF__
+            if [ -n "${down}" ]; then
+                echo "VM exists and is down, destroying it"
+                ${VDSCOMMAND} destroy "${vmid}"
+            else
+                echo "VM exists and its status is ${status}"
+                exit 1
+            fi
+
+        fi
         ${VDSCOMMAND} create "${conf}"
     else
         echo "You must run deploy first"


-- 
To view, visit http://gerrit.ovirt.org/23219
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I49aa7b1cdd8eac6e99852dc02af2e888023f73f3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to