Last change
on this file since 1197 was
1187,
checked in by price, 16 years ago
|
sipb-xen-console-server -> invirt-console-host
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Rev | Line | |
---|
[397] | 1 | #!/usr/bin/python |
---|
[386] | 2 | |
---|
[397] | 3 | import sipb_xen_database |
---|
| 4 | import subprocess |
---|
| 5 | import os |
---|
[672] | 6 | import socket |
---|
[811] | 7 | from invirt.config import structs as config |
---|
[397] | 8 | |
---|
[814] | 9 | sipb_xen_database.connect(config.db.uri) |
---|
[397] | 10 | |
---|
| 11 | def live_vms(): |
---|
[403] | 12 | p = subprocess.Popen(['/usr/sbin/xm', 'list'], stdout=subprocess.PIPE) |
---|
[397] | 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 | |
---|
| 18 | def reload_conserver(): |
---|
[400] | 19 | p = subprocess.Popen(['/etc/init.d/conserver-server', 'reload'], stdout=subprocess.PIPE) |
---|
[397] | 20 | p.wait() |
---|
| 21 | |
---|
| 22 | if __name__ == '__main__': |
---|
[672] | 23 | hostname = socket.getfqdn().lower() |
---|
[811] | 24 | realm = config.authn[0].realm |
---|
[706] | 25 | principal = 'host/'+hostname+'@'+realm |
---|
[813] | 26 | conftext = '\n'.join('console %s { master %s; }' % (vm, hostname) |
---|
| 27 | for vm in live_vms()) |
---|
[1187] | 28 | f = open('/etc/conserver/invirt-consoles.cf', 'w') |
---|
[813] | 29 | f.write(conftext) |
---|
[397] | 30 | f.close() |
---|
| 31 | reload_conserver() |
---|
[672] | 32 | subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab', |
---|
[706] | 33 | principal]) |
---|
[813] | 34 | subprocess.call(['/usr/bin/remctl', config.console.hostname, |
---|
| 35 | 'console', 'update', conftext]) |
---|
Note: See
TracBrowser
for help on using the repository browser.