Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle OSError which can be thrown when removing tmpdir. Fixes bug 88…
…3326.

Change-Id: Ie1f40fcce6ce6af4ab71961c725dcd626eda8aea
  • Loading branch information
chris fattarsi committed Feb 20, 2012
1 parent 7ab28c4 commit 94d3d19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -29,6 +29,7 @@ Chiradeep Vittal <chiradeep@cloud.com>
Chmouel Boudjnah <chmouel@chmouel.com>
Chris Behrens <cbehrens@codestud.com>
Christian Berendt <berendt@b1-systems.de>
Chris Fattarsi <chris.fattarsi@pistoncloud.com>
Christopher MacGown <chris@pistoncloud.com>
Chuck Short <zulcss@ubuntu.com>
Cole Robinson <crobinso@redhat.com>
Expand Down
17 changes: 14 additions & 3 deletions nova/crypto.py
Expand Up @@ -136,7 +136,10 @@ def generate_fingerprint(public_key):
except exception.ProcessExecutionError:
raise exception.InvalidKeypair()
finally:
shutil.rmtree(tmpdir)
try:
shutil.rmtree(tmpdir)
except IOError, e:
LOG.debug(_('Could not remove tmpdir: %s'), str(e))


def generate_key_pair(bits=1024):
Expand All @@ -150,7 +153,10 @@ def generate_key_pair(bits=1024):
private_key = open(keyfile).read()
public_key = open(keyfile + '.pub').read()

shutil.rmtree(tmpdir)
try:
shutil.rmtree(tmpdir)
except OSError, e:
LOG.debug(_('Could not remove tmpdir: %s'), str(e))

return (private_key, public_key, fingerprint)

Expand Down Expand Up @@ -235,7 +241,12 @@ def generate_x509_cert(user_id, project_id, bits=1024):
'-batch', '-subj', subject)
private_key = open(keyfile).read()
csr = open(csrfile).read()
shutil.rmtree(tmpdir)

try:
shutil.rmtree(tmpdir)
except OSError, e:
LOG.debug(_('Could not remove tmpdir: %s'), str(e))

(serial, signed_csr) = sign_csr(csr, project_id)
fname = os.path.join(ca_folder(project_id), 'newcerts/%s.pem' % serial)
cert = {'user_id': user_id,
Expand Down

0 comments on commit 94d3d19

Please sign in to comment.