mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Add support to take a list of hosts on the command line
This commit is contained in:
parent
69f2618ec6
commit
1ab2b34d86
@ -70,7 +70,10 @@ class SaltCMD(object):
|
||||
sys.exit('2')
|
||||
opts['cmd'] = args[0]
|
||||
else:
|
||||
opts['tgt'] = args[0]
|
||||
if opts['list']:
|
||||
opts['tgt'] = args[0].split(',')
|
||||
else:
|
||||
opts['tgt'] = args[0]
|
||||
opts['fun'] = args[1]
|
||||
opts['arg'] = args[2:]
|
||||
|
||||
|
@ -77,6 +77,17 @@ class LocalClient(object):
|
||||
os.chdir(cwd)
|
||||
return ret
|
||||
|
||||
def _check_list_minions(self, expr):
|
||||
'''
|
||||
Return the minions found by looking via a list
|
||||
'''
|
||||
ret = []
|
||||
for fn_ in os.listdir(os.path.join(self.opts['pki_dir'], 'minions')):
|
||||
if expr.count(fn_):
|
||||
if not ret.count(fn_):
|
||||
ret.append(fn_)
|
||||
return ret
|
||||
|
||||
def _check_pcre_minions(self, expr):
|
||||
'''
|
||||
Return the minions found by looking via regular expresions
|
||||
@ -153,7 +164,9 @@ class LocalClient(object):
|
||||
returns to make sure everyone has checked back in.
|
||||
'''
|
||||
return {'glob': self._check_glob_minions,
|
||||
'pcre': self._check_pcre_minions}[expr_form](expr)
|
||||
'pcre': self._check_pcre_minions,
|
||||
'list': self._check_list_minions,
|
||||
}[expr_form](expr)
|
||||
|
||||
def pub(self, tgt, fun, arg=(), expr_form='glob'):
|
||||
'''
|
||||
|
@ -152,6 +152,12 @@ class Minion(object):
|
||||
'''
|
||||
return bool(re.match(tgt, self.opts['hostname']))
|
||||
|
||||
def _list_match(self, tgt):
|
||||
'''
|
||||
Determines if this host is on the list
|
||||
'''
|
||||
return bool(tgt.count(self.opts['hostname']))
|
||||
|
||||
def _return_pub(self, ret):
|
||||
'''
|
||||
Returnt the data from the executed command to the master server
|
||||
|
Loading…
Reference in New Issue
Block a user