source: trunk/packages/invirt-console-host/files/usr/sbin/invirt-update-conserver @ 1539

Last change on this file since 1539 was 1539, checked in by broder, 15 years ago

In invirt-update-conserver, specify the full path to invoke-rc.d for
when it's run as a cron job

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