mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
add support to list denied minions to salt-key
This commit is contained in:
parent
176b4106df
commit
84753ee9dd
29
salt/key.py
29
salt/key.py
@ -33,6 +33,7 @@ class KeyCLI(object):
|
||||
self.acc = 'minions'
|
||||
self.pend = 'minions_pre'
|
||||
self.rej = 'minions_rejected'
|
||||
self.den = 'minions_denied'
|
||||
else:
|
||||
self.key = RaetKey(opts)
|
||||
self.acc = 'accepted'
|
||||
@ -64,6 +65,12 @@ class KeyCLI(object):
|
||||
'key',
|
||||
self.opts
|
||||
)
|
||||
elif status.startswith('den'):
|
||||
salt.output.display_output(
|
||||
{'minions_denied': keys[self.den]},
|
||||
'key',
|
||||
self.opts
|
||||
)
|
||||
elif status.startswith('all'):
|
||||
self.list_all()
|
||||
|
||||
@ -430,7 +437,15 @@ class Key(object):
|
||||
minions_pre = os.path.join(self.opts['pki_dir'], 'minions_pre')
|
||||
minions_rejected = os.path.join(self.opts['pki_dir'],
|
||||
'minions_rejected')
|
||||
return minions_accepted, minions_pre, minions_rejected
|
||||
|
||||
minions_denied = os.path.join(self.opts['pki_dir'],
|
||||
'minions_denied')
|
||||
return (
|
||||
minions_accepted,
|
||||
minions_pre,
|
||||
minions_rejected,
|
||||
minions_denied
|
||||
)
|
||||
|
||||
def gen_keys(self):
|
||||
'''
|
||||
@ -516,7 +531,13 @@ class Key(object):
|
||||
cur_keys = self.list_keys()
|
||||
for status, keys in match_dict.items():
|
||||
for key in salt.utils.isorted(keys):
|
||||
for keydir in ('minions', 'minions_pre', 'minions_rejected'):
|
||||
key_dirs = (
|
||||
'minions',
|
||||
'minions_pre',
|
||||
'minions_rejected',
|
||||
'minions_denied'
|
||||
)
|
||||
for keydir in key_dirs:
|
||||
if fnmatch.filter(cur_keys.get(keydir, []), key):
|
||||
ret.setdefault(keydir, []).append(key)
|
||||
return ret
|
||||
@ -537,9 +558,9 @@ class Key(object):
|
||||
'''
|
||||
Return a dict of managed keys and what the key status are
|
||||
'''
|
||||
acc, pre, rej = self._check_minions_directories()
|
||||
acc, pre, rej, den = self._check_minions_directories()
|
||||
ret = {}
|
||||
for dir_ in acc, pre, rej:
|
||||
for dir_ in acc, pre, rej, den:
|
||||
ret[os.path.basename(dir_)] = []
|
||||
for fn_ in salt.utils.isorted(os.listdir(dir_)):
|
||||
if os.path.isfile(os.path.join(dir_, fn_)):
|
||||
|
Loading…
Reference in New Issue
Block a user