本文整理汇总了Python中rbd.Image.list_children方法的典型用法代码示例。如果您正苦于以下问题:Python Image.list_children方法的具体用法?Python Image.list_children怎么用?Python Image.list_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rbd.Image
的用法示例。
在下文中一共展示了Image.list_children方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestClone
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import list_children [as 别名]
#.........这里部分代码省略.........
parent_data = self.image.read(IMG_SIZE / 2, 256)
self.image.resize(0)
self.clone.resize(IMG_SIZE / 2 + 128)
child_data = self.clone.read(IMG_SIZE / 2, 128)
eq(child_data, parent_data[:128])
self.clone.resize(IMG_SIZE)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data[:128] + ('\0' * 128))
self.clone.resize(IMG_SIZE / 2 + 1)
child_data = self.clone.read(IMG_SIZE / 2, 1)
eq(child_data, parent_data[0])
self.clone.resize(0)
self.clone.resize(IMG_SIZE)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, '\0' * 256)
def test_read(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data)
def test_write(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
new_data = rand_data(256)
self.clone.write(new_data, IMG_SIZE / 2 + 256)
child_data = self.clone.read(IMG_SIZE / 2 + 256, 256)
eq(child_data, new_data)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data)
parent_data = self.image.read(IMG_SIZE / 2 + 256, 256)
eq(parent_data, '\0' * 256)
def check_children(self, expected):
actual = self.image.list_children()
# dedup for cache pools until
# http://tracker.ceph.com/issues/8187 is fixed
deduped = set([(pool_name, image[1]) for image in actual])
eq(deduped, set(expected))
def test_list_children(self):
global ioctx
global features
self.image.set_snap('snap1')
self.check_children([(pool_name, self.clone_name)])
self.clone.close()
self.rbd.remove(ioctx, self.clone_name)
eq(self.image.list_children(), [])
clone_name = get_temp_image_name() + '_'
expected_children = []
for i in xrange(10):
self.rbd.clone(ioctx, image_name, 'snap1', ioctx,
clone_name + str(i), features)
expected_children.append((pool_name, clone_name + str(i)))
self.check_children(expected_children)
for i in xrange(10):
self.rbd.remove(ioctx, clone_name + str(i))
expected_children.pop(0)
self.check_children(expected_children)
eq(self.image.list_children(), [])
self.rbd.clone(ioctx, image_name, 'snap1', ioctx, self.clone_name,
features)
self.check_children([(pool_name, self.clone_name)])
self.clone = Image(ioctx, self.clone_name)
示例2: TestClone
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import list_children [as 别名]
#.........这里部分代码省略.........
def test_resize_io(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
self.clone.resize(IMG_SIZE / 2 + 128)
child_data = self.clone.read(IMG_SIZE / 2, 128)
eq(child_data, parent_data[:128])
self.clone.resize(IMG_SIZE)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data[:128] + ("\0" * 128))
self.clone.resize(IMG_SIZE / 2 + 1)
child_data = self.clone.read(IMG_SIZE / 2, 1)
eq(child_data, parent_data[0])
self.clone.resize(0)
self.clone.resize(IMG_SIZE)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, "\0" * 256)
def test_read(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data)
def test_write(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
new_data = rand_data(256)
self.clone.write(new_data, IMG_SIZE / 2 + 256)
child_data = self.clone.read(IMG_SIZE / 2 + 256, 256)
eq(child_data, new_data)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data)
parent_data = self.image.read(IMG_SIZE / 2 + 256, 256)
eq(parent_data, "\0" * 256)
def test_list_children(self):
global ioctx
global features
self.image.set_snap("snap1")
eq(self.image.list_children(), [("rbd", "clone")])
self.clone.close()
self.rbd.remove(ioctx, "clone")
eq(self.image.list_children(), [])
expected_children = []
for i in xrange(10):
self.rbd.clone(ioctx, IMG_NAME, "snap1", ioctx, "clone%d" % i, features)
expected_children.append(("rbd", "clone%d" % i))
eq(self.image.list_children(), expected_children)
for i in xrange(10):
self.rbd.remove(ioctx, "clone%d" % i)
expected_children.pop(0)
eq(self.image.list_children(), expected_children)
eq(self.image.list_children(), [])
self.rbd.clone(ioctx, IMG_NAME, "snap1", ioctx, "clone", features)
eq(self.image.list_children(), [("rbd", "clone")])
self.clone = Image(ioctx, "clone")
def test_flatten_errors(self):
# test that we can't flatten a non-clone
assert_raises(InvalidArgument, self.image.flatten)
# test that we can't flatten a snapshot
self.clone.create_snap("snap2")
self.clone.set_snap("snap2")
assert_raises(ReadOnlyImage, self.clone.flatten)
示例3: TestClone
# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import list_children [as 别名]
#.........这里部分代码省略.........
self.other_clone = Image(other_ioctx, 'other_clone')
# validate its parent info
(pool, image, snap) = self.other_clone.parent_info()
eq(pool, 'rbd')
eq(image, IMG_NAME)
eq(snap, 'snap1')
# can't unprotect snap with children
assert_raises(ImageBusy, self.image.unprotect_snap, 'snap1')
# 2 children, check that cannot remove the parent snap
assert_raises(ImageBusy, self.image.remove_snap, 'snap1')
# close and remove other pool's clone
self.other_clone.close()
self.rbd.remove(other_ioctx, 'other_clone')
# check that we cannot yet remove the parent snap
assert_raises(ImageBusy, self.image.remove_snap, 'snap1')
other_ioctx.close()
rados.delete_pool('rbd2')
# unprotect, remove parent snap happen in cleanup, and should succeed
def test_stat(self):
image_info = self.image.stat()
clone_info = self.clone.stat()
eq(clone_info['size'], image_info['size'])
eq(clone_info['size'], self.clone.overlap())
def test_resize_stat(self):
self.clone.resize(IMG_SIZE / 2)
image_info = self.image.stat()
clone_info = self.clone.stat()
eq(clone_info['size'], IMG_SIZE / 2)
eq(image_info['size'], IMG_SIZE)
eq(self.clone.overlap(), IMG_SIZE / 2)
self.clone.resize(IMG_SIZE * 2)
image_info = self.image.stat()
clone_info = self.clone.stat()
eq(clone_info['size'], IMG_SIZE * 2)
eq(image_info['size'], IMG_SIZE)
eq(self.clone.overlap(), IMG_SIZE / 2)
def test_resize_io(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
self.clone.resize(IMG_SIZE / 2 + 128)
child_data = self.clone.read(IMG_SIZE / 2, 128)
eq(child_data, parent_data[:128])
self.clone.resize(IMG_SIZE)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data[:128] + ('\0' * 128))
self.clone.resize(IMG_SIZE / 2 + 1)
child_data = self.clone.read(IMG_SIZE / 2, 1)
eq(child_data, parent_data[0])
self.clone.resize(0)
self.clone.resize(IMG_SIZE)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, '\0' * 256)
def test_read(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data)
def test_write(self):
parent_data = self.image.read(IMG_SIZE / 2, 256)
new_data = rand_data(256)
self.clone.write(new_data, IMG_SIZE / 2 + 256)
child_data = self.clone.read(IMG_SIZE / 2 + 256, 256)
eq(child_data, new_data)
child_data = self.clone.read(IMG_SIZE / 2, 256)
eq(child_data, parent_data)
parent_data = self.image.read(IMG_SIZE / 2 + 256, 256)
eq(parent_data, '\0' * 256)
def test_list_children(self):
global ioctx
global features
self.image.set_snap('snap1')
eq(self.image.list_children(), [('rbd', 'clone')])
self.rbd.remove(ioctx, 'clone')
eq(self.image.list_children(), [])
expected_children = []
for i in xrange(10):
self.rbd.clone(ioctx, IMG_NAME, 'snap1', ioctx, 'clone%d' % i, features)
expected_children.append(('rbd', 'clone%d' % i))
eq(self.image.list_children(), expected_children)
for i in xrange(10):
self.rbd.remove(ioctx, 'clone%d' % i)
expected_children.pop(0)
eq(self.image.list_children(), expected_children)
eq(self.image.list_children(), [])
self.rbd.clone(ioctx, IMG_NAME, 'snap1', ioctx, 'clone', features)
eq(self.image.list_children(), [('rbd', 'clone')])