source: trunk/scripts/outage/crash-recovery.py

Last change on this file was 3009, checked in by quentin, 15 years ago

Script for automating the process of determining which VMs need to be rebooted after a crash

  • Property svn:executable set to *
File size: 983 bytes
Line 
1#!/usr/bin/python
2
3from invirt.config import structs as config
4import yaml
5import gzip
6import sys
7from subprocess import Popen, PIPE
8
9logfile = sys.argv[1]
10hostname = sys.argv[2]
11
12log = yaml.load(gzip.GzipFile(logfile))
13current = yaml.load(Popen(['remctl', config.remote.hostname, 'web', 'listvms'],
14                     stdout=PIPE).communicate()[0])
15
16was_running_cd = set([k for k,v in log.iteritems() if v['host'] == hostname and 'cdrom' in v])
17was_running = set([k for k,v in log.iteritems() if v['host'] == hostname and 'cdrom' not in v])
18is_running = set(current.keys())
19
20to_be_booted = was_running - is_running
21already_booted = was_running & is_running
22
23print "The following VMs were already rebooted by their owners:"
24print "\n".join(sorted(already_booted))
25
26print "\nThe following VMs were booted with CDROMs and cannot be automatically rebooted:"
27print "\n".join(sorted(was_running_cd))
28
29print "\nThe following VMs need to be booted:"
30print "\n".join(sorted(to_be_booted))
Note: See TracBrowser for help on using the repository browser.