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
changes/21/458021/3
Daniel Pawlik 6 years ago
parent 0732dcb4da
commit 72ce87338c
  1. 2
      os_brick/initiator/connectors/rbd.py
  2. 4
      os_brick/tests/initiator/connectors/test_rbd.py

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

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

Loading…
Cancel
Save