本文整理汇总了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
示例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())
示例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))
示例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