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

Last change on this file was 2261, checked in by quentin, 16 years ago

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

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