mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
I decided to only build in regex support at this time for the target
matching
This commit is contained in:
parent
518ad0a831
commit
50bde04bb4
1 changed files with 7 additions and 11 deletions
|
@ -27,7 +27,6 @@ The data structurte needs to be:
|
|||
|
||||
import os
|
||||
import re
|
||||
import glob
|
||||
|
||||
# Import zmq modules
|
||||
import zmq
|
||||
|
@ -58,23 +57,20 @@ class LocalClient(object):
|
|||
except:
|
||||
raise SaltClientError('Failed to read in the salt root key')
|
||||
|
||||
def check_minions(self, expr, expr_type='glob'):
|
||||
def check_minions(self, expr):
|
||||
'''
|
||||
Check the passed glob or regex against the available minions' public
|
||||
Check the passed regex against the available minions' public
|
||||
keys stored for authentication. This should return a set of hostnames
|
||||
which match the glob or regex, this will then be used to parse the
|
||||
which match the regex, this will then be used to parse the
|
||||
returns to make sure everyone has checked back in.
|
||||
'''
|
||||
ret = set()
|
||||
cwd = os.getcwd()
|
||||
os.chdir(os.path.join(self.opts['pki_dir'], 'minions'))
|
||||
if expr_type == 'glob':
|
||||
ret = set(glob.glob(expr))
|
||||
else:
|
||||
reg = re.compile(expr)
|
||||
for fn_ in os.listdir('.'):
|
||||
if reg.match(fn_):
|
||||
ret.add(fn_)
|
||||
reg = re.compile(expr)
|
||||
for fn_ in os.listdir('.'):
|
||||
if reg.match(fn_):
|
||||
ret.add(fn_)
|
||||
os.chdir(cwd)
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue