Exemple #1
0
 def test_check_renderer_blacklisting(self):
     '''
     Check that all renderers specified in the pipe string are available.
     '''
     ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], None)
     self.assertListEqual([('fake_json_func', '')], ret)
     ret = template.check_render_pipe_str('jinja|json', self.render_dict, None, ['jinja'])
     self.assertListEqual([('fake_jinja_func', '')], ret)
     ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], ['jinja'])
     self.assertListEqual([], ret)
     ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], ['jinja', 'json'])
     self.assertListEqual([('fake_json_func', '')], ret)
Exemple #2
0
def render(opts, functions, states=None):
    '''
    Returns the render modules
    '''
    load = _create_loader(opts,
                          'renderers',
                          'render',
                          ext_type_dirs='render_dirs')
    pack = [{
        'name': '__salt__',
        'value': functions
    }, {
        'name': '__pillar__',
        'value': opts.get('pillar', {})
    }]

    if states:
        pack.append({'name': '__states__', 'value': states})
    rend = load.filter_func('render', pack)
    if not check_render_pipe_str(opts['renderer'], rend):
        err = ('The renderer {0} is unavailable, this error is often because '
               'the needed software is unavailable'.format(opts['renderer']))
        log.critical(err)
        raise LoaderError(err)
    return rend
Exemple #3
0
 def test_check_renderer_blacklisting(self):
     '''
     Check that all renderers specified in the pipe string are available.
     '''
     ret = template.check_render_pipe_str('jinja|json', self.render_dict,
                                          ['jinja'], None)
     self.assertListEqual([('fake_json_func', '')], ret)
     ret = template.check_render_pipe_str('jinja|json', self.render_dict,
                                          None, ['jinja'])
     self.assertListEqual([('fake_jinja_func', '')], ret)
     ret = template.check_render_pipe_str('jinja|json', self.render_dict,
                                          ['jinja'], ['jinja'])
     self.assertListEqual([], ret)
     ret = template.check_render_pipe_str('jinja|json', self.render_dict,
                                          ['jinja'], ['jinja', 'json'])
     self.assertListEqual([('fake_json_func', '')], ret)
Exemple #4
0
 def test_check_renderer_blacklisting(self):
     """
     Check that all renderers specified in the pipe string are available.
     """
     ret = template.check_render_pipe_str("jinja|json", self.render_dict,
                                          ["jinja"], None)
     self.assertListEqual([("fake_json_func", "")], ret)
     ret = template.check_render_pipe_str("jinja|json", self.render_dict,
                                          None, ["jinja"])
     self.assertListEqual([("fake_jinja_func", "")], ret)
     ret = template.check_render_pipe_str("jinja|json", self.render_dict,
                                          ["jinja"], ["jinja"])
     self.assertListEqual([], ret)
     ret = template.check_render_pipe_str("jinja|json", self.render_dict,
                                          ["jinja"], ["jinja", "json"])
     self.assertListEqual([("fake_json_func", "")], ret)
 def test_check_render_pipe_str(self):
     '''
     Check that all renderers specified in the pipe string are available.
     '''
     ret = template.check_render_pipe_str('jinja|json', self.render_dict)
     self.assertIn(('fake_jinja_func', ''), ret)
     self.assertIn(('fake_json_func', ''), ret)
     self.assertNotIn(('OBVIOUSLY_NOT_HERE', ''), ret)
 def test_check_render_pipe_str(self):
     '''
     Check that all renderers specified in the pipe string are available.
     '''
     ret = template.check_render_pipe_str('jinja|json', self.render_dict)
     self.assertIn(('fake_jinja_func', ''), ret)
     self.assertIn(('fake_json_func', ''), ret)
     self.assertNotIn(('OBVIOUSLY_NOT_HERE', ''), ret)
Exemple #7
0
 def test_check_render_pipe_str(self):
     """
     Check that all renderers specified in the pipe string are available.
     """
     ret = template.check_render_pipe_str("jinja|json", self.render_dict,
                                          None, None)
     self.assertIn(("fake_jinja_func", ""), ret)
     self.assertIn(("fake_json_func", ""), ret)
     self.assertNotIn(("OBVIOUSLY_NOT_HERE", ""), ret)
Exemple #8
0
def render(opts, functions):
    '''
    Returns the render modules
    '''
    load = _create_loader(
        opts, 'renderers', 'render', ext_type_dirs='render_dirs'
    )
    pack = {'name': '__salt__',
            'value': functions}
    rend = load.filter_func('render', pack)
    if not check_render_pipe_str(opts['renderer'], rend):
        err = ('The renderer {0} is unavailable, this error is often because '
               'the needed software is unavailable'.format(opts['renderer']))
        log.critical(err)
        raise LoaderError(err)
    return rend
Exemple #9
0
def render(opts, functions):
    '''
    Returns the render modules
    '''
    load = _create_loader(
        opts, 'renderers', 'render', ext_type_dirs='render_dirs'
    )
    pack = {'name': '__salt__',
            'value': functions}
    rend = load.filter_func('render', pack)
    if not check_render_pipe_str(opts['renderer'], rend):
        err = ('The renderer {0} is unavailable, this error is often because '
               'the needed software is unavailable'.format(opts['renderer']))
        log.critical(err)
        raise LoaderError(err)
    return rend
Exemple #10
0
def render(opts, functions, states=None, proxy=None, context=None):
    """
    Returns the render modules
    """
    if context is None:
        context = {}

    pack = {
        "__salt__": functions,
        "__grains__": opts.get("grains", {}),
        "__context__": context,
    }

    if states:
        pack["__states__"] = states

    if proxy is None:
        proxy = {}
    pack["__proxy__"] = proxy

    ret = LazyLoader(
        _module_dirs(
            opts,
            "renderers",
            "render",
            ext_type_dirs="render_dirs",
        ),
        opts,
        tag="render",
        pack=pack,
    )
    rend = FilterDictWrapper(ret, ".render")

    if not check_render_pipe_str(
        opts["renderer"], rend, opts["renderer_blacklist"], opts["renderer_whitelist"]
    ):
        err = (
            "The renderer {} is unavailable, this error is often because "
            "the needed software is unavailable".format(opts["renderer"])
        )
        log.critical(err)
        raise LoaderError(err)
    return rend
Exemple #11
0
def render(opts, functions, states=None):
    '''
    Returns the render modules
    '''
    pack = {'__salt__': functions}
    if states:
        pack['__states__'] = states
    ret = LazyLoader(
        _module_dirs(opts, 'renderers', 'render', ext_type_dirs='render_dirs'),
        opts,
        tag='render',
        pack=pack,
    )
    rend = FilterDictWrapper(ret, '.render')

    if not check_render_pipe_str(opts['renderer'], rend):
        err = ('The renderer {0} is unavailable, this error is often because '
               'the needed software is unavailable'.format(opts['renderer']))
        log.critical(err)
        raise LoaderError(err)
    return rend
def render(opts, functions, states=None):
    '''
    Returns the render modules
    '''
    load = _create_loader(
        opts, 'renderers', 'render', ext_type_dirs='render_dirs'
    )
    pack = [{'name': '__salt__',
             'value': functions},
            {'name': '__pillar__',
             'value': opts.get('pillar', {})}]

    if states:
        pack.append({'name': '__states__', 'value': states})
    rend = load.filter_func('render', pack)
    if not check_render_pipe_str(opts['renderer'], rend):
        err = ('The renderer {0} is unavailable, this error is often because '
               'the needed software is unavailable'.format(opts['renderer']))
        log.critical(err)
        raise LoaderError(err)
    return rend
Exemple #13
0
def render(opts, functions, states=None):
    '''
    Returns the render modules
    '''
    pack = {'__salt__': functions}
    if states:
        pack['__states__'] = states
    ret = LazyLoader(_module_dirs(opts,
                                  'renderers',
                                  'render',
                                  ext_type_dirs='render_dirs'),
                     opts,
                     tag='render',
                     pack=pack,
                     )
    rend = FilterDictWrapper(ret, '.render')

    if not check_render_pipe_str(opts['renderer'], rend):
        err = ('The renderer {0} is unavailable, this error is often because '
               'the needed software is unavailable'.format(opts['renderer']))
        log.critical(err)
        raise LoaderError(err)
    return rend