summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-26 19:54:20 +0000
committerGerrit Code Review <review@openstack.org>2012-03-26 19:54:20 +0000
commit3433fd65d5f70d83ffa4db013f96c55970ea293e (patch)
tree087a8fa2a8c0776d733ff6d318f249c88c7e3da1
parentff150b326e649f75ee523ab42f9f0a409c0f4eca (diff)
parent2b3e3685ff45ad0662c1bffc8896261eaa6cfbcc (diff)
downloadnova-3433fd65d5f70d83ffa4db013f96c55970ea293e.tar.gz
nova-3433fd65d5f70d83ffa4db013f96c55970ea293e.tar.xz
nova-3433fd65d5f70d83ffa4db013f96c55970ea293e.zip
Merge "Improve performance of safe_log()."
-rw-r--r--nova/rpc/common.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/nova/rpc/common.py b/nova/rpc/common.py
index 03fe14e17..95c245810 100644
--- a/nova/rpc/common.py
+++ b/nova/rpc/common.py
@@ -127,7 +127,12 @@ class Connection(object):
def _safe_log(log_func, msg, msg_data):
"""Sanitizes the msg_data field before logging."""
- has_method = 'method' in msg_data
+ SANITIZE = {
+ 'set_admin_password': ('new_pass',),
+ 'run_instance': ('admin_password',),
+ }
+
+ has_method = 'method' in msg_data and msg_data['method'] in SANITIZE
has_context_token = '_context_auth_token' in msg_data
has_token = 'auth_token' in msg_data
@@ -137,10 +142,6 @@ def _safe_log(log_func, msg, msg_data):
msg_data = copy.deepcopy(msg_data)
if has_method:
- SANITIZE = {
- 'set_admin_password': ('new_pass',),
- 'run_instance': ('admin_password',),
- }
method = msg_data['method']
if method in SANITIZE:
args_to_sanitize = SANITIZE[method]