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


Python VDiskController.create_volume方法代码示例

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


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

示例1: create_volume

# 需要导入模块: from ovs.lib.vdisk import VDiskController [as 别名]
# 或者: from ovs.lib.vdisk.VDiskController import create_volume [as 别名]
    def create_volume(self, volume):
        """Creates a volume.
        Called on "cinder create ..." or "nova volume-create ..."
        :param volume: volume reference (sqlalchemy Model)
        """
        _debug_vol_info("CREATE", volume)

        hostname = str(volume.host)
        name = volume.display_name
        if not name:
            name = volume.name
        mountpoint = self._get_hostname_mountpoint(hostname)
        location = '{}/{}.raw'.format(mountpoint, name)
        size = volume.size

        LOG.info('DO_CREATE_VOLUME %s %s' % (location, size))
        VDiskController.create_volume(location = location,
                                      size = size)
        volume['provider_location'] = location

        try:
            ovs_disk = self._find_ovs_model_disk_by_location(location,
                                                             hostname)
        except RuntimeError:
            VDiskController.delete_volume(location = location)
            raise

        ovs_disk.cinder_id = volume.id
        ovs_disk.name = name
        ovs_disk.save()
        return {'provider_location': volume['provider_location']}
开发者ID:jianyongchen,项目名称:openvstorage,代码行数:33,代码来源:openvstorage.py

示例2: download_to_vpool

# 需要导入模块: from ovs.lib.vdisk import VDiskController [as 别名]
# 或者: from ovs.lib.vdisk.VDiskController import create_volume [as 别名]
    def download_to_vpool(url, path, overwrite_if_exists=False):
        """
        Special method to download to vpool because voldrv does not support extending file at write
        :param url: URL to download from
        :type url: str

        :param path: Path to download to
        :type path: str

        :param overwrite_if_exists: Overwrite if file already exists
        :type overwrite_if_exists: bool

        :return: None
        """
        print url
        print path
        if os.path.exists(path) and not overwrite_if_exists:
            return
        u = urllib.urlopen(url)
        file_size = u.info()['Content-Length']
        bsize = 4096 * 1024
        VDiskController.create_volume(path, 0)
        with open(path, "wb") as f:
            size_written = 0
            os.ftruncate(f.fileno(), int(file_size))
            while 1:
                s = u.read(bsize)
                size_written += len(s)
                f.write(s)
                if len(s) < bsize:
                    break
        u.close()
开发者ID:openvstorage,项目名称:integrationtests,代码行数:34,代码来源:general_hypervisor.py


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