data = src.read(self.chunk_size)
# If we have reach end of source, discard any extraneous bytes from
# destination volume if trim is enabled and stop writing.
- if data == '':
+ if data == b'':
if CONF.restore_discard_excess_bytes:
self._discard_bytes(dest, dest.tell(),
length - dest.tell())
if rem:
LOG.debug("Transferring remaining %s bytes", rem)
data = src.read(rem)
- if data == '':
+ if data == b'':
if CONF.restore_discard_excess_bytes:
self._discard_bytes(dest, dest.tell(), rem)
else:
self.meta.image.size = mock.Mock()
self.mock_rbd_wrapper = driver.RBDImageIOWrapper(self.meta)
self.data_length = 1024
- self.full_data = 'abcd' * 256
+ self.full_data = b'abcd' * 256
def test_init(self):
self.assertEqual(self.mock_rbd_wrapper._rbd_meta, self.meta)
self.assertEqual(self.full_data, data)
data = self.mock_rbd_wrapper.read()
- self.assertEqual('', data)
+ self.assertEqual(b'', data)
self.mock_rbd_wrapper.seek(0)
data = self.mock_rbd_wrapper.read()
# length (they just return nothing) but rbd images do so we need to
# return empty string if we have reached the end of the image.
if (offset >= total):
- return ''
+ return b''
if length is None:
length = total
LOG.debug("%(chunks)s chunks of %(bytes)s bytes to be transferred.",
{'chunks': chunks, 'bytes': chunk_size})
- for chunk in xrange(0, chunks):
+ for chunk in range(0, chunks):
before = time.time()
data = tpool.execute(src.read, min(chunk_size, remaining_length))
# If we have reached end of source, discard any extraneous bytes from
# destination volume if trim is enabled and stop writing.
- if data == '':
+ if data == b'':
break
tpool.execute(dest.write, data)