mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix a misplaced continue
on the grains matching logic which caused a traceback.
``` [21:18:46,004 [salt.utils.minions :200 ][ERROR ] Failed matching available minions with grain pattern: planets:saturn Traceback (most recent call last): File "/home/ubuntu/salt/salt/utils/minions.py", line 197, in check_minions }[expr_form](expr) File "/home/ubuntu/salt/salt/utils/minions.py", line 119, in _check_grain_minions str(match.lower()), AttributeError: 'list' object has no attribute 'lower' ```
This commit is contained in:
parent
4d5af27ebe
commit
c0ead8b2dc
2 changed files with 41 additions and 9 deletions
|
@ -111,17 +111,43 @@ class CkMinions(object):
|
|||
minions.remove(id_)
|
||||
continue
|
||||
if isinstance(match, list):
|
||||
# We are matching a single component to a single list member
|
||||
# We are matching a single component to a single list
|
||||
# member
|
||||
for member in match:
|
||||
if fnmatch.fnmatch(str(member).lower(), comps[1].lower()):
|
||||
continue
|
||||
if fnmatch.fnmatch(
|
||||
str(match.lower()),
|
||||
comps[1].lower(),
|
||||
):
|
||||
if fnmatch.fnmatch(
|
||||
str(member).lower(), comps[1].lower()):
|
||||
break
|
||||
else:
|
||||
# Walked through ALL the members in the list and no
|
||||
# match?
|
||||
# Remove the minion id from the list of minions!
|
||||
minions.remove(id_)
|
||||
continue
|
||||
else:
|
||||
minions.remove(id_)
|
||||
|
||||
if fnmatch.fnmatch(str(match.lower()), comps[1].lower()):
|
||||
continue
|
||||
|
||||
# Still no match!? Remove the minion id from the list
|
||||
minions.remove(id_)
|
||||
|
||||
if isinstance(match, list):
|
||||
# We are matching a single component to a single list
|
||||
# member
|
||||
member_matched = False
|
||||
for member in match:
|
||||
if fnmatch.fnmatch(str(member).lower(),
|
||||
comps[1].lower()):
|
||||
member_matched = True
|
||||
break
|
||||
else:
|
||||
minions.remove(id_)
|
||||
if member_matched:
|
||||
continue
|
||||
if fnmatch.fnmatch(str(match.lower()), comps[1].lower()):
|
||||
continue
|
||||
|
||||
minions.remove(id_)
|
||||
|
||||
return list(minions)
|
||||
|
||||
def _check_grain_pcre_minions(self, expr):
|
||||
|
|
|
@ -103,6 +103,12 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
data = '\n'.join(data)
|
||||
self.assertIn('sub_minion', data)
|
||||
self.assertNotIn('minion', data.replace('sub_minion', 'stub'))
|
||||
data = self.run_salt('-G "planets:pluto" test.ping')
|
||||
self.assertEqual(
|
||||
''.join(data),
|
||||
'No minions matched the target. No command was sent, no jid was '
|
||||
'assigned.'
|
||||
)
|
||||
# Nested grain (string value)
|
||||
data = self.run_salt('-t 1 -G "level1:level2:foo" test.ping')
|
||||
data = '\n'.join(data)
|
||||
|
|
Loading…
Add table
Reference in a new issue