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


Python pillar.compile_pillar函数代码示例

本文整理汇总了Python中salt.pillar.compile_pillar函数的典型用法代码示例。如果您正苦于以下问题:Python compile_pillar函数的具体用法?Python compile_pillar怎么用?Python compile_pillar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_topfile_order

 def test_topfile_order(self, Matcher, get_file_client):
     opts = {
         'renderer': 'yaml',
         'state_top': '',
         'pillar_roots': [],
         'extension_modules': '',
         'environment': 'base',
         'file_roots': [],
     }
     grains = {
         'os': 'Ubuntu',
         'os_family': 'Debian',
         'oscodename': 'raring',
         'osfullname': 'Ubuntu',
         'osrelease': '13.04',
         'kernel': 'Linux'
     }
     # glob match takes precedence
     self._setup_test_topfile_mocks(Matcher, get_file_client, 1, 2)
     pillar = salt.pillar.Pillar(opts, grains, 'mocked-minion', 'base')
     self.assertEqual(pillar.compile_pillar()['ssh'], 'bar')
     # nodegroup match takes precedence
     self._setup_test_topfile_mocks(Matcher, get_file_client, 2, 1)
     pillar = salt.pillar.Pillar(opts, grains, 'mocked-minion', 'base')
     self.assertEqual(pillar.compile_pillar()['ssh'], 'foo')
开发者ID:dmyerscough,项目名称:salt,代码行数:25,代码来源:pillar_test.py

示例2: data

def data(key=''):
    '''
    Returns the pillar derived from the configured pillar source. The pillar
    source is derived from the file_client option in the minion config

    CLI Example::

        salt '*' pillar.data

    With the optional key argument, you can select a subtree of the
    pillar data.::

        salt '*' pillar.data key='roles'
    '''
    pillar = salt.pillar.get_pillar(
            __opts__,
            __grains__,
            __opts__['id'],
            __opts__['environment'])

    compiled_pillar = pillar.compile_pillar()

    if key:
        try:
            ret = compiled_pillar[key]
        except KeyError:
            ret = {}
    else:
        ret = compiled_pillar

    return ret
开发者ID:11craft,项目名称:salt,代码行数:31,代码来源:pillar.py

示例3: _pillar

 def _pillar(self, load):
     '''
     Return the pillar data for the minion
     '''
     if any(key not in load for key in ('id', 'grains')):
         return False
     pillar = salt.pillar.Pillar(
             self.opts,
             load['grains'],
             load['id'],
             load.get('saltenv', load.get('env')),
             load.get('ext'),
             self.mminion.functions)
     data = pillar.compile_pillar()
     if self.opts.get('minion_data_cache', False):
         cdir = os.path.join(self.opts['cachedir'], 'minions', load['id'])
         if not os.path.isdir(cdir):
             os.makedirs(cdir)
         datap = os.path.join(cdir, 'data.p')
         with salt.utils.fopen(datap, 'w+') as fp_:
             fp_.write(
                     self.serial.dumps(
                         {'grains': load['grains'],
                          'pillar': data})
                         )
     return data
开发者ID:penta-srl,项目名称:salt,代码行数:26,代码来源:masterapi.py

示例4: test_pillar_multiple_matches

 def test_pillar_multiple_matches(self, Matcher, get_file_client):
     # Uses the ``recurse_list`` strategy.
     opts = {
         'renderer': 'yaml',
         'state_top': '',
         'pillar_roots': [],
         'extension_modules': '',
         'environment': 'base',
         'file_roots': [],
         'pillar_source_merging_strategy': 'recurse_list',
     }
     grains = {
         'os': 'Ubuntu',
         'os_family': 'Debian',
         'oscodename': 'raring',
         'osfullname': 'Ubuntu',
         'osrelease': '13.04',
         'kernel': 'Linux'
     }
     self._setup_test_topfile_mocks(Matcher, get_file_client, 1, 2)
     pillar = salt.pillar.Pillar(opts, grains, 'mocked-minion', 'base')
     # Pillars should be merged, but only once per pillar file.
     self.assertDictEqual(pillar.compile_pillar()['generic'], {
         'key1': ['value1', 'value2', 'value3'],
         'key2': {
             'sub_key1': [],
             'sub_key2': [],
         }
     })
开发者ID:mahak,项目名称:salt,代码行数:29,代码来源:pillar_test.py

示例5: items

def items(*args):
    '''
    Calls the master for a fresh pillar and generates the pillar data on the
    fly

    Contrast with :py:func:`raw` which returns the pillar data that is
    currently loaded into the minion.

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.items
    '''
    # Preserve backwards compatibility
    if args:
        return item(*args)

    pillar = salt.pillar.get_pillar(
        __opts__,
        __grains__,
        __opts__['id'],
        __opts__['environment'])

    return pillar.compile_pillar()
开发者ID:AccelerationNet,项目名称:salt,代码行数:25,代码来源:pillar.py

示例6: items

def items(*args, **kwargs):
    '''
    Calls the master for a fresh pillar and generates the pillar data on the
    fly

    Contrast with :py:func:`raw` which returns the pillar data that is
    currently loaded into the minion.

    pillar : none
        if specified, allows for a dictionary of pillar data to be made
        available to pillar and ext_pillar rendering. these pillar variables
        will also override any variables of the same name in pillar or
        ext_pillar.

        .. versionadded:: 2015.5.0

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.items
    '''
    # Preserve backwards compatibility
    if args:
        return item(*args)

    pillar = salt.pillar.get_pillar(
        __opts__,
        __grains__,
        __opts__['id'],
        __opts__['environment'],
        pillar=kwargs.get('pillar'))

    return pillar.compile_pillar()
开发者ID:iquaba,项目名称:salt,代码行数:34,代码来源:pillar.py

示例7: data

def data(key=None):
    '''
    Returns the pillar derived from the configured pillar source. The pillar
    source is derived from the file_client option in the minion config

    CLI Example::

        salt '*' pillar.data

    With the optional key argument, you can select a subtree of the
    pillar data.::

        salt '*' pillar.data key='roles'
    '''
    pillar = salt.pillar.get_pillar(
        __opts__,
        __grains__,
        __opts__['id'],
        __opts__['environment'])

    ret = pillar.compile_pillar()

    if key:
        ret = ret.get(key, {})

    return ret
开发者ID:herlo,项目名称:salt,代码行数:26,代码来源:pillar.py

示例8: show_pillar

def show_pillar(minion='*', **kwargs):
    '''
    Returns the compiled pillar either of a specific minion
    or just the global available pillars. I assume that no minion
    is using the id ``*``.

    CLI Example:

    shows minion specific pillar:

    .. code-block:: bash

        salt-run pillar.show_pillar 'www.example.com'

    shows global pillar:

    .. code-block:: bash

        salt-run pillar.show_pillar

    shows global pillar for 'dev' pillar environment:

    .. code-block:: bash

        salt-run pillar.show_pillar 'saltenv=dev'

    API Example:

    .. code-block:: python

        import salt.config
        import salt.runner
        opts = salt.config.master_config('/etc/salt/master')
        runner = salt.runner.RunnerClient(opts)
        pillar = runner.cmd('pillar.show_pillar', [])
        print pillar¬
    '''

    saltenv = 'base'
    id_, grains, _ = salt.utils.minions.get_minion_data(minion, __opts__)
    if grains is None:
        grains = {'fqdn': minion}

    for key in kwargs:
        if key == 'saltenv':
            saltenv = kwargs[key]
        else:
            grains[key] = kwargs[key]

    pillar = salt.pillar.Pillar(
        __opts__,
        grains,
        id_,
        saltenv)

    compiled_pillar = pillar.compile_pillar()
    salt.output.display_output(compiled_pillar, 'nested', __opts__)
    return compiled_pillar
开发者ID:AccelerationNet,项目名称:salt,代码行数:58,代码来源:pillar.py

示例9: data

def data():
    """
    Returns the pillar derived from the configured pillar source. The pillar
    source is derived from the file_client option in the minion config

    CLI Example::

        salt '*' pillar.data
    """
    pillar = salt.pillar.get_pillar(__opts__, __grains__, __opts__["id"], __opts__["environment"])
    return pillar.compile_pillar()
开发者ID:robinsmidsrod,项目名称:salt,代码行数:11,代码来源:pillar.py

示例10: data

def data():
    '''
    Returns the pillar derived from the configured pillar source. The pillar
    source is derived from the file_client option in the minion config

    CLI Example::

        salt '*' pillar.data
    '''
    pillar = salt.pillar.get_pillar(__opts__, __grains__, __opts__['id'])
    return pillar.compile_pillar()
开发者ID:LinuxJedi,项目名称:salt,代码行数:11,代码来源:pillar.py

示例11: _pillar

 def _pillar(self, load):
     '''
     Return the pillar data for the minion
     '''
     if 'id' not in load or 'grains' not in load or 'env' not in load:
         return False
     pillar = salt.pillar.Pillar(
             self.opts,
             load['grains'],
             load['id'],
             load['env'])
     return pillar.compile_pillar()
开发者ID:cmek,项目名称:salt,代码行数:12,代码来源:master.py

示例12: ext

def ext(external):
    """
    Generate the pillar and apply an explicit external pillar

    CLI Example::

        salt '*' pillar.ext 'libvirt: _'
    """
    if isinstance(external, basestring):
        external = yaml.load(external)
    pillar = salt.pillar.get_pillar(__opts__, __grains__, __opts__["id"], __opts__["environment"], external)

    ret = pillar.compile_pillar()

    return ret
开发者ID:jaypei,项目名称:salt,代码行数:15,代码来源:pillar.py

示例13: items

def items(*args):
    """
    This function calls the master for a fresh pillar and generates the pillar
    data on the fly, unlike pillar.raw which returns the pillar data which
    is currently loaded into the minion.

    CLI Example::

        salt '*' pillar.items
    """
    # Preserve backwards compatibility
    if args:
        return item(*args)

    pillar = salt.pillar.get_pillar(__opts__, __grains__, __opts__["id"], __opts__["environment"])

    return pillar.compile_pillar()
开发者ID:jaypei,项目名称:salt,代码行数:17,代码来源:pillar.py

示例14: _get_live_minion_pillar

 def _get_live_minion_pillar(self, minion_id=None, minion_grains=None):
     # Returns a dict of pillar data for one minion
     if minion_id == None:
         return {}
     if not minion_grains:
         log.warn('Cannot get pillar data for {0}: no grains supplied.'.format(minion_id))
         return {}
     log.debug('Getting live pillar for {0}'.format(minion_id))
     pillar = salt.pillar.Pillar(
                         self.opts,
                         minion_grains,
                         minion_id,
                         self.env,
                         self.opts['ext_pillar'])
     log.debug('Compiling pillar for {0}'.format(minion_id))
     ret = pillar.compile_pillar()
     return ret
开发者ID:jslatts,项目名称:salt,代码行数:17,代码来源:master.py

示例15: ext

def ext(external):
    """
    Generate the pillar and apply an explicit external pillar

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.ext '{libvirt: _}'
    """
    if isinstance(external, string_types):
        external = yaml.safe_load(external)
    pillar = salt.pillar.get_pillar(__opts__, __grains__, __opts__["id"], __opts__["environment"], external)

    ret = pillar.compile_pillar()

    return ret
开发者ID:ckraemer,项目名称:salt,代码行数:17,代码来源:pillar.py


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