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


Python qemuimg.create函数代码示例

本文整理汇总了Python中vdsm.qemuimg.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_wrong_format_raises

 def test_wrong_format_raises(self, vol_fmt, qemu_fmt):
     with self.fake_volume(vol_fmt) as vol:
         qemuimg.create(vol.volumePath, size=self.SIZE, format=qemu_fmt)
         h = FakeHSM()
         self.assertRaises(se.ImageVerificationError,
                           h.verify_untrusted_volume,
                           'sp', vol.sdUUID, vol.imgUUID, vol.volUUID)
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:storage_hsm_test.py

示例2: test_invalid_config

 def test_invalid_config(self):
     config = make_config([('irs', 'qcow2_compat', '1.2')])
     with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat',
                             self.supported('create', True)),
                            (qemuimg, 'config', config)]):
         with self.assertRaises(exception.InvalidConfiguration):
             qemuimg.create('image', format='qcow2')
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:7,代码来源:qemuimgTests.py

示例3: make_volume

def make_volume(env, size, md_fmt, real_fmt):
    img_id = make_uuid()
    vol_id = make_uuid()
    env.make_volume(size, img_id, vol_id, vol_format=md_formats[md_fmt])
    vol = env.sd_manifest.produceVolume(img_id, vol_id)
    qemuimg.create(vol.getVolumePath(), size, qemu_formats[real_fmt])
    return vol
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:storage_workarounds_test.py

示例4: test_check

 def test_check(self):
     with namedTemporaryDir() as tmpdir:
         path = os.path.join(tmpdir, 'test.qcow2')
         qemuimg.create(path, size=1048576, format=qemuimg.FORMAT.QCOW2)
         info = qemuimg.check(path)
         # The exact value depends on qcow2 internals
         self.assertEqual(int, type(info['offset']))
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:qemuimgTests.py

示例5: test_ok

 def test_ok(self, vol_fmt):
     with self.fake_volume(vol_fmt) as vol:
         qemu_fmt = sc.FMT2STR[vol_fmt]
         qemuimg.create(vol.volumePath, size=self.SIZE, format=qemu_fmt)
         h = FakeHSM()
         self.assertNotRaises(h.verify_untrusted_volume,
                              'sp', vol.sdUUID, vol.imgUUID, vol.volUUID)
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:storage_hsm_test.py

示例6: clone

 def clone(self, dstPath, volFormat):
     """
     Clone self volume to the specified dst_image_dir/dst_volUUID
     """
     wasleaf = False
     taskName = "parent volume rollback: " + self.volUUID
     vars.task.pushRecovery(
         task.Recovery(taskName, "volume", "Volume",
                       "parentVolumeRollback",
                       [self.sdUUID, self.imgUUID, self.volUUID]))
     if self.isLeaf():
         wasleaf = True
         self.setInternal()
     try:
         self.prepare(rw=False)
         self.log.debug('cloning volume %s to %s', self.volumePath,
                        dstPath)
         parent = getBackingVolumePath(self.imgUUID, self.volUUID)
         qemuimg.create(dstPath, backing=parent,
                        format=fmt2str(volFormat),
                        backingFormat=fmt2str(self.getFormat()))
         self.teardown(self.sdUUID, self.volUUID)
     except Exception as e:
         self.log.exception('cannot clone image %s volume %s to %s',
                            self.imgUUID, self.volUUID, dstPath)
         # FIXME: might race with other clones
         if wasleaf:
             self.setLeaf()
         self.teardown(self.sdUUID, self.volUUID)
         raise se.CannotCloneVolume(self.volumePath, dstPath, str(e))
开发者ID:mykaul,项目名称:vdsm,代码行数:30,代码来源:volume.py

示例7: test_no_format

    def test_no_format(self):
        def create(cmd, **kw):
            expected = [QEMU_IMG, 'create', 'image']
            self.assertEqual(cmd, expected)
            return 0, '', ''

        with MonkeyPatchScope([(commands, "execCmd", create)]):
            qemuimg.create('image')
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:8,代码来源:qemuimgTests.py

示例8: test_zero_size

    def test_zero_size(self):
        def create(cmd, **kw):
            expected = [QEMU_IMG, 'create', 'image', '0']
            self.assertEqual(cmd, expected)
            return 0, '', ''

        with MonkeyPatchScope([(utils, "execCmd", create)]):
            qemuimg.create('image', size=0)
开发者ID:fancyKai,项目名称:vdsm,代码行数:8,代码来源:qemuimgTests.py

示例9: test_no_format

    def test_no_format(self):
        def create(cmd, **kw):
            expected = [QEMU_IMG, 'create', 'image']
            self.assertEqual(cmd, expected)
            return 0, '', ''

        with FakeCmd(utils, 'execCmd', create):
            qemuimg.create('image')
开发者ID:aiminickwong,项目名称:vdsm,代码行数:8,代码来源:qemuimgTests.py

示例10: test_no_format

    def test_no_format(self):

        def create_no_format(cmd, **kw):
            assert cmd == [qemuimg._qemuimg.cmd, 'create', 'image']
            return 0, '', ''

        with FakeExecCmd(create_no_format):
            qemuimg.create('image')
开发者ID:mpavlase,项目名称:vdsm,代码行数:8,代码来源:qemuimgTests.py

示例11: _create

    def _create(cls, dom, imgUUID, volUUID, size, volFormat, preallocate,
                volParent, srcImgUUID, srcVolUUID, volPath,
                initialSize=None):
        """
        Class specific implementation of volumeCreate. All the exceptions are
        properly handled and logged in volume.create()
        """
        if initialSize:
            cls.log.error("initialSize is not supported for file-based "
                          "volumes")
            raise se.InvalidParameterException("initial size",
                                               initialSize)

        sizeBytes = size * BLOCK_SIZE
        truncSize = sizeBytes if volFormat == sc.RAW_FORMAT else 0

        try:
            oop.getProcessPool(dom.sdUUID).truncateFile(
                volPath, truncSize, mode=sc.FILE_VOLUME_PERMISSIONS,
                creatExcl=True)
        except OSError as e:
            if e.errno == errno.EEXIST:
                raise se.VolumeAlreadyExists(volUUID)
            raise

        if preallocate == sc.PREALLOCATED_VOL:
            try:
                operation = fallocate.allocate(volPath,
                                               sizeBytes)
                with vars.task.abort_callback(operation.abort):
                    with utils.stopwatch("Preallocating volume %s" % volPath):
                        operation.run()
            except exception.ActionStopped:
                raise
            except Exception:
                cls.log.error("Unexpected error", exc_info=True)
                raise se.VolumesZeroingError(volPath)

        if not volParent:
            cls.log.info("Request to create %s volume %s with size = %s "
                         "sectors", sc.type2name(volFormat), volPath,
                         size)
            if volFormat == sc.COW_FORMAT:
                qemuimg.create(volPath,
                               size=sizeBytes,
                               format=sc.fmt2str(volFormat),
                               qcow2Compat=dom.qcow2_compat())
        else:
            # Create hardlink to template and its meta file
            cls.log.info("Request to create snapshot %s/%s of volume %s/%s",
                         imgUUID, volUUID, srcImgUUID, srcVolUUID)
            volParent.clone(volPath, volFormat)

        # Forcing the volume permissions in case one of the tools we use
        # (dd, qemu-img, etc.) will mistakenly change the file permissiosn.
        dom.oop.os.chmod(volPath, sc.FILE_VOLUME_PERMISSIONS)

        return (volPath,)
开发者ID:EdDev,项目名称:vdsm,代码行数:58,代码来源:fileVolume.py

示例12: test_backingfile_raises

 def test_backingfile_raises(self):
     with self.fake_volume(sc.COW_FORMAT) as vol:
         qemu_fmt = qemuimg.FORMAT.QCOW2
         qemuimg.create(vol.volumePath, size=self.SIZE, format=qemu_fmt,
                        backing='foo')
         h = FakeHSM()
         self.assertRaises(se.ImageVerificationError,
                           h.verify_untrusted_volume,
                           'sp', vol.sdUUID, vol.imgUUID, vol.volUUID)
开发者ID:yingyun001,项目名称:vdsm,代码行数:9,代码来源:storage_hsm_test.py

示例13: test_qcow2_compat_unsupported

    def test_qcow2_compat_unsupported(self):
        def create(cmd, **kw):
            expected = [QEMU_IMG, 'create', '-f', 'qcow2', 'image']
            self.assertEqual(cmd, expected)
            return 0, '', ''

        with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat',
                                self.supported('create', False)),
                               (utils, 'execCmd', create)]):
            qemuimg.create('image', format='qcow2')
开发者ID:fancyKai,项目名称:vdsm,代码行数:10,代码来源:qemuimgTests.py

示例14: make_volume

 def make_volume(self, env, img_id, vol_id, parent_vol_id, vol_fmt):
     if parent_vol_id != sc.BLANK_UUID:
         vol_fmt = sc.COW_FORMAT
     env.make_volume(self.SIZE, img_id, vol_id,
                     parent_vol_id=parent_vol_id, vol_format=vol_fmt)
     vol = env.sd_manifest.produceVolume(img_id, vol_id)
     if vol_fmt == sc.COW_FORMAT:
         backing = parent_vol_id if parent_vol_id != sc.BLANK_UUID else None
         qemuimg.create(vol.volumePath, size=self.SIZE,
                        format=qemuimg.FORMAT.QCOW2, backing=backing)
     return vol
开发者ID:yingyun001,项目名称:vdsm,代码行数:11,代码来源:storage_sdm_copy_data_test.py

示例15: test_qcow2_compat

    def test_qcow2_compat(self):

        def create(cmd, **kw):
            expected = [QEMU_IMG, 'create', '-f', 'qcow2', '-o', 'compat=0.10',
                        'image']
            self.assertEqual(cmd, expected)
            return 0, '', ''

        with MonkeyPatchScope([(qemuimg, 'config', CONFIG),
                               (commands, 'execCmd', create)]):
            qemuimg.create('image', format='qcow2')
开发者ID:yingyun001,项目名称:vdsm,代码行数:11,代码来源:qemuimgTests.py


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