当前位置: 首页>>代码示例>>Python>>正文


Python Image.parent_info方法代码示例

本文整理汇总了Python中rbd.Image.parent_info方法的典型用法代码示例。如果您正苦于以下问题:Python Image.parent_info方法的具体用法?Python Image.parent_info怎么用?Python Image.parent_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rbd.Image的用法示例。


在下文中一共展示了Image.parent_info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestClone

# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import parent_info [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_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')

        # 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_name)

        # check that we cannot yet remove the parent snap
        assert_raises(ImageBusy, self.image.remove_snap, 'snap1')

        other_ioctx.close()
        rados.delete_pool(pool_name2)

        # 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)
#.........这里部分代码省略.........
开发者ID:OyTao,项目名称:ceph-learning,代码行数:103,代码来源:test_rbd.py

示例2: TestClone

# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import parent_info [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, IMG_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.rbd.clone(ioctx, IMG_NAME, "snap1", ioctx, "clone", features)
        self.clone = Image(ioctx, "clone")

    def tearDown(self):
        global ioctx
        self.clone.close()
        self.rbd.remove(ioctx, "clone")
        self.image.unprotect_snap("snap1")
        self.image.remove_snap("snap1")
        self.image.close()
        remove_image()

    def test_unprotected(self):
        self.image.create_snap("snap2")
        global features
        assert_raises(InvalidArgument, self.rbd.clone, ioctx, IMG_NAME, "snap2", ioctx, "clone2", 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, "rbd")
        eq(image, IMG_NAME)
        eq(snap, "snap1")

        # create a new pool...
        rados.create_pool("rbd2")
        other_ioctx = rados.open_ioctx("rbd2")

        # ...with a clone of the same parent
        self.rbd.clone(ioctx, IMG_NAME, "snap1", other_ioctx, "other_clone", features)
        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)
#.........这里部分代码省略.........
开发者ID:AlphaStaxLLC,项目名称:ceph,代码行数:103,代码来源:test_rbd.py

示例3: TestClone

# 需要导入模块: from rbd import Image [as 别名]
# 或者: from rbd.Image import parent_info [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, IMG_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.rbd.clone(ioctx, IMG_NAME, 'snap1', ioctx, 'clone', features)
        self.clone = Image(ioctx, 'clone')

    def tearDown(self):
        global ioctx
        self.clone.close()
        self.rbd.remove(ioctx, 'clone')
        self.image.unprotect_snap('snap1')
        self.image.remove_snap('snap1')
        self.image.close()
        remove_image()

    def test_unprotected(self):
        self.image.create_snap('snap2')
        global features
        assert_raises(InvalidArgument, self.rbd.clone, ioctx, IMG_NAME, 'snap2', ioctx, 'clone2', 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, 'rbd')
        eq(image, IMG_NAME)
        eq(snap, 'snap1')

        # create a new pool...
        rados.create_pool('rbd2')
        other_ioctx = rados.open_ioctx('rbd2')

        # ...with a clone of the same parent
        self.rbd.clone(ioctx, IMG_NAME, 'snap1', other_ioctx, 'other_clone', features)
        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])
#.........这里部分代码省略.........
开发者ID:HubPeter,项目名称:ceph,代码行数:103,代码来源:test_rbd.py


注:本文中的rbd.Image.parent_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。