當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.OPENSTACK_CODENAMES屬性代碼示例

本文整理匯總了Python中charmhelpers.contrib.openstack.utils.OPENSTACK_CODENAMES屬性的典型用法代碼示例。如果您正苦於以下問題:Python utils.OPENSTACK_CODENAMES屬性的具體用法?Python utils.OPENSTACK_CODENAMES怎麽用?Python utils.OPENSTACK_CODENAMES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在charmhelpers.contrib.openstack.utils的用法示例。


在下文中一共展示了utils.OPENSTACK_CODENAMES屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_loader

# 需要導入模塊: from charmhelpers.contrib.openstack import utils [as 別名]
# 或者: from charmhelpers.contrib.openstack.utils import OPENSTACK_CODENAMES [as 別名]
def get_loader(templates_dir, os_release):
    """
    Create a jinja2.ChoiceLoader containing template dirs up to
    and including os_release.  If directory template directory
    is missing at templates_dir, it will be omitted from the loader.
    templates_dir is added to the bottom of the search list as a base
    loading dir.

    A charm may also ship a templates dir with this module
    and it will be appended to the bottom of the search list, eg::

        hooks/charmhelpers/contrib/openstack/templates

    :param templates_dir (str): Base template directory containing release
        sub-directories.
    :param os_release (str): OpenStack release codename to construct template
        loader.
    :returns: jinja2.ChoiceLoader constructed with a list of
        jinja2.FilesystemLoaders, ordered in descending
        order by OpenStack release.
    """
    tmpl_dirs = [(rel, os.path.join(templates_dir, rel))
                 for rel in six.itervalues(OPENSTACK_CODENAMES)]

    if not os.path.isdir(templates_dir):
        log('Templates directory not found @ %s.' % templates_dir,
            level=ERROR)
        raise OSConfigException

    # the bottom contains tempaltes_dir and possibly a common templates dir
    # shipped with the helper.
    loaders = [FileSystemLoader(templates_dir)]
    helper_templates = os.path.join(os.path.dirname(__file__), 'templates')
    if os.path.isdir(helper_templates):
        loaders.append(FileSystemLoader(helper_templates))

    for rel, tmpl_dir in tmpl_dirs:
        if os.path.isdir(tmpl_dir):
            loaders.insert(0, FileSystemLoader(tmpl_dir))
        if rel == os_release:
            break
    log('Creating choice loader with dirs: %s' %
        [l.searchpath for l in loaders], level=INFO)
    return ChoiceLoader(loaders) 
開發者ID:openstack,項目名稱:charm-plumgrid-gateway,代碼行數:46,代碼來源:templating.py

示例2: get_loader

# 需要導入模塊: from charmhelpers.contrib.openstack import utils [as 別名]
# 或者: from charmhelpers.contrib.openstack.utils import OPENSTACK_CODENAMES [as 別名]
def get_loader(templates_dir, os_release):
    """
    Create a jinja2.ChoiceLoader containing template dirs up to
    and including os_release.  If directory template directory
    is missing at templates_dir, it will be omitted from the loader.
    templates_dir is added to the bottom of the search list as a base
    loading dir.

    A charm may also ship a templates dir with this module
    and it will be appended to the bottom of the search list, eg::

        hooks/charmhelpers/contrib/openstack/templates

    :param templates_dir (str): Base template directory containing release
        sub-directories.
    :param os_release (str): OpenStack release codename to construct template
        loader.
    :returns: jinja2.ChoiceLoader constructed with a list of
        jinja2.FilesystemLoaders, ordered in descending
        order by OpenStack release.
    """
    tmpl_dirs = [(rel, os.path.join(templates_dir, rel))
                 for rel in six.itervalues(OPENSTACK_CODENAMES)]

    if not os.path.isdir(templates_dir):
        log('Templates directory not found @ %s.' % templates_dir,
            level=ERROR)
        raise OSConfigException

    # the bottom contains tempaltes_dir and possibly a common templates dir
    # shipped with the helper.
    loaders = [FileSystemLoader(templates_dir)]
    helper_templates = os.path.join(os.path.dirname(__file__), 'templates')
    if os.path.isdir(helper_templates):
        loaders.append(FileSystemLoader(helper_templates))

    for rel, tmpl_dir in tmpl_dirs:
        if os.path.isdir(tmpl_dir):
            loaders.insert(0, FileSystemLoader(tmpl_dir))
        if rel == os_release:
            break
    # demote this log to the lowest level; we don't really need to see these
    # lots in production even when debugging.
    log('Creating choice loader with dirs: %s' %
        [l.searchpath for l in loaders], level=TRACE)
    return ChoiceLoader(loaders) 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:48,代碼來源:templating.py


注:本文中的charmhelpers.contrib.openstack.utils.OPENSTACK_CODENAMES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。