source: trunk/packages/sipb-xen-console-server/files/usr/sbin/sipb-xen-update-conserver @ 672

Last change on this file since 672 was 672, checked in by price, 16 years ago

multiplex conserver across hosts

  • Property svn:executable set to *
File size: 1.0 KB
Line 
1#!/usr/bin/python
2
3import sipb_xen_database
4import subprocess
5import os
6import socket
7
8sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
9
10def live_vms():
11    p = subprocess.Popen(['/usr/sbin/xm', 'list'], stdout=subprocess.PIPE)
12    p.wait()
13    output = p.stdout.read()
14    vms = [x.split()[0][2:] for x in output.splitlines() if x.startswith('d_')]
15    return vms
16
17def reload_conserver():
18    p = subprocess.Popen(['/etc/init.d/conserver-server', 'reload'], stdout=subprocess.PIPE)
19    p.wait()
20
21if __name__ == '__main__':
22    hostname = socket.getfqdn().lower()
23    config = '\n'.join('console %s { master %s; }' % (vm, hostname)
24                       for vm in live_vms())
25    f = open('/etc/conserver/sipb-xen-consoles.cf', 'w')
26    f.write(config)
27    f.close()
28    reload_conserver()
29    subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab',
30                     'host/'+hostname+'@ATHENA.MIT.EDU'])
31    subprocess.call(['/usr/bin/remctl', 'sipb-xen-console.mit.edu',
32                     'console', 'update', config])
Note: See TracBrowser for help on using the repository browser.