Merge "Fixed generated temp file problem for RBD backend"

This commit is contained in:
Jenkins 2017-04-20 10:52:04 +00:00 committed by Gerrit Code Review
commit 962fce720c
2 changed files with 4 additions and 2 deletions

View File

@ -87,7 +87,7 @@ class RBDConnector(base.BaseLinuxConnector):
fd, ceph_conf_path = tempfile.mkstemp(prefix="brickrbd_")
with os.fdopen(fd, 'w') as conf_file:
conf_file.writelines([mon_hosts, "\n",
client_section, "\n", keyring])
client_section, "\n", keyring, "\n"])
return ceph_conf_path
except IOError:
msg = (_("Failed to write data to %s.") % (ceph_conf_path))

View File

@ -33,6 +33,7 @@ class RBDConnectorTestCase(test_connector.ConnectorTestCase):
self.clustername = 'fake_ceph'
self.hosts = ['192.168.10.2']
self.ports = ['6789']
self.keyring = '/etc/ceph/ceph.client.cinder.keyring'
self.connection_properties = {
'auth_username': self.user,
@ -137,7 +138,8 @@ class RBDConnectorTestCase(test_connector.ConnectorTestCase):
with mock.patch('os.fdopen', mockopen, create=True):
rbd_connector = rbd.RBDConnector(None)
conf_path = rbd_connector._create_ceph_conf(
self.hosts, self.ports, self.clustername, self.user, None)
self.hosts, self.ports, self.clustername, self.user,
self.keyring)
self.assertEqual(conf_path, tmpfile)
mock_mkstemp.assert_called_once_with(prefix='brickrbd_')