Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def callcitellus(path=False, plugins=False):
"""
Do actual execution of citellus against data
:param path: sosreport path
:param plugins: plugins enabled as provided to citellus
:return: dict with results
"""
# Call citellus and format data returned
results = citellus.docitellus(path=path, plugins=plugins)
# Process plugin output from multiple plugins
new_dict = {}
for item in results:
name = item['plugin']
new_dict[name] = item
return new_dict
if options.live is True:
for playbook in playbooksnap:
if citellus.regexpfile(file=playbook, regexp="CITELLUS_HYBRID"):
# Add to the list of playbooks to run
playbooks.append(playbook)
# Remove from the skipped playbooks
playbookskipped.remove(playbook)
commands = []
ansible = which("ansible-playbook")
for playbook in playbooks:
commands.append("%s -i localhost --connection=local, %s" % (ansible, playbook))
# Actually run the tests
results = citellus.docitellus(live=options.live, path=None, plugins=commands, lang='en_US')
# Do formatting of results to remove ansible-playbook -i localhost, and adjust return codes to citellus standards
for result in results:
# Convert RC codes to what citellus expects
if result['result']['rc'] == 2:
result['result']['rc'] = citellus.RC_FAILED
elif result['result']['rc'] == 0:
result['result']['rc'] = citellus.RC_OKAY
# Convert stdout to stderr for citellus handling
result['result']['err'] = result['result']['out']
result['result']['out'] = ''
# Remove ansible-playbook command and just leave yml file
result['plugin'] = result['plugin'].replace(which('ansible-playbook'), '').replace(' -i localhost --connection=local, ', '')