本文整理汇总了Python中aquilon.config.Config.sections方法的典型用法代码示例。如果您正苦于以下问题:Python Config.sections方法的具体用法?Python Config.sections怎么用?Python Config.sections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aquilon.config.Config
的用法示例。
在下文中一共展示了Config.sections方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: discover_network_types
# 需要导入模块: from aquilon.config import Config [as 别名]
# 或者: from aquilon.config.Config import sections [as 别名]
def discover_network_types(dbapi_con, connection_record): # pylint: disable=W0613
config = Config()
if not config.has_option("broker", "default_network_type"): # pragma: no cover
raise InternalError("The default_network_type option is missing from "
"the [broker] section in the configuration.")
default_type = config.get("broker", "default_network_type")
default_section = "network_" + default_type
if not config.has_section(default_section): # pragma: no cover
raise InternalError("The default network type is %s, but there's no "
"section named [%s] in the configuration." %
(default_type, default_section))
nettypes = {}
# This function should be called only once, but you never know...
if Network.network_type_map:
return
for section in config.sections():
if not section.startswith("network_"):
continue
name = section[8:]
nettypes[name] = NetworkProperties(config, name)
LOGGER.info("Configured network type %s", name)
Network.network_type_map = nettypes
Network.default_network_props = nettypes[default_type]