volume: log which encryptor class is being used

After resolving which encryptor class to use with a cinder
volume, record it in the logs for easier debugging.

Related-Bug: #1463525

Change-Id: Ic753b11a48cb2c17c24c6636a456f00966f7c8ab
This commit is contained in:
Daniel P. Berrange 2015-06-09 17:08:20 +01:00 committed by Matt Riedemann
parent 3e503e2a60
commit c13588517a
1 changed files with 16 additions and 1 deletions

View File

@ -16,8 +16,9 @@
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import strutils
from nova.i18n import _LE
from nova.i18n import _LE, _LW
from nova.volume.encryptors import nop
@ -50,6 +51,11 @@ def get_volume_encryptor(connection_info, **kwargs):
{'provider': provider, 'exception': e})
raise
msg = ("Using volume encryptor '%(encryptor)s' for connection: "
"%(connection_info)s" %
{'encryptor': encryptor, 'connection_info': connection_info})
LOG.debug(strutils.mask_password(msg))
return encryptor
@ -60,10 +66,19 @@ def get_encryption_metadata(context, volume_api, volume_id, connection_info):
try:
metadata = volume_api.get_volume_encryption_metadata(context,
volume_id)
if not metadata:
LOG.warn(_LW('Volume %s should be encrypted but there is no '
'encryption metadata.'), volume_id)
except Exception as e:
LOG.error(_LE("Failed to retrieve encryption metadata for "
"volume %(volume_id)s: %(exception)s"),
{'volume_id': volume_id, 'exception': e})
raise
if metadata:
msg = ("Using volume encryption metadata '%(metadata)s' for "
"connection: %(connection_info)s" %
{'metadata': metadata, 'connection_info': connection_info})
LOG.debug(strutils.mask_password(msg))
return metadata