3 from invirt.config import structs as config
7 from subprocess import Popen, PIPE
10 hostname = sys.argv[2]
12 log = yaml.load(gzip.GzipFile(logfile))
13 current = yaml.load(Popen(['remctl', config.remote.hostname, 'web', 'listvms'],
14 stdout=PIPE).communicate()[0])
16 was_running_cd = set([k for k,v in log.iteritems() if v['host'] == hostname and 'cdrom' in v])
17 was_running = set([k for k,v in log.iteritems() if v['host'] == hostname and 'cdrom' not in v])
18 is_running = set(current.keys())
20 to_be_booted = was_running - is_running
21 already_booted = was_running & is_running
23 print "The following VMs were already rebooted by their owners:"
24 print "\n".join(sorted(already_booted))
26 print "\nThe following VMs were booted with CDROMs and cannot be automatically rebooted:"
27 print "\n".join(sorted(was_running_cd))
29 print "\nThe following VMs need to be booted:"
30 print "\n".join(sorted(to_be_booted))