partition_utils.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:os-xenapi 作者: openstack 项目源码 文件源码
def make_partition(session, dev, partition_start, partition_end):
    # Since XS7.0 which has sfdisk V2.23, we observe sfdisk has a bug
    # that sfdisk will wrongly calculate cylinders when specify Sector
    # as unit (-uS). That bug will cause the partition operation failed.
    # And that's fixed in 2.26. So as a workaround, let's use the option
    # of '--force' for version <=2.25 and >=2.23. '--force' will ignore
    # the wrong cylinder value but works as expected.
    VER_FORCE_MIN = '2.23'
    VER_FORCE_MAX = '2.25'
    dev_path = utils.make_dev_path(dev)

    if partition_end != "-":
        raise pluginlib.PluginError("Can only create unbounded partitions")

    sfdisk_ver = _get_sfdisk_version()
    cmd_list = ['sfdisk', '-uS', dev_path]
    if sfdisk_ver:
        if StrictVersion(sfdisk_ver) >= StrictVersion(VER_FORCE_MIN) and \
           StrictVersion(sfdisk_ver) <= StrictVersion(VER_FORCE_MAX):
            cmd_list = ['sfdisk', '--force', '-uS', dev_path]

    utils.run_command(cmd_list, '%s,;\n' % (partition_start))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号