Fixed generated temp file problem for RBD backend
Generated file doesn't have EOF char and it is problematic to read by rados libraries. New line char fix the problem. Closes-bug: #1684077 Change-Id: I4f2eecafbe13e65cdcc24e46ae664760fa3ec306
This commit is contained in:
parent
0732dcb4da
commit
72ce87338c
|
@ -87,7 +87,7 @@ class RBDConnector(base.BaseLinuxConnector):
|
||||||
fd, ceph_conf_path = tempfile.mkstemp(prefix="brickrbd_")
|
fd, ceph_conf_path = tempfile.mkstemp(prefix="brickrbd_")
|
||||||
with os.fdopen(fd, 'w') as conf_file:
|
with os.fdopen(fd, 'w') as conf_file:
|
||||||
conf_file.writelines([mon_hosts, "\n",
|
conf_file.writelines([mon_hosts, "\n",
|
||||||
client_section, "\n", keyring])
|
client_section, "\n", keyring, "\n"])
|
||||||
return ceph_conf_path
|
return ceph_conf_path
|
||||||
except IOError:
|
except IOError:
|
||||||
msg = (_("Failed to write data to %s.") % (ceph_conf_path))
|
msg = (_("Failed to write data to %s.") % (ceph_conf_path))
|
||||||
|
|
|
@ -33,6 +33,7 @@ class RBDConnectorTestCase(test_connector.ConnectorTestCase):
|
||||||
self.clustername = 'fake_ceph'
|
self.clustername = 'fake_ceph'
|
||||||
self.hosts = ['192.168.10.2']
|
self.hosts = ['192.168.10.2']
|
||||||
self.ports = ['6789']
|
self.ports = ['6789']
|
||||||
|
self.keyring = '/etc/ceph/ceph.client.cinder.keyring'
|
||||||
|
|
||||||
self.connection_properties = {
|
self.connection_properties = {
|
||||||
'auth_username': self.user,
|
'auth_username': self.user,
|
||||||
|
@ -137,7 +138,8 @@ class RBDConnectorTestCase(test_connector.ConnectorTestCase):
|
||||||
with mock.patch('os.fdopen', mockopen, create=True):
|
with mock.patch('os.fdopen', mockopen, create=True):
|
||||||
rbd_connector = rbd.RBDConnector(None)
|
rbd_connector = rbd.RBDConnector(None)
|
||||||
conf_path = rbd_connector._create_ceph_conf(
|
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)
|
self.assertEqual(conf_path, tmpfile)
|
||||||
mock_mkstemp.assert_called_once_with(prefix='brickrbd_')
|
mock_mkstemp.assert_called_once_with(prefix='brickrbd_')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue