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
This commit is contained in:
Tim Burke 2018-07-27 20:20:39 +00:00
parent b15111abe7
commit 2f9bd85ae1
3 changed files with 7 additions and 8 deletions

View File

@ -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)

View File

@ -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']

View File

@ -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):
"""