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


Python Config.volmgr_mount_namespace_fd方法代码示例

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


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

示例1: _get_volume

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import volmgr_mount_namespace_fd [as 别名]
def _get_volume(vol_name, vol_size, instance_name, user):
    path = _get_volume_dir(vol_name, user)
    if os.path.exists(path):
        volume_uuid = _get_volume_uuid(path)
        create = False
        if volume_uuid == "":
            log.warning("Found volume directory but cannot find related \
                    volume! Create one")
            create = True

        assert _get_volume_instance_name(path) == instance_name

        if not create:
            mount_dir = os.path.join(path, volume_uuid)
            if not service.mounted(mount_dir,
                                   Config.volmgr_mount_namespace_fd()):
                v.mount_volume(volume_uuid, mount_dir, False,
                               Config.volmgr_mount_namespace_fd())
            return mount_dir

    volume_uuid = v.create_volume(vol_size)
    v.add_volume_to_blockstore(volume_uuid, blockstore_uuid)
    mount_dir = os.path.join(path, volume_uuid)
    os.makedirs(mount_dir)
    f = open(os.path.join(path, INSTANCE_TAG_FILE), "w")
    try:
        f.write(instance_name)
    finally:
        f.close()
    v.mount_volume(volume_uuid, mount_dir, True,
                   Config.volmgr_mount_namespace_fd())
    return mount_dir
开发者ID:aruneli,项目名称:python-agent,代码行数:34,代码来源:volmgr.py

示例2: volume_exists

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import volmgr_mount_namespace_fd [as 别名]
def volume_exists(path):
    if not enabled():
        return False
    if not path.startswith(Config.volmgr_mount_dir()):
        return False
    if not os.path.exists(path):
        return False
    return service.mounted(path, Config.volmgr_mount_namespace_fd())
开发者ID:aruneli,项目名称:python-agent,代码行数:10,代码来源:volmgr.py

示例3: remove_volume

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import volmgr_mount_namespace_fd [as 别名]
def remove_volume(path):
    if not enabled():
        return
    if not volume_exists(path):
        return
    volume_name_path = path.rsplit('/', 1)[0]
    volume_uuid = path.rsplit('/', 1)[1]
    log.info("Removing volume %s for instance %s" % (
             volume_uuid, _get_volume_instance_name(volume_name_path)))
    remove_internal_snapshots_for_volume(volume_uuid)
    v.umount_volume(volume_uuid, Config.volmgr_mount_namespace_fd())
    v.delete_volume(volume_uuid)
    shutil.rmtree(volume_name_path)
    log.info("Cleaned volume %s's mount directory at %s" % (
             volume_uuid, volume_name_path))
开发者ID:aruneli,项目名称:python-agent,代码行数:17,代码来源:volmgr.py

示例4: _restore_snapshot

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import volmgr_mount_namespace_fd [as 别名]
def _restore_snapshot(vol_name, old_volume_uuid, vol_size,
                      snapshot_uuid, instance_name, user):
    path = _get_volume_dir(vol_name, user)
    if os.path.exists(path):
        log.info("Already found the volume, skip restore")
        volume_uuid = _get_volume_uuid(path)
        return os.path.join(path, volume_uuid)
    volume_uuid = v.create_volume(vol_size)
    v.restore_snapshot_from_blockstore(snapshot_uuid, old_volume_uuid,
                                       volume_uuid, blockstore_uuid)
    v.add_volume_to_blockstore(volume_uuid, blockstore_uuid)

    mount_dir = os.path.join(path, volume_uuid)
    os.makedirs(mount_dir)
    f = open(os.path.join(path, INSTANCE_TAG_FILE), "w")
    try:
        f.write(instance_name)
    finally:
        f.close()
    v.mount_volume(volume_uuid, mount_dir, False,
                   Config.volmgr_mount_namespace_fd())
    return mount_dir
开发者ID:aruneli,项目名称:python-agent,代码行数:24,代码来源:volmgr.py


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