Image,
ImageNotFound,
RBD_FEATURE_EXCLUSIVE_LOCK,
- RBD_FEATURE_LAYERING)
+ RBD_FEATURE_LAYERING,
+ RBD_FEATURE_OBJECT_MAP,
+ RBD_FEATURE_FAST_DIFF,
+ RBD_FLAG_OBJECT_MAP_INVALID)
POOL_NAME='rbd'
PARENT_IMG_NAME='test_notify_parent'
def master(ioctx):
print("starting master")
+ safe_delete_image(ioctx, CLONE_IMG_RENAME)
safe_delete_image(ioctx, CLONE_IMG_NAME)
safe_delete_image(ioctx, PARENT_IMG_NAME)
while image.is_exclusive_lock_owner():
time.sleep(5)
- delete_image(ioctx, CLONE_IMG_NAME)
+ safe_delete_image(ioctx, CLONE_IMG_RENAME)
+ safe_delete_image(ioctx, CLONE_IMG_NAME)
delete_image(ioctx, PARENT_IMG_NAME)
print ("finished")
except Exception:
pass
- with Image(ioctx, CLONE_IMG_NAME) as image:
- print("detected master")
+ print("detected master")
+
+ print("rename")
+ RBD().rename(ioctx, CLONE_IMG_NAME, CLONE_IMG_RENAME);
+ assert(not image.is_exclusive_lock_owner())
+ with Image(ioctx, CLONE_IMG_RENAME) as image:
print("flatten")
image.flatten()
assert(not image.is_exclusive_lock_owner())
print("protect_snap")
image.protect_snap('snap1')
assert(not image.is_exclusive_lock_owner())
- assert(image.is_protected_snap())
+ assert(image.is_protected_snap('snap1'))
print("unprotect_snap")
image.unprotect_snap('snap1')
assert(not image.is_exclusive_lock_owner())
- assert(not image.is_protected_snap())
+ assert(not image.is_protected_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()))
print("remove_snap")
- image.remove_snap('snap1')
+ image.remove_snap('snap1-new')
assert(not image.is_exclusive_lock_owner())
assert(list(image.list_snaps()) == [])
+ print("rebuild object map")
+ image.update_features(RBD_FEATURE_OBJECT_MAP | RBD_FEATURE_FAST_DIFF,
+ False)
+ image.update_features(RBD_FEATURE_OBJECT_MAP, True)
+ assert((image.flags() & RBD_FLAG_OBJECT_MAP_INVALID) != 0)
+ image.rebuild_object_map()
+ assert(not image.is_exclusive_lock_owner())
+ assert((image.flags() & RBD_FLAG_OBJECT_MAP_INVALID) == 0)
+
print("write")
data = os.urandom(512)
image.write(data, 0)
assert(image.is_exclusive_lock_owner())
- print("rename")
- RBD().rename(ioctx, CLONE_IMG_NAME, CLONE_IMG_RENAME);
-
print("finished")
def main():