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

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

use invirt.config in sipb-xen-console-server

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