Import cleanup, plus have /bin/ansible remind you if no hosts were matched by a pattern (for instance, assume

there was a typo in the pattern)
This commit is contained in:
Michael DeHaan 2012-03-18 17:53:58 -04:00
commit 9c5ec886a6
4 changed files with 20 additions and 10 deletions

View file

@ -149,6 +149,14 @@ def has_dark_hosts(results):
''' are there any uncontactable hosts? '''
return len(results['dark'].keys()) > 0
def has_contacted_hosts(results):
''' are there any contacted hosts? '''
return len(results['contacted'].keys()) > 0
def has_hosts(results):
''' did ansible run against any hosts at all? '''
return has_contacted_hosts(results) or has_dark_hosts(results)
def contacted_hosts(results):
''' what are the contactable hosts? '''
return sorted(results['contacted'])
@ -186,7 +194,11 @@ def async_poll_status(jid, host, clock, result):
else:
return "<job %s> polling on %s, %s remaining" % (jid, host, clock)
def json_loads(data):
return json.loads(data)
def parse_json(data):
''' this version for module return data only '''
try:
return json.loads(data)
except: