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


Python templating.get_loader方法代码示例

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


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

示例1: test_get_loader_all_search_paths

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def test_get_loader_all_search_paths(self, isdir):
        '''Ensure loader reverse searches of all release template dirs'''
        isdir.return_value = True
        choice_loader = templating.get_loader('/tmp/foo',
                                              os_release='icehouse')
        dirs = [l.searchpath for l in choice_loader.loaders]

        common_tmplts = os.path.join(os.path.dirname(templating.__file__),
                                     'templates')
        expected = [['/tmp/foo/icehouse'],
                    ['/tmp/foo/havana'],
                    ['/tmp/foo/grizzly'],
                    ['/tmp/foo/folsom'],
                    ['/tmp/foo/essex'],
                    ['/tmp/foo/diablo'],
                    ['/tmp/foo'],
                    [common_tmplts]]
        self.assertEquals(dirs, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:20,代码来源:test_os_templating.py

示例2: test_get_loader_some_search_paths

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def test_get_loader_some_search_paths(self, isdir):
        '''Ensure loader reverse searches of some release template dirs'''
        isdir.return_value = True
        choice_loader = templating.get_loader('/tmp/foo', os_release='grizzly')
        dirs = [l.searchpath for l in choice_loader.loaders]

        common_tmplts = os.path.join(os.path.dirname(templating.__file__),
                                     'templates')

        expected = [['/tmp/foo/grizzly'],
                    ['/tmp/foo/folsom'],
                    ['/tmp/foo/essex'],
                    ['/tmp/foo/diablo'],
                    ['/tmp/foo'],
                    [common_tmplts]]
        self.assertEquals(dirs, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:18,代码来源:test_os_templating.py

示例3: get_template_for_release

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def get_template_for_release(self, os_release, mock_log):
        loader = get_loader('./templates', os_release)
        env = Environment(loader=loader)

        return env.get_template('proxy-server.conf') 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:7,代码来源:test_templates.py

示例4: render_config

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def render_config(self, restart_trigger):
        """Render the domain specific LDAP configuration for the application
        """
        checksum = ch_host.path_hash(self.configuration_file)
        core.templating.render(
            source=KEYSTONE_CONF_TEMPLATE,
            template_loader=os_templating.get_loader(
                'templates/', self.release),
            target=self.configuration_file,
            context=self.adapters_instance)
        if checksum != ch_host.path_hash(self.configuration_file):
            restart_trigger() 
开发者ID:openstack,项目名称:charm-keystone-ldap,代码行数:14,代码来源:keystone_ldap.py

示例5: get_template_for_release_and_server

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def get_template_for_release_and_server(
            self,
            os_release,
            server,
            mock_log):

        if not server:
            server = 'object'

        loader = get_loader('./templates', os_release)
        env = Environment(loader=loader)

        return env.get_template('{}-server.conf'.format(server)) 
开发者ID:openstack,项目名称:charm-swift-storage,代码行数:15,代码来源:test_templates.py

示例6: render_configs

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def render_configs(self, configs, adapters_instance=None):
        """Render the configuration files identified in the list passed as
        configs.

        If adapters_instance is None then the self.adapters_instance is used
        that was setup in the __init__() method.  Note, if no interfaces were
        passed (the default) then there will be no interfaces.

        TODO: need to work out how to make this function more useful - at the
        moment, with a default setup, this function is only useful to
        render_with_interfaces() which constructs a new adapters_instance
        anyway.

        :param configs: list of strings, the names of the configuration files.
        :param adapters_instance: [optional] the adapters_instance to use.
        """
        if adapters_instance is None:
            adapters_instance = self.adapters_instance
        with self.restart_on_change():
            for conf in configs:
                charmhelpers.core.templating.render(
                    source=os.path.basename(conf),
                    template_loader=os_templating.get_loader(
                        'templates/', self.release),
                    target=conf,
                    context=adapters_instance) 
开发者ID:openstack,项目名称:charms.openstack,代码行数:28,代码来源:core.py

示例7: test_get_loader_no_templates_dir

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def test_get_loader_no_templates_dir(self, isdir):
        '''Ensure getting loader fails with no template dir'''
        isdir.return_value = False
        self.assertRaises(templating.OSConfigException,
                          templating.get_loader,
                          templates_dir='/tmp/foo', os_release='foo') 
开发者ID:juju,项目名称:charm-helpers,代码行数:8,代码来源:test_os_templating.py

示例8: get_config_for_principal

# 需要导入模块: from charmhelpers.contrib.openstack import templating [as 别名]
# 或者: from charmhelpers.contrib.openstack.templating import get_loader [as 别名]
def get_config_for_principal(self, auth_data):
        """Assuming that the configuration data is valid, return the
        configuration data for the principal charm.

        The format of the complete returned data is:
        {
            "<config file>: <string>
        }

        If the configuration is not complete, or we don't have auth data from
        the principal charm, then we return and emtpy dictionary {}

        :param auth_data: the raw dictionary received from the principal charm
        :returns: structure described above.
        """
        # If there is no auth_data yet, then we can't write our config.
        if not auth_data:
            return {}
        # If the state from the assess_status is not None then we're blocked,
        # so don't send any config to the principal.
        state, message = self.custom_assess_status_check()
        if state:
            return {}
        options = self.options  # tiny optimisation for less typing.

        # If there is no backend name, then we can't send the data yet as the
        # manila-charm won't know what to do with it.
        if not options.share_backend_name:
            return {}

        # We have the auth data & the config is reasonably sensible.
        # We can try and render the config file segment.
        # TODO this is horrible, and we should have something in
        # charms.openstack to do this, but we need a c.r relation to be able to
        # add it to the adapters_instance
        manila_plugin = charms.reactive.RelationBase.from_state(
            'manila-plugin.available')
        self.adapters_instance.add_relation(manila_plugin)
        rendered_configs = charmhelpers.core.templating.render(
            source=os.path.basename(MANILA_CONF),
            template_loader=os_templating.get_loader(
                'templates/', self.release),
            target=None,
            context=self.adapters_instance)

        return {
            MANILA_CONF: rendered_configs
        } 
开发者ID:openstack,项目名称:charm-manila-generic,代码行数:50,代码来源:manila_generic.py


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