diff options
author | Russell Bryant <rbryant@redhat.com> | 2014-10-08 12:14:31 +0000 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2014-10-08 13:43:42 +0000 |
commit | c8538208da00c3b0d0646629c9d668aa69944b85 (patch) | |
tree | 3a4040802320ed80d245b42a72784c9ccf18a3ec /nova/crypto.py | |
parent | 51de439a4d1fe5e17d59d3aac3fd2c49556e641b (diff) | |
download | nova-c8538208da00c3b0d0646629c9d668aa69944b85.tar.gz |
Fix broken cert revocation
Cert revocation was broken by
32b0adb591f80ad2c5c19519b4ffc2b55dbea672. os.chdir() never returns
anything, so this method would always raise an exception. The proper
way to handle an error from os.chdir() is to catch OSError.
There were existing tests for this code, but they conveniently mocked
os.chdir() to return values that are never actually returned. The
tests were fixed to match the real behavior.
Change-Id: I7549bb60a7d43d53d6f81eecea31cbb9720cc8b6
Closes-bug: #1376368
Diffstat (limited to 'nova/crypto.py')
-rw-r--r-- | nova/crypto.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/nova/crypto.py b/nova/crypto.py index cecd1846bc..c9f3030d48 100644 --- a/nova/crypto.py +++ b/nova/crypto.py @@ -274,7 +274,9 @@ def ssh_encrypt_text(ssh_public_key, text): def revoke_cert(project_id, file_name): """Revoke a cert by file name.""" start = os.getcwd() - if not os.chdir(ca_folder(project_id)): + try: + os.chdir(ca_folder(project_id)) + except OSError: raise exception.ProjectNotFound(project_id=project_id) try: # NOTE(vish): potential race condition here |