with rbd.Image(ioctx, sys.argv[1]) as image:
image.lock_exclusive(sys.argv[2])
while True:
- image.write('A' * 4096, 0)
+ image.write(b'A' * 4096, 0)
r = image.read(0, 4096)
except rbd.ConnectionShutdown:
# it so happens that the errno here is 108, but
while offset < IMG_SIZE:
image.write(data, offset)
offset += (1 << IMG_ORDER)
- image.write('1', IMG_SIZE - 1)
+ image.write(b'1', IMG_SIZE - 1)
assert(image.is_exclusive_lock_owner())
print("waiting for slave to complete")
safe_delete_image(ioctx, CLONE_IMG_RENAME)
safe_delete_image(ioctx, CLONE_IMG_NAME)
delete_image(ioctx, PARENT_IMG_NAME)
- print ("finished")
+ print("finished")
def slave(ioctx):
print("starting slave")
try:
with Image(ioctx, CLONE_IMG_NAME) as image:
if (image.list_lockers() != [] and
- image.read(IMG_SIZE - 1, 1) == '1'):
+ image.read(IMG_SIZE - 1, 1) == b'1'):
break
except Exception:
pass
assert(not image.is_exclusive_lock_owner())
print("resize")
- image.resize(IMG_SIZE / 2)
+ image.resize(IMG_SIZE // 2)
assert(not image.is_exclusive_lock_owner())
- assert(image.stat()['size'] == IMG_SIZE / 2)
+ assert(image.stat()['size'] == IMG_SIZE // 2)
print("create_snap")
image.create_snap('snap1')
assert(not image.is_exclusive_lock_owner())
- assert('snap1' in map(lambda snap: snap['name'], image.list_snaps()))
+ assert(any(snap['name'] == 'snap1'
+ for snap in image.list_snaps()))
print("protect_snap")
image.protect_snap('snap1')
print("rename_snap")
image.rename_snap('snap1', 'snap1-new')
assert(not image.is_exclusive_lock_owner())
- assert('snap1-new' in map(lambda snap: snap['name'],
- image.list_snaps()))
+ assert(any(snap['name'] == 'snap1-new'
+ for snap in image.list_snaps()))
print("remove_snap")
image.remove_snap('snap1-new')