本文整理汇总了Python中rbd.Image.stripe_unit方法的典型用法代码示例。如果您正苦于以下问题:Python Image.stripe_unit方法的具体用法?Python Image.stripe_unit怎么用?Python Image.stripe_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rbd.Image
的用法示例。
在下文中一共展示了Image.stripe_unit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_with_params
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import stripe_unit [as 别名]
def test_create_with_params(self):
global features
image_name = get_temp_image_name()
order = 20
stripe_unit = 1 << 20
stripe_count = 10
self.rbd.create(ioctx, image_name, IMG_SIZE, order, False, features, stripe_unit, stripe_count)
image = Image(ioctx, image_name)
info = image.stat()
check_stat(info, IMG_SIZE, order)
eq(image.features(), features)
eq(image.stripe_unit(), stripe_unit)
eq(image.stripe_count(), stripe_count)
image.close()
RBD().remove(ioctx, image_name)
示例2: TestClone
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import stripe_unit [as 别名]
class TestClone(object):
@require_features([RBD_FEATURE_LAYERING])
def setUp(self):
global ioctx
global features
self.rbd = RBD()
create_image()
self.image = Image(ioctx, image_name)
data = rand_data(256)
self.image.write(data, IMG_SIZE // 2)
self.image.create_snap('snap1')
global features
self.image.protect_snap('snap1')
self.clone_name = get_temp_image_name()
self.rbd.clone(ioctx, image_name, 'snap1', ioctx, self.clone_name,
features)
self.clone = Image(ioctx, self.clone_name)
def tearDown(self):
global ioctx
self.clone.close()
self.rbd.remove(ioctx, self.clone_name)
self.image.unprotect_snap('snap1')
self.image.remove_snap('snap1')
self.image.close()
remove_image()
def _test_with_params(self, features=None, order=None, stripe_unit=None,
stripe_count=None):
self.image.create_snap('snap2')
self.image.protect_snap('snap2')
clone_name2 = get_temp_image_name()
if features is None:
self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2)
elif order is None:
self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
features)
elif stripe_unit is None:
self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
features, order)
elif stripe_count is None:
self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
features, order, stripe_unit)
else:
self.rbd.clone(ioctx, image_name, 'snap2', ioctx, clone_name2,
features, order, stripe_unit, stripe_count)
self.rbd.remove(ioctx, clone_name2)
self.image.unprotect_snap('snap2')
self.image.remove_snap('snap2')
def test_with_params(self):
self._test_with_params()
def test_with_params2(self):
global features
self._test_with_params(features, self.image.stat()['order'])
@require_features([RBD_FEATURE_STRIPINGV2])
def test_with_params3(self):
global features
self._test_with_params(features, self.image.stat()['order'],
self.image.stripe_unit(),
self.image.stripe_count())
def test_unprotected(self):
self.image.create_snap('snap2')
global features
clone_name2 = get_temp_image_name()
assert_raises(InvalidArgument, self.rbd.clone, ioctx, image_name,
'snap2', ioctx, clone_name2, features)
self.image.remove_snap('snap2')
def test_unprotect_with_children(self):
global features
# can't remove a snapshot that has dependent clones
assert_raises(ImageBusy, self.image.remove_snap, 'snap1')
# validate parent info of clone created by TestClone.setUp
(pool, image, snap) = self.clone.parent_info()
eq(pool, pool_name)
eq(image, image_name)
eq(snap, 'snap1')
# create a new pool...
pool_name2 = get_temp_pool_name()
rados.create_pool(pool_name2)
other_ioctx = rados.open_ioctx(pool_name2)
# ...with a clone of the same parent
other_clone_name = get_temp_image_name()
self.rbd.clone(ioctx, image_name, 'snap1', other_ioctx,
other_clone_name, features)
self.other_clone = Image(other_ioctx, other_clone_name)
# validate its parent info
(pool, image, snap) = self.other_clone.parent_info()
eq(pool, pool_name)
eq(image, image_name)
eq(snap, 'snap1')
#.........这里部分代码省略.........
示例3: TestImage
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import stripe_unit [as 别名]
class TestImage(object):
def setUp(self):
self.rbd = RBD()
create_image()
self.image = Image(ioctx, image_name)
def tearDown(self):
self.image.close()
remove_image()
self.image = None
@require_new_format()
@blacklist_features([RBD_FEATURE_EXCLUSIVE_LOCK])
def test_update_features(self):
features = self.image.features()
self.image.update_features(RBD_FEATURE_EXCLUSIVE_LOCK, True)
eq(features | RBD_FEATURE_EXCLUSIVE_LOCK, self.image.features())
@require_features([RBD_FEATURE_STRIPINGV2])
def test_create_with_params(self):
global features
image_name = get_temp_image_name()
order = 20
stripe_unit = 1 << 20
stripe_count = 10
self.rbd.create(ioctx, image_name, IMG_SIZE, order,
False, features, stripe_unit, stripe_count)
image = Image(ioctx, image_name)
info = image.stat()
check_stat(info, IMG_SIZE, order)
eq(image.features(), features)
eq(image.stripe_unit(), stripe_unit)
eq(image.stripe_count(), stripe_count)
image.close()
RBD().remove(ioctx, image_name)
@require_new_format()
def test_id(self):
assert_not_equal(b'', self.image.id())
def test_block_name_prefix(self):
assert_not_equal(b'', self.image.block_name_prefix())
def test_invalidate_cache(self):
self.image.write(b'abc', 0)
eq(b'abc', self.image.read(0, 3))
self.image.invalidate_cache()
eq(b'abc', self.image.read(0, 3))
def test_stat(self):
info = self.image.stat()
check_stat(info, IMG_SIZE, IMG_ORDER)
def test_flags(self):
flags = self.image.flags()
eq(0, flags)
def test_image_auto_close(self):
image = Image(ioctx, image_name)
def test_write(self):
data = rand_data(256)
self.image.write(data, 0)
def test_write_with_fadvise_flags(self):
data = rand_data(256)
self.image.write(data, 0, LIBRADOS_OP_FLAG_FADVISE_DONTNEED)
self.image.write(data, 0, LIBRADOS_OP_FLAG_FADVISE_NOCACHE)
def test_read(self):
data = self.image.read(0, 20)
eq(data, b'\0' * 20)
def test_read_with_fadvise_flags(self):
data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADVISE_DONTNEED)
eq(data, b'\0' * 20)
data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADVISE_RANDOM)
eq(data, b'\0' * 20)
def test_large_write(self):
data = rand_data(IMG_SIZE)
self.image.write(data, 0)
def test_large_read(self):
data = self.image.read(0, IMG_SIZE)
eq(data, b'\0' * IMG_SIZE)
def test_write_read(self):
data = rand_data(256)
offset = 50
self.image.write(data, offset)
read = self.image.read(offset, 256)
eq(data, read)
def test_read_bad_offset(self):
assert_raises(InvalidArgument, self.image.read, IMG_SIZE + 1, IMG_SIZE)
def test_resize(self):
new_size = IMG_SIZE * 2
#.........这里部分代码省略.........
示例4: TestImage
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import stripe_unit [as 别名]
class TestImage(object):
def setUp(self):
self.rbd = RBD()
create_image()
self.image = Image(ioctx, image_name)
def tearDown(self):
self.image.close()
remove_image()
@require_new_format()
@blacklist_features([RBD_FEATURE_EXCLUSIVE_LOCK])
def test_update_features(self):
features = self.image.features()
self.image.update_features(RBD_FEATURE_EXCLUSIVE_LOCK, True)
eq(features | RBD_FEATURE_EXCLUSIVE_LOCK, self.image.features())
@require_features([RBD_FEATURE_STRIPINGV2])
def test_create_with_params(self):
global features
image_name = get_temp_image_name()
order = 20
stripe_unit = 1 << 20
stripe_count = 10
self.rbd.create(ioctx, image_name, IMG_SIZE, order, False, features, stripe_unit, stripe_count)
image = Image(ioctx, image_name)
info = image.stat()
check_stat(info, IMG_SIZE, order)
eq(image.features(), features)
eq(image.stripe_unit(), stripe_unit)
eq(image.stripe_count(), stripe_count)
image.close()
RBD().remove(ioctx, image_name)
def test_invalidate_cache(self):
self.image.write(b"abc", 0)
eq(b"abc", self.image.read(0, 3))
self.image.invalidate_cache()
eq(b"abc", self.image.read(0, 3))
def test_stat(self):
info = self.image.stat()
check_stat(info, IMG_SIZE, IMG_ORDER)
def test_flags(self):
flags = self.image.flags()
eq(0, flags)
def test_image_auto_close(self):
image = Image(ioctx, image_name)
def test_write(self):
data = rand_data(256)
self.image.write(data, 0)
def test_write_with_fadvise_flags(self):
data = rand_data(256)
self.image.write(data, 0, LIBRADOS_OP_FLAG_FADVISE_DONTNEED)
self.image.write(data, 0, LIBRADOS_OP_FLAG_FADVISE_NOCACHE)
def test_read(self):
data = self.image.read(0, 20)
eq(data, b"\0" * 20)
def test_read_with_fadvise_flags(self):
data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADVISE_DONTNEED)
eq(data, b"\0" * 20)
data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADVISE_RANDOM)
eq(data, b"\0" * 20)
def test_large_write(self):
data = rand_data(IMG_SIZE)
self.image.write(data, 0)
def test_large_read(self):
data = self.image.read(0, IMG_SIZE)
eq(data, b"\0" * IMG_SIZE)
def test_write_read(self):
data = rand_data(256)
offset = 50
self.image.write(data, offset)
read = self.image.read(offset, 256)
eq(data, read)
def test_read_bad_offset(self):
assert_raises(InvalidArgument, self.image.read, IMG_SIZE + 1, IMG_SIZE)
def test_resize(self):
new_size = IMG_SIZE * 2
self.image.resize(new_size)
info = self.image.stat()
check_stat(info, new_size, IMG_ORDER)
def test_size(self):
eq(IMG_SIZE, self.image.size())
self.image.create_snap("snap1")
new_size = IMG_SIZE * 2
self.image.resize(new_size)
eq(new_size, self.image.size())
#.........这里部分代码省略.........