From 2f9bd85ae14c7d4a8c0646642e28899de92ec680 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 27 Jul 2018 20:20:39 +0000 Subject: [PATCH] Define keymaster log routes on the class ... instead of having KmipKeyMaster instantiate its own logger inside of _get_root_secret. Bonus: KmsKeyMaster uses its own log route now. Bonus bonus: get rid of KmsKeyMaster's pointlessly-overriden __init__ method. Change-Id: Idb4b832e5ca0e3d749fe2c0b7ba283447a4dc69e --- swift/common/middleware/crypto/keymaster.py | 4 +++- swift/common/middleware/crypto/kmip_keymaster.py | 5 +++-- swift/common/middleware/crypto/kms_keymaster.py | 6 +----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/swift/common/middleware/crypto/keymaster.py b/swift/common/middleware/crypto/keymaster.py index 40e3698a7d..b4bdb5c5f7 100644 --- a/swift/common/middleware/crypto/keymaster.py +++ b/swift/common/middleware/crypto/keymaster.py @@ -18,7 +18,7 @@ import os from swift.common.middleware.crypto.crypto_utils import CRYPTO_KEY_CALLBACK from swift.common.swob import Request, HTTPException -from swift.common.utils import readconf, strict_b64decode +from swift.common.utils import readconf, strict_b64decode, get_logger from swift.common.wsgi import WSGIContext @@ -106,9 +106,11 @@ class KeyMaster(object): random number generator. Changing the root secret is likely to result in data loss. """ + log_route = 'keymaster' def __init__(self, app, conf): self.app = app + self.logger = get_logger(conf, log_route=self.log_route) self.keymaster_config_path = conf.get('keymaster_config_path') # The _get_root_secret() function is overridden by other keymasters self.root_secret = self._get_root_secret(conf) diff --git a/swift/common/middleware/crypto/kmip_keymaster.py b/swift/common/middleware/crypto/kmip_keymaster.py index cff9be3b6e..6a409aa7ce 100644 --- a/swift/common/middleware/crypto/kmip_keymaster.py +++ b/swift/common/middleware/crypto/kmip_keymaster.py @@ -17,7 +17,7 @@ import logging import os from swift.common.middleware.crypto import keymaster -from swift.common.utils import readconf, get_logger +from swift.common.utils import readconf from kmip.pie.client import ProxyKmipClient @@ -79,8 +79,9 @@ example:: class KmipKeyMaster(keymaster.KeyMaster): + log_route = 'kmip_keymaster' + def _get_root_secret(self, conf): - self.logger = get_logger(conf, log_route='kmip_keymaster') if self.keymaster_config_path: keymaster_opts = ['host', 'port', 'certfile', 'keyfile', 'ca_certs', 'username', 'password', 'key_id'] diff --git a/swift/common/middleware/crypto/kms_keymaster.py b/swift/common/middleware/crypto/kms_keymaster.py index 4c4395d86d..402b987c25 100644 --- a/swift/common/middleware/crypto/kms_keymaster.py +++ b/swift/common/middleware/crypto/kms_keymaster.py @@ -28,11 +28,7 @@ class KmsKeyMaster(KeyMaster): proxy-server.conf file, or in the configuration pointed to using the keymaster_config_path configuration value in the proxy-server.conf file. """ - - def __init__(self, app, conf): - # Call the superclass __init__() method, which calls the overridden - # self._get_root_secret() below. - super(KmsKeyMaster, self).__init__(app, conf) + log_route = 'kms_keymaster' def _get_root_secret(self, conf): """