Ignore:
Timestamp:
Apr 2, 2008, 4:36:45 AM (17 years ago)
Author:
broder
Message:

Create and destroy conserver consoles through a Python script,
instead of a shell script. Also run this script every 5 minutes or so

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-console-server/files/usr/sbin/sipb-xen-update-conserver

    r386 r397  
    1 #!/bin/bash
     1#!/usr/bin/python
    22
    3 ls /etc/conserver/conf.d/ | sed -e 's|^|#include /etc/conserver/conf.d/|' >/etc/conserver/includes.cf
    4 /etc/init.d/conserver-server reload
     3import sipb_xen_database
     4import subprocess
     5import os
     6
     7sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
     8
     9def live_vms():
     10    p = subprocess.Popen(['xm', 'list'], stdout=subprocess.PIPE)
     11    p.wait()
     12    output = p.stdout.read()
     13    vms = [x.split()[0][2:] for x in output.splitlines() if x.startswith('d_')]
     14    return vms
     15
     16def reload_conserver():
     17    p = subprocess.Popen(['/etc/init.d/conserver-server', 'restart'], stdout=subprocess.PIPE)
     18    p.wait()
     19
     20if __name__ == '__main__':
     21    f = open('/etc/conserver/sipb-xen-consoles.cf', 'w')
     22    f.write('\n'.join('console %s {}' % vm for vm in live_vms()))
     23    f.close()
     24    reload_conserver()
Note: See TracChangeset for help on using the changeset viewer.