mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
salt.pillar: rename the "pillar" argument to "pillar_override"
This differentiates CLI pillar override with an eventual future "initial_pillar" argument which will seed the Pillar class with initial data.
This commit is contained in:
parent
564d5fd9d3
commit
70186de532
7 changed files with 40 additions and 46 deletions
|
@ -731,7 +731,7 @@ class RemoteFuncs(object):
|
|||
load.get('saltenv', load.get('env')),
|
||||
load.get('ext'),
|
||||
self.mminion.functions,
|
||||
pillar=load.get('pillar_override', {}))
|
||||
pillar_override=load.get('pillar_override', {}))
|
||||
pillar_dirs = {}
|
||||
data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
|
||||
if self.opts.get('minion_data_cache', False):
|
||||
|
|
|
@ -1336,7 +1336,7 @@ class AESFuncs(object):
|
|||
load['id'],
|
||||
load.get('saltenv', load.get('env')),
|
||||
ext=load.get('ext'),
|
||||
pillar=load.get('pillar_override', {}),
|
||||
pillar_override=load.get('pillar_override', {}),
|
||||
pillarenv=load.get('pillarenv'))
|
||||
data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
|
||||
self.fs_.update_opts()
|
||||
|
|
|
@ -211,7 +211,7 @@ def _gather_pillar(pillarenv, pillar_override):
|
|||
__grains__,
|
||||
__opts__['id'],
|
||||
__opts__['environment'],
|
||||
pillar=pillar_override,
|
||||
pillar_override=pillar_override,
|
||||
pillarenv=pillarenv
|
||||
)
|
||||
ret = pillar.compile_pillar()
|
||||
|
|
|
@ -48,7 +48,7 @@ def _gather_pillar(pillarenv, pillar_override):
|
|||
__grains__,
|
||||
__opts__['id'],
|
||||
__opts__['environment'],
|
||||
pillar=pillar_override,
|
||||
pillar_override=pillar_override,
|
||||
pillarenv=pillarenv
|
||||
)
|
||||
ret = pillar.compile_pillar()
|
||||
|
|
|
@ -5620,7 +5620,7 @@ def _gather_pillar(pillarenv, pillar_override, **grains):
|
|||
# Not sure if these two are correct
|
||||
__opts__['id'],
|
||||
__opts__['environment'],
|
||||
pillar=pillar_override,
|
||||
pillar_override=pillar_override,
|
||||
pillarenv=pillarenv
|
||||
)
|
||||
ret = pillar.compile_pillar()
|
||||
|
|
|
@ -189,7 +189,7 @@ def items(*args, **kwargs):
|
|||
__opts__,
|
||||
__grains__,
|
||||
__opts__['id'],
|
||||
pillar=kwargs.get('pillar'),
|
||||
pillar_override=kwargs.get('pillar'),
|
||||
pillarenv=kwargs.get('pillarenv') or __opts__['pillarenv'])
|
||||
|
||||
return pillar.compile_pillar()
|
||||
|
@ -397,7 +397,7 @@ def ext(external, pillar=None):
|
|||
__opts__['id'],
|
||||
__opts__['environment'],
|
||||
ext=external,
|
||||
pillar=pillar)
|
||||
pillar_override=pillar)
|
||||
|
||||
ret = pillar_obj.compile_pillar()
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
|
||||
pillar=None, pillarenv=None):
|
||||
pillar_override=None, pillarenv=None):
|
||||
'''
|
||||
Return the correct pillar driver based on the file_client option
|
||||
'''
|
||||
|
@ -49,14 +49,14 @@ def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
|
|||
log.info('Compiling pillar from cache')
|
||||
log.debug('get_pillar using pillar cache with ext: {0}'.format(ext))
|
||||
return PillarCache(opts, grains, minion_id, saltenv, ext=ext, functions=funcs,
|
||||
pillar=pillar, pillarenv=pillarenv)
|
||||
pillar_override=pillar_override, pillarenv=pillarenv)
|
||||
return ptype(opts, grains, minion_id, saltenv, ext, functions=funcs,
|
||||
pillar=pillar, pillarenv=pillarenv)
|
||||
pillar_override=pillar_override, pillarenv=pillarenv)
|
||||
|
||||
|
||||
# TODO: migrate everyone to this one!
|
||||
def get_async_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
|
||||
pillar=None, pillarenv=None):
|
||||
pillar_override=None, pillarenv=None):
|
||||
'''
|
||||
Return the correct pillar driver based on the file_client option
|
||||
'''
|
||||
|
@ -68,7 +68,7 @@ def get_async_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None
|
|||
'local': AsyncPillar,
|
||||
}.get(file_client, AsyncPillar)
|
||||
return ptype(opts, grains, minion_id, saltenv, ext, functions=funcs,
|
||||
pillar=pillar, pillarenv=pillarenv)
|
||||
pillar_override=pillar_override, pillarenv=pillarenv)
|
||||
|
||||
|
||||
class AsyncRemotePillar(object):
|
||||
|
@ -76,7 +76,7 @@ class AsyncRemotePillar(object):
|
|||
Get the pillar from the master
|
||||
'''
|
||||
def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
|
||||
pillar=None, pillarenv=None):
|
||||
pillar_override=None, pillarenv=None):
|
||||
self.opts = opts
|
||||
self.opts['environment'] = saltenv
|
||||
self.ext = ext
|
||||
|
@ -85,12 +85,10 @@ class AsyncRemotePillar(object):
|
|||
self.channel = salt.transport.client.AsyncReqChannel.factory(opts)
|
||||
if pillarenv is not None or 'pillarenv' not in self.opts:
|
||||
self.opts['pillarenv'] = pillarenv
|
||||
self.pillar_override = {}
|
||||
if pillar is not None:
|
||||
if isinstance(pillar, dict):
|
||||
self.pillar_override = pillar
|
||||
else:
|
||||
log.error('Pillar data must be a dictionary')
|
||||
self.pillar_override = pillar_override or {}
|
||||
if not isinstance(self.pillar_override, dict):
|
||||
self.pillar_override = {}
|
||||
log.error('Pillar data must be a dictionary')
|
||||
|
||||
@tornado.gen.coroutine
|
||||
def compile_pillar(self):
|
||||
|
@ -129,7 +127,7 @@ class RemotePillar(object):
|
|||
Get the pillar from the master
|
||||
'''
|
||||
def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
|
||||
pillar=None, pillarenv=None):
|
||||
pillar_override=None, pillarenv=None):
|
||||
self.opts = opts
|
||||
self.opts['environment'] = saltenv
|
||||
self.ext = ext
|
||||
|
@ -138,12 +136,10 @@ class RemotePillar(object):
|
|||
self.channel = salt.transport.Channel.factory(opts)
|
||||
if pillarenv is not None or 'pillarenv' not in self.opts:
|
||||
self.opts['pillarenv'] = pillarenv
|
||||
self.pillar_override = {}
|
||||
if pillar is not None:
|
||||
if isinstance(pillar, dict):
|
||||
self.pillar_override = pillar
|
||||
else:
|
||||
log.error('Pillar data must be a dictionary')
|
||||
self.pillar_override = pillar_override or {}
|
||||
if not isinstance(self.pillar_override, dict):
|
||||
self.pillar_override = {}
|
||||
log.error('Pillar data must be a dictionary')
|
||||
|
||||
def compile_pillar(self):
|
||||
'''
|
||||
|
@ -175,8 +171,8 @@ class PillarCache(object):
|
|||
'''
|
||||
Return a cached pillar if it exists, otherwise cache it.
|
||||
|
||||
Pillar caches are structed in two diminensions: minion_id with a dict of saltenvs.
|
||||
Each saltenv contains a pillar dict
|
||||
Pillar caches are structed in two diminensions: minion_id with a dict of
|
||||
saltenvs. Each saltenv contains a pillar dict
|
||||
|
||||
Example data structure:
|
||||
|
||||
|
@ -187,7 +183,7 @@ class PillarCache(object):
|
|||
'''
|
||||
# TODO ABC?
|
||||
def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
|
||||
pillar=None, pillarenv=None):
|
||||
pillar_override=None, pillarenv=None):
|
||||
# Yes, we need all of these because we need to route to the Pillar object
|
||||
# if we have no cache. This is another refactor target.
|
||||
|
||||
|
@ -197,7 +193,7 @@ class PillarCache(object):
|
|||
self.minion_id = minion_id
|
||||
self.ext = ext
|
||||
self.functions = functions
|
||||
self.pillar = pillar
|
||||
self.pillar_override = pillar_override
|
||||
self.pillarenv = pillarenv
|
||||
|
||||
if saltenv is None:
|
||||
|
@ -226,13 +222,13 @@ class PillarCache(object):
|
|||
'''
|
||||
log.debug('Pillar cache getting external pillar with ext: {0}'.format(self.ext))
|
||||
fresh_pillar = Pillar(self.opts,
|
||||
self.grains,
|
||||
self.minion_id,
|
||||
self.saltenv,
|
||||
ext=self.ext,
|
||||
functions=self.functions,
|
||||
pillar=self.pillar,
|
||||
pillarenv=self.pillarenv)
|
||||
self.grains,
|
||||
self.minion_id,
|
||||
self.saltenv,
|
||||
ext=self.ext,
|
||||
functions=self.functions,
|
||||
pillar_override=self.pillar_override,
|
||||
pillarenv=self.pillarenv)
|
||||
return fresh_pillar.compile_pillar() # FIXME We are not yet passing pillar_dirs in here
|
||||
|
||||
def compile_pillar(self, *args, **kwargs): # Will likely just be pillar_dirs
|
||||
|
@ -265,7 +261,7 @@ class Pillar(object):
|
|||
Read over the pillar top files and render the pillar data
|
||||
'''
|
||||
def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
|
||||
pillar=None, pillarenv=None):
|
||||
pillar_override=None, pillarenv=None):
|
||||
self.minion_id = minion_id
|
||||
self.ext = ext
|
||||
# Store the file_roots path so we can restore later. Issue 5449
|
||||
|
@ -303,12 +299,10 @@ class Pillar(object):
|
|||
|
||||
self.ext_pillars = salt.loader.pillars(ext_pillar_opts, self.functions)
|
||||
self.ignored_pillars = {}
|
||||
self.pillar_override = {}
|
||||
if pillar is not None:
|
||||
if isinstance(pillar, dict):
|
||||
self.pillar_override = pillar
|
||||
else:
|
||||
log.error('Pillar data must be a dictionary')
|
||||
self.pillar_override = pillar_override or {}
|
||||
if not isinstance(self.pillar_override, dict):
|
||||
self.pillar_override = {}
|
||||
log.error('Pillar data must be a dictionary')
|
||||
|
||||
def __valid_on_demand_ext_pillar(self, opts):
|
||||
'''
|
||||
|
@ -784,7 +778,7 @@ class Pillar(object):
|
|||
return pillar, errors
|
||||
ext = None
|
||||
# Bring in CLI pillar data
|
||||
if self.pillar_override and isinstance(self.pillar_override, dict):
|
||||
if self.pillar_override:
|
||||
pillar = merge(pillar,
|
||||
self.pillar_override,
|
||||
self.merge_strategy,
|
||||
|
@ -863,7 +857,7 @@ class Pillar(object):
|
|||
log.critical('Pillar render error: {0}'.format(error))
|
||||
pillar['_errors'] = errors
|
||||
|
||||
if self.pillar_override and isinstance(self.pillar_override, dict):
|
||||
if self.pillar_override:
|
||||
pillar = merge(pillar,
|
||||
self.pillar_override,
|
||||
self.merge_strategy,
|
||||
|
|
Loading…
Add table
Reference in a new issue