Last change
on this file since 764 was
706,
checked in by price, 16 years ago
|
on console, get Kerberos realm from config
|
-
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 |
---|
[397] | 7 | |
---|
| 8 | sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') |
---|
| 9 | |
---|
| 10 | def live_vms(): |
---|
[403] | 11 | p = subprocess.Popen(['/usr/sbin/xm', 'list'], stdout=subprocess.PIPE) |
---|
[397] | 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 | |
---|
| 17 | def reload_conserver(): |
---|
[400] | 18 | p = subprocess.Popen(['/etc/init.d/conserver-server', 'reload'], stdout=subprocess.PIPE) |
---|
[397] | 19 | p.wait() |
---|
| 20 | |
---|
| 21 | if __name__ == '__main__': |
---|
[672] | 22 | hostname = socket.getfqdn().lower() |
---|
[706] | 23 | realm = file('/etc/invirt/realm').read().strip() |
---|
| 24 | principal = 'host/'+hostname+'@'+realm |
---|
[672] | 25 | config = '\n'.join('console %s { master %s; }' % (vm, hostname) |
---|
| 26 | for vm in live_vms()) |
---|
[397] | 27 | f = open('/etc/conserver/sipb-xen-consoles.cf', 'w') |
---|
[672] | 28 | f.write(config) |
---|
[397] | 29 | f.close() |
---|
| 30 | reload_conserver() |
---|
[672] | 31 | subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab', |
---|
[706] | 32 | principal]) |
---|
[672] | 33 | subprocess.call(['/usr/bin/remctl', 'sipb-xen-console.mit.edu', |
---|
| 34 | 'console', 'update', config]) |
---|
Note: See
TracBrowser
for help on using the repository browser.