本文整理汇总了Python中cattle.Config.volmgr_root方法的典型用法代码示例。如果您正苦于以下问题:Python Config.volmgr_root方法的具体用法?Python Config.volmgr_root怎么用?Python Config.volmgr_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cattle.Config
的用法示例。
在下文中一共展示了Config.volmgr_root方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_startup
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import volmgr_root [as 别名]
def on_startup(self):
if not enabled():
return
log.info("Volmgr enabled")
driver = Config.volmgr_storage_driver()
if driver != "devicemapper":
raise Exception("Unknown volmgr driver %s" % (driver))
data_dev = Config.volmgr_dm_data_device()
metadata_dev = Config.volmgr_dm_metadata_device()
if data_dev != "" and metadata_dev != "":
if os.path.exists(data_dev) and os.path.exists(metadata_dev):
raise Exception("Provided data_dev %s and metadata_dev %s, \
but unable to find the devices" % (
data_dev, metadata_dev))
elif (data_dev == "") ^ (metadata_dev == ""):
raise Exception("Only one of two device mapper devices \
are specified")
data_file = Config.volmgr_dm_data_file()
metadata_file = Config.volmgr_dm_metadata_file()
if os.path.exists(data_file) and os.path.exists(metadata_file):
log.info("Found existed device mapper data and metadata file,"
"load them to loopback device")
elif not (os.path.exists(data_file) or os.path.exists(metadata_file)):
log.info("Existed device mapper data and metadata file not found, "
"create them")
service.create_pool_files(data_file, metadata_file)
else:
raise Exception("Only one of data or metadata file exists, "
"please clean up %s ,%s" % (data_file,
metadata_file))
if data_dev == "":
data_dev = service.register_loopback(data_file)
log.info("Loaded %s to %s" % (data_file, data_dev))
metadata_dev = service.register_loopback(metadata_file)
log.info("Loaded %s to %s" % (metadata_file, metadata_dev))
root_dir = Config.volmgr_root()
mount_dir = Config.volmgr_mount_dir()
if not os.path.exists(root_dir):
os.makedirs(root_dir)
log.info("Root_dir for volmgr at %s " % root_dir)
if not os.path.exists(mount_dir):
os.makedirs(mount_dir)
log.info("Mount_dir for volmgr at %s " % mount_dir)
base_cmdline = ["volmgr", "--debug",
"--log", Config.volmgr_log_file(),
"--root", root_dir]
global v
v = VolmgrService(base_cmdline)
pool_name = Config.volmgr_pool_name()
# TODO better for volmgr to verify cfg is the same
if not os.path.exists(os.path.join(root_dir, "volmgr.cfg")):
v.init(driver, data_dev, metadata_dev, pool_name)
log.info("Complete init for volmgr, init pool %s" % pool_name)
global blockstore_uuid
if not os.path.exists(Config.volmgr_blockstore_dir()):
os.makedirs(Config.volmgr_blockstore_dir())
blockstore_uuid = v.register_vfs_blockstore(
Config.volmgr_blockstore_dir())
log.info("Complete register blockstore for volmgr at %s, uuid %s" % (
Config.volmgr_blockstore_dir(), blockstore_uuid))