"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "salt/utils/minions.py" between
salt-2019.2.0.tar.gz and salt-2019.2.1.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

minions.py  (salt-2019.2.0):minions.py  (salt-2019.2.1)
skipping to change at line 49 skipping to change at line 49
TARGET_REX = re.compile( TARGET_REX = re.compile(
r'''(?x) r'''(?x)
( (
(?P<engine>G|P|I|J|L|N|S|E|R) # Possible target engines (?P<engine>G|P|I|J|L|N|S|E|R) # Possible target engines
(?P<delimiter>(?<=G|P|I|J).)? # Optional delimiter for specific eng ines (?P<delimiter>(?<=G|P|I|J).)? # Optional delimiter for specific eng ines
@)? # Engine+delimiter are separated by a '@' @)? # Engine+delimiter are separated by a '@'
# character and are optional for the target # character and are optional for the target
(?P<pattern>.+)$''' # The pattern passed to the target en gine (?P<pattern>.+)$''' # The pattern passed to the target en gine
) )
def _nodegroup_regex(nodegroup, words, opers):
opers_set = set(opers)
ret = words
if (set(ret) - opers_set) == set(ret):
# No compound operators found in nodegroup definition. Check for
# group type specifiers
group_type_re = re.compile('^[A-Z]@')
regex_chars = ['(', '[', '{', '\\', '?', '}', ']', ')']
if not [x for x in ret if '*' in x or group_type_re.match(x)]:
# No group type specifiers and no wildcards.
# Treat this as an expression.
if [x for x in ret if x in [x for y in regex_chars if y in x]]:
joined = 'E@' + ','.join(ret)
log.debug(
'Nodegroup \'%s\' (%s) detected as an expression. '
'Assuming compound matching syntax of \'%s\'',
nodegroup, ret, joined
)
else:
# Treat this as a list of nodenames.
joined = 'L@' + ','.join(ret)
log.debug(
'Nodegroup \'%s\' (%s) detected as list of nodenames. '
'Assuming compound matching syntax of \'%s\'',
nodegroup, ret, joined
)
# Return data must be a list of compound matching components
# to be fed into compound matcher. Enclose return data in list.
return [joined]
def parse_target(target_expression): def parse_target(target_expression):
'''Parse `target_expressing` splitting it into `engine`, `delimiter`, '''Parse `target_expressing` splitting it into `engine`, `delimiter`,
`pattern` - returns a dict''' `pattern` - returns a dict'''
match = TARGET_REX.match(target_expression) match = TARGET_REX.match(target_expression)
if not match: if not match:
log.warning('Unable to parse target "%s"', target_expression) log.warning('Unable to parse target "%s"', target_expression)
ret = { ret = {
'engine': None, 'engine': None,
'delimiter': None, 'delimiter': None,
skipping to change at line 141 skipping to change at line 171
if ret: if ret:
ret.insert(0, '(') ret.insert(0, '(')
ret.append(')') ret.append(')')
skip.remove(nodegroup) skip.remove(nodegroup)
log.debug('nodegroup_comp(%s) => %s', nodegroup, ret) log.debug('nodegroup_comp(%s) => %s', nodegroup, ret)
# Only return list form if a nodegroup was expanded. Otherwise return # Only return list form if a nodegroup was expanded. Otherwise return
# the original string to conserve backwards compat # the original string to conserve backwards compat
if expanded_nodegroup or not first_call: if expanded_nodegroup or not first_call:
if not first_call:
joined = _nodegroup_regex(nodegroup, words, opers)
if joined:
return joined
return ret return ret
else: else:
opers_set = set(opers)
ret = words ret = words
if (set(ret) - opers_set) == set(ret): joined = _nodegroup_regex(nodegroup, ret, opers)
# No compound operators found in nodegroup definition. Check for if joined:
# group type specifiers return joined
group_type_re = re.compile('^[A-Z]@')
regex_chars = ['(', '[', '{', '\\', '?''}])']
if not [x for x in ret if '*' in x or group_type_re.match(x)]:
# No group type specifiers and no wildcards.
# Treat this as an expression.
if [x for x in ret if x in [x for y in regex_chars if y in x]]:
joined = 'E@' + ','.join(ret)
log.debug(
'Nodegroup \'%s\' (%s) detected as an expression. '
'Assuming compound matching syntax of \'%s\'',
nodegroup, ret, joined
)
else:
# Treat this as a list of nodenames.
joined = 'L@' + ','.join(ret)
log.debug(
'Nodegroup \'%s\' (%s) detected as list of nodenames. '
'Assuming compound matching syntax of \'%s\'',
nodegroup, ret, joined
)
# Return data must be a list of compound matching components
# to be fed into compound matcher. Enclose return data in list.
return [joined]
log.debug( log.debug(
'No nested nodegroups detected. Using original nodegroup ' 'No nested nodegroups detected. Using original nodegroup '
'definition: %s', nodegroups[nodegroup] 'definition: %s', nodegroups[nodegroup]
) )
return ret return ret
class CkMinions(object): class CkMinions(object):
''' '''
Used to check what minions should respond from a target Used to check what minions should respond from a target
skipping to change at line 270 skipping to change at line 280
return minions return minions
def _check_cache_minions(self, def _check_cache_minions(self,
expr, expr,
delimiter, delimiter,
greedy, greedy,
search_type, search_type,
regex_match=False, regex_match=False,
exact_match=False): exact_match=False):
''' '''
Helper function to search for minions in master caches Helper function to search for minions in master caches If 'greedy',
If 'greedy' return accepted minions that matched by the condition or abs then return accepted minions matched by the condition or those absent
end in the cache. from the cache. If not 'greedy' return the only minions have cache
If not 'greedy' return the only minions have cache data and matched by t data and matched by the condition.
he condition.
''' '''
cache_enabled = self.opts.get('minion_data_cache', False) cache_enabled = self.opts.get('minion_data_cache', False)
def list_cached_minions(): def list_cached_minions():
return self.cache.list('minions') return self.cache.list('minions')
if greedy: if greedy:
minions = [] minions = []
for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join (self.opts['pki_dir'], self.acc))): for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join (self.opts['pki_dir'], self.acc))):
if not fn_.startswith('.') and os.path.isfile(os.path.join(self. opts['pki_dir'], self.acc, fn_)): if not fn_.startswith('.') and os.path.isfile(os.path.join(self. opts['pki_dir'], self.acc, fn_)):
 End of changes. 5 change blocks. 
32 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)