#!/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