Add missing dependency on java6-sdk to invirt-vnc-client.
[invirt/packages/invirt-vnc-client.git] / debian / invirt-update-vnc-cert
1 #!/usr/bin/python
2
3 from invirt.config import structs as config
4 from subprocess import Popen, call, PIPE
5 import tempfile
6 import os
7 import sys
8 import shutil
9
10 def main():
11     call(['kinit', '-k', 'daemon/%s' % config.web.hostname])
12     
13     shutil.copy('/usr/share/invirt-vnc-client/VncViewer.src.jar',
14                 '/usr/share/invirt-vnc-client/VncViewer.jar')
15     
16     temp_dir = tempfile.mkdtemp()
17     keystore = os.path.join(temp_dir, 'trust.store')
18     for host in config.hosts:
19         cert = Popen(['remctl', config.remote.hostname, 'web', 'vnccert', host.hostname],
20                      stdout=PIPE)
21         cert.wait()
22         call(['keytool', '-import', '-noprompt', '-alias', host.hostname,
23               '-keystore', keystore, '-storepass', 'foobar'],
24              stdin=cert.stdout)
25     
26     call(['jar', 'uf', '/usr/share/invirt-vnc-client/VncViewer.jar',
27           '-C', temp_dir, 'trust.store'])
28     
29     shutil.rmtree(temp_dir)
30
31 if __name__ == '__main__':
32     sys.exit(main())