| 
                Last change
                  on this file since 3015 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 |  | 
|---|
| 3 | from invirt.config import structs as config | 
|---|
| 4 | import yaml | 
|---|
| 5 | import gzip | 
|---|
| 6 | import sys | 
|---|
| 7 | from subprocess import Popen, PIPE | 
|---|
| 8 |  | 
|---|
| 9 | logfile = sys.argv[1] | 
|---|
| 10 | hostname = sys.argv[2] | 
|---|
| 11 |  | 
|---|
| 12 | log = yaml.load(gzip.GzipFile(logfile)) | 
|---|
| 13 | current = yaml.load(Popen(['remctl', config.remote.hostname, 'web', 'listvms'], | 
|---|
| 14 |                      stdout=PIPE).communicate()[0]) | 
|---|
| 15 |  | 
|---|
| 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()) | 
|---|
| 19 |  | 
|---|
| 20 | to_be_booted = was_running - is_running | 
|---|
| 21 | already_booted = was_running & is_running | 
|---|
| 22 |  | 
|---|
| 23 | print "The following VMs were already rebooted by their owners:" | 
|---|
| 24 | print "\n".join(sorted(already_booted)) | 
|---|
| 25 |  | 
|---|
| 26 | print "\nThe following VMs were booted with CDROMs and cannot be automatically rebooted:" | 
|---|
| 27 | print "\n".join(sorted(was_running_cd)) | 
|---|
| 28 |  | 
|---|
| 29 | print "\nThe following VMs need to be booted:" | 
|---|
| 30 | print "\n".join(sorted(to_be_booted)) | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.