multiplex conserver across hosts
[invirt/packages/invirt-console.git] / files / usr / sbin / sipb-xen-update-conserver
index fb3a7a0..1d3580b 100755 (executable)
@@ -3,11 +3,12 @@
 import sipb_xen_database
 import subprocess
 import os
 import sipb_xen_database
 import subprocess
 import os
+import socket
 
 sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
 
 def live_vms():
 
 sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
 
 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_')]
     p.wait()
     output = p.stdout.read()
     vms = [x.split()[0][2:] for x in output.splitlines() if x.startswith('d_')]
@@ -18,7 +19,14 @@ def reload_conserver():
     p.wait()
 
 if __name__ == '__main__':
     p.wait()
 
 if __name__ == '__main__':
+    hostname = socket.getfqdn().lower()
+    config = '\n'.join('console %s { master %s; }' % (vm, hostname)
+                       for vm in live_vms())
     f = open('/etc/conserver/sipb-xen-consoles.cf', 'w')
     f = open('/etc/conserver/sipb-xen-consoles.cf', 'w')
-    f.write('\n'.join('console %s {}' % vm for vm in live_vms()))
+    f.write(config)
     f.close()
     reload_conserver()
     f.close()
     reload_conserver()
+    subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab',
+                     'host/'+hostname+'@ATHENA.MIT.EDU'])
+    subprocess.call(['/usr/bin/remctl', 'sipb-xen-console.mit.edu',
+                     'console', 'update', config])