Ignore:
Timestamp:
Mar 18, 2009, 6:52:03 PM (16 years ago)
Author:
quentin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-vnc-client/debian/invirt-update-vnc-cert

    r1588 r2261  
    22
    33from invirt.config import structs as config
    4 from subprocess import Popen, call, PIPE
     4from subprocess import Popen, check_call, PIPE, CalledProcessError
    55import tempfile
    66import os
     
    88import shutil
    99
     10def check_wait(popen):
     11    retcode = popen.wait()
     12    if retcode != 0:
     13        raise CalledProcessError(retcode, popen.pid)
     14    return retcode
     15
    1016def 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')
     17    check_call(['kinit', '-k', 'daemon/%s' % config.web.hostname])
    1518   
    1619    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   
    1726    keystore = os.path.join(temp_dir, 'trust.store')
    1827    for host in config.hosts:
    1928        cert = Popen(['remctl', config.remote.hostname, 'web', 'vnccert', host.hostname],
    2029                     stdout=PIPE)
    21         cert.wait()
    22         call(['keytool', '-import', '-noprompt', '-alias', host.hostname,
    23               '-keystore', keystore, '-storepass', 'foobar'],
    24              stdin=cert.stdout)
     30        check_wait(cert)
     31        check_call(['keytool', '-import', '-noprompt', '-alias', host.hostname,
     32                    '-keystore', keystore, '-storepass', 'foobar'],
     33                   stdin=cert.stdout)
    2534   
    26     call(['jar', 'uf', '/usr/share/invirt-vnc-client/VncViewer.jar',
    27           '-C', temp_dir, 'trust.store'])
     35    check_call(['jar', 'uf', jarfile,
     36                '-C', temp_dir, 'trust.store'])
     37
     38    shutil.move(jarfile, '/usr/share/invirt-vnc-client/VncViewer.jar')
    2839   
    2940    shutil.rmtree(temp_dir)
Note: See TracChangeset for help on using the changeset viewer.