Merge "Ensure rbd auth fallback uses matching credentials"

This commit is contained in:
Zuul 2018-12-25 03:27:10 +00:00 committed by Gerrit Code Review
commit 9b0019b5a9
2 changed files with 7 additions and 3 deletions

View File

@ -150,7 +150,8 @@ class LibvirtNetVolumeDriverTestCase(
secret_uuid wasn't set on the cinder side for the original connection
which is now persisted in the
nova.block_device_mappings.connection_info column and used here. In
this case we fallback to use the local config for secret_uuid.
this case we fallback to use the local config for secret_uuid and
username.
"""
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
@ -170,7 +171,7 @@ class LibvirtNetVolumeDriverTestCase(
conf = libvirt_driver.get_config(connection_info, self.disk_info)
tree = conf.format_dom()
self._assertNetworkAndProtocolEquals(tree)
self.assertEqual(self.user, tree.find('./auth').get('username'))
self.assertEqual(flags_user, tree.find('./auth').get('username'))
self.assertEqual(secret_type, tree.find('./auth/secret').get('type'))
# Assert that the secret_uuid comes from CONF.libvirt.rbd_secret_uuid.
self.assertEqual(flags_uuid, tree.find('./auth/secret').get('uuid'))

View File

@ -69,8 +69,11 @@ class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
if netdisk_properties['secret_uuid'] is not None:
conf.auth_secret_uuid = netdisk_properties['secret_uuid']
else:
# If we're using the rbd_secret_uuid from nova.conf we need to
# use the rbd_user from nova.conf as well.
LOG.debug('Falling back to Nova configuration for RBD auth '
'secret_uuid value.')
'secret_uuid and username values.')
conf.auth_username = CONF.libvirt.rbd_user
conf.auth_secret_uuid = CONF.libvirt.rbd_secret_uuid
# secret_type is always hard-coded to 'ceph' in cinder
conf.auth_secret_type = netdisk_properties['secret_type']