Add manage.not_present

This commit is contained in:
Joseph Hall 2014-08-21 09:13:27 -06:00
parent e5fadf15e9
commit b5744a54f8

View File

@ -138,7 +138,7 @@ def up(): # pylint: disable=C0103
def present(subset=None, show_ipv4=False):
'''
Print a list of all minions that are up according to Salt's presence
detection, no commands will be sent
detection (no commands will be sent)
subset : None
Pass in a CIDR range to filter minions by IP address.
@ -161,6 +161,40 @@ def present(subset=None, show_ipv4=False):
return connected
def not_present(subset=None, show_ipv4=False):
'''
Print a list of all minions that are NOT up according to Salt's presence
detection (no commands will be sent)
subset : None
Pass in a CIDR range to filter minions by IP address.
show_ipv4 : False
Also show the IP address each minion is connecting from.
CLI Example:
.. code-block:: bash
salt-run manage.not_present
'''
ckminions = salt.utils.minions.CkMinions(__opts__)
minions = ckminions.connected_ids(show_ipv4=show_ipv4, subset=subset)
connected = dict(minions) if show_ipv4 else sorted(minions)
key = salt.key.Key(__opts__)
keys = key.list_keys()
not_connected = []
for minion in keys['minions']:
if not minion in connected:
not_connected.append(minion)
salt.output.display_output(not_connected, '', __opts__)
return connected
def safe_accept(target, expr_form='glob'):
'''
Accept a minion's public key after checking the fingerprint over salt-ssh