X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-console.git/blobdiff_plain/7b6a8036eed4a74e173d91552c5704954c706c05..7f53b6cbcf5195b38271e6bff3a4a8fcbf3e9edb:/files/usr/sbin/sipb-xen-update-conserver diff --git a/files/usr/sbin/sipb-xen-update-conserver b/files/usr/sbin/sipb-xen-update-conserver index fb3a7a0..8d99d64 100755 --- a/files/usr/sbin/sipb-xen-update-conserver +++ b/files/usr/sbin/sipb-xen-update-conserver @@ -3,11 +3,13 @@ import sipb_xen_database import subprocess import os +import socket +from invirt.config import structs as config -sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') +sipb_xen_database.connect(config.db.uri) def live_vms(): - p = subprocess.Popen(['xm', 'list'], stdout=subprocess.PIPE) + p = subprocess.Popen(['/usr/sbin/xm', 'list'], stdout=subprocess.PIPE) p.wait() output = p.stdout.read() vms = [x.split()[0][2:] for x in output.splitlines() if x.startswith('d_')] @@ -18,7 +20,16 @@ def reload_conserver(): p.wait() if __name__ == '__main__': + hostname = socket.getfqdn().lower() + realm = config.authn[0].realm + principal = 'host/'+hostname+'@'+realm + conftext = '\n'.join('console %s { master %s; }' % (vm, hostname) + for vm in live_vms()) f = open('/etc/conserver/sipb-xen-consoles.cf', 'w') - f.write('\n'.join('console %s {}' % vm for vm in live_vms())) + f.write(conftext) f.close() reload_conserver() + subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab', + principal]) + subprocess.call(['/usr/bin/remctl', config.console.hostname, + 'console', 'update', conftext])