From: Quentin Smith Date: Sat, 22 May 2010 05:39:13 +0000 (-0400) Subject: Script for automating the process of determining which VMs need to be rebooted after... X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/outage.git/commitdiff_plain/18db0434c020e34755f691da2443445ac664b93f Script for automating the process of determining which VMs need to be rebooted after a crash svn path=/trunk/scripts/outage/; revision=3009 --- diff --git a/crash-recovery.py b/crash-recovery.py new file mode 100755 index 0000000..c325095 --- /dev/null +++ b/crash-recovery.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +from invirt.config import structs as config +import yaml +import gzip +import sys +from subprocess import Popen, PIPE + +logfile = sys.argv[1] +hostname = sys.argv[2] + +log = yaml.load(gzip.GzipFile(logfile)) +current = yaml.load(Popen(['remctl', config.remote.hostname, 'web', 'listvms'], + stdout=PIPE).communicate()[0]) + +was_running_cd = set([k for k,v in log.iteritems() if v['host'] == hostname and 'cdrom' in v]) +was_running = set([k for k,v in log.iteritems() if v['host'] == hostname and 'cdrom' not in v]) +is_running = set(current.keys()) + +to_be_booted = was_running - is_running +already_booted = was_running & is_running + +print "The following VMs were already rebooted by their owners:" +print "\n".join(sorted(already_booted)) + +print "\nThe following VMs were booted with CDROMs and cannot be automatically rebooted:" +print "\n".join(sorted(was_running_cd)) + +print "\nThe following VMs need to be booted:" +print "\n".join(sorted(to_be_booted))