source: trunk/packages/invirt-vnc-client/debian/invirt-update-vnc-cert @ 2888

Last change on this file since 2888 was 2261, checked in by quentin, 15 years ago

Make invirt-update-vnc-cert more robust to failure

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/python
2
3from invirt.config import structs as config
4from subprocess import Popen, check_call, PIPE, CalledProcessError
5import tempfile
6import os
7import sys
8import shutil
9
10def check_wait(popen):
11    retcode = popen.wait()
12    if retcode != 0:
13        raise CalledProcessError(retcode, popen.pid)
14    return retcode
15
16def main():
17    check_call(['kinit', '-k', 'daemon/%s' % config.web.hostname])
18   
19    temp_dir = tempfile.mkdtemp()
20
21    jarfile = os.path.join(temp_dir, 'VncViewer.jar')
22
23    shutil.copy('/usr/share/invirt-vnc-client/VncViewer.src.jar',
24                jarfile)
25   
26    keystore = os.path.join(temp_dir, 'trust.store')
27    for host in config.hosts:
28        cert = Popen(['remctl', config.remote.hostname, 'web', 'vnccert', host.hostname],
29                     stdout=PIPE)
30        check_wait(cert)
31        check_call(['keytool', '-import', '-noprompt', '-alias', host.hostname,
32                    '-keystore', keystore, '-storepass', 'foobar'],
33                   stdin=cert.stdout)
34   
35    check_call(['jar', 'uf', jarfile,
36                '-C', temp_dir, 'trust.store'])
37
38    shutil.move(jarfile, '/usr/share/invirt-vnc-client/VncViewer.jar')
39   
40    shutil.rmtree(temp_dir)
41
42if __name__ == '__main__':
43    sys.exit(main())
Note: See TracBrowser for help on using the repository browser.