Martin Sivák has uploaded a new change for review.

Change subject: Add two new recover commands to the hosted-engine tool
......................................................................

Add two new recover commands to the hosted-engine tool

This adds new interface to two hosted engine operations:

- sanlock lockspace reinitialization
- host metadata cleanup

Change-Id: I7cdb65057de3cf75a1b2919030a8ec79523b36d3
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1116469
Signed-off-by: Martin Sivak <msi...@redhat.com>
---
M src/bin/hosted-engine.in
A src/ovirt_hosted_engine_setup/reinitialize_lockspace.py
2 files changed, 79 insertions(+), 0 deletions(-)


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

diff --git a/src/bin/hosted-engine.in b/src/bin/hosted-engine.in
index b1a73b9..1d0166c 100644
--- a/src/bin/hosted-engine.in
+++ b/src/bin/hosted-engine.in
@@ -62,6 +62,13 @@
             Open the configured console using remote-viewer on localhost
         --set-maintenance --mode=<mode>
             Set maintenance status to the specified mode (global/local/none)
+        --reinitialize-lockspace
+            Make sure all hosted engine agents are down and reinitialize the
+            sanlock lockspaces.
+        --clean-metadata
+            Remove the metadata for the current host's agent from the global
+            status database. This makes all other hosts forget about this
+            host.
 
     For additional information about a specific command try:
         $@ <command> --help
@@ -372,6 +379,46 @@
     fi
 }
 
+cmd_reinitialize_lockspace() {
+    [ "$1" == "--help" ] && { cat << __EOF__
+Usage: $0 reinitialize-lockspace [--force]
+    Reinitialize the sanlock lockspace file. This WIPES all locks.
+    Available only in properly deployed cluster in global maintenance mode
+    with all HA agents shut down.
+
+    --force  This option overrides the safety checks. Use at your own
+             risk DANGEROUS.
+__EOF__
+return ;}
+
+    if [ -r "${conf}" ] ; then
+        python -m ovirt_hosted_engine_setup.reinitialize_lockspace "$@"
+    else
+        echo "You must run deploy first"
+    fi
+}
+
+cmd_clean_metadata() {
+    [ "$1" == "--help" ] && { cat << __EOF__
+Usage: $0 clean_metadata [--force-cleanup] [--host-id=<id>]
+    Remove host's metadata from the global status database.
+    Available only in properly deployed cluster with properly stopped
+    agent.
+
+    --force-cleanup  This option overrides the safety checks. Use at your own
+                     risk DANGEROUS.
+
+    --host-id=<id>  Specify an explicit host id to clean
+__EOF__
+return ;}
+
+    if [ -r "${conf}" ] ; then
+        exec @datadir@/ovirt-hosted-engine-ha/agent/agent.py --cleanup "$@"
+    else
+        echo "You must run deploy first"
+    fi
+}
+
 if [ -z "$1" ] ; then
     usage
 fi
@@ -397,6 +444,8 @@
     --start-pool) cmd_start_pool "$@" ;;
     --console) cmd_console "$@" ;;
     --set-maintenance) cmd_set_maintenance "$@" ;;
+    --reinitialize-lockspace) cmd_reinitialize_lockspace "$@" ;;
+    --clean-metadata) cmd_clean_metadata "$@" ;;
     --help)
         rc=0
         usage
diff --git a/src/ovirt_hosted_engine_setup/reinitialize_lockspace.py 
b/src/ovirt_hosted_engine_setup/reinitialize_lockspace.py
new file mode 100644
index 0000000..60bced2
--- /dev/null
+++ b/src/ovirt_hosted_engine_setup/reinitialize_lockspace.py
@@ -0,0 +1,30 @@
+#
+# ovirt-hosted-engine-setup -- ovirt hosted engine setup
+# Copyright (C) 2013-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""Reinitialize sanlock lockspace"""
+
+import sys
+from ovirt_hosted_engine_ha.client import client
+
+
+if __name__ == "__main__":
+    force = len(sys.argv) > 1 and sys.argv[1] == "--force"
+    ha_cli = client.HAClient()
+    ha_cli.reset_lockspace()


-- 
To view, visit https://gerrit.ovirt.org/42093
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7cdb65057de3cf75a1b2919030a8ec79523b36d3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <msi...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to