Balance LVM requests (LP: #307361)
[invirt/packages/invirt-remote.git] / server / usr / sbin / invirt-remote-lvm
diff --git a/server/usr/sbin/invirt-remote-lvm b/server/usr/sbin/invirt-remote-lvm
new file mode 100755 (executable)
index 0000000..1c69107
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+"""
+Run an LVM command on one host, with failover for downed hosts.
+"""
+
+from invirt.remote import monocast
+import sys
+import os
+
+def main(argv):
+    # Query each of the hosts.
+    if(os.path.exists("/etc/invirt/nolvm")):
+        sys.stderr.write("LVM operations are temporarily disabled for maintenance, sorry.\n")
+        return 2
+    result = monocast(argv[1:])
+    #print "Hostname: %s; down=%s" % (result[0], result[1])
+    sys.stdout.write(result[3]) # stdout
+    sys.stderr.write(result[4]) # stderr
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))
+
+# vim:et:sw=4:ts=4