• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pillar.compile_pillar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: get_pillar

def get_pillar(__opts__, minion='*', **kwargs):
    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()
    return compiled_pillar 
开发者ID:toby82,项目名称:shell,代码行数:19,代码来源:comm.py


示例17: 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, basestring):
        external = yaml.safe_load(external)
    pillar = salt.pillar.get_pillar(
        __opts__,
        __grains__,
        __opts__['id'],
        __opts__['environment'],
        external)

    ret = pillar.compile_pillar()

    return ret
开发者ID:penta-srl,项目名称:salt,代码行数:22,代码来源:pillar.py


示例18: _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'])
     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 open(datap, 'w+') as fp_:
             fp_.write(
                     self.serial.dumps(
                         {'grains': load['grains'],
                          'pillar': data})
                         )
     return data
开发者ID:abh,项目名称:salt,代码行数:24,代码来源:master.py


示例19: _bind

    # Enable logging
    log = logging.getLogger(__name__)

    BASE_DIR = os.getcwd()

    # Set salt pillar, grains and opts settings so they can be applied to modules
    __opts__ = salt.config.minion_config('/etc/salt/minion')
    __opts__['grains'] = salt.loader.grains(__opts__)
    pillar = salt.pillar.get_pillar(
        __opts__,
        __opts__['grains'],
        __opts__['id'],
        __opts__['environment'],
    )
    __opts__['pillar'] = pillar.compile_pillar()
    __salt__ = salt.loader.minion_mods(__opts__)
    __grains__ = __opts__['grains']
    __pillar__ = __opts__['pillar']
    __context__ = {}

    salt.modules.saltutil.__opts__ =  __opts__
    salt.modules.saltutil.__grains__ =  __grains__
    salt.modules.saltutil.__pillar__ =  __pillar__
    salt.modules.saltutil.__salt__ =  __salt__
    salt.modules.saltutil.__context__ =  __context__

from salt.scripts import salt_call

def _bind(form, saltenv=None, umount=False):
    '''
开发者ID:DockerNAS,项目名称:yamlscript-formula,代码行数:30,代码来源:salt-call.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mysql.merger函数代码示例发布时间:2022-05-27
下一篇:
Python virtualenv_mod.create函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap