In invirt-vnc-client, get certificates from remctl, instead of from
[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     subprocess.call(['kinit', '-k', 'daemon/%s' % config.web.hostname])
12     
13     temp_dir = tempfile.mkdtemp()
14     keystore = os.path.join(temp_dir, 'trust.store')
15     for host in config.hosts:
16         cert = subprocess.Popen(['remctl', config.remote.hostname, 'web',
17                                  'vnccert', host.hostname],
18                                 stdout=PIPE)
19         cert.wait()
20         subprocess.call(['keytool', '-import', '-noprompt', '-alias',
21                          host.hostname, '-keystore', keystore, '-storepass',
22                          'foobar'], stdin=cert.stdout)
23     
24     subprocess.call(['jar', 'uf', '/usr/share/invirt-vnc-client/VncViewer.jar',
25                      '-C', temp_dir, 'trust.store'])
26     
27     shutil.rmtree(temp_dir)
28
29 if __name__ == '__main__':
30     sys.exit(main())