How to use the citellus.RC_FAILED function in citellus

To help you get started, we’ve selected a few citellus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github citellusorg / citellus / doc / templates / template.py View on Github external
# For example, next condition might be an existing file like:
        # os.path.exists(os.join.path(CITELLUS_ROOT,'/etc/nova/nova.conf'))
        if True:

            # Example: File does exist, check file contents or other checks
            if True:
                # Plugin tests passed
                exitcitellus(code=citellus.RC_OKAY)

            else:
                # Error with plugin tests

                # Provide messages on STDERR
                exitcitellus(
                    code=citellus.RC_FAILED, msg="There was an error because of 'xxx'"
                )
        else:
            # Plugin script skipped per conditions

            # Provide reason for skipping:
            exitcitellus(code=citellus.RC_SKIPPED, msg="Required file 'xxx' not found")

    elif not runninglive():
        # Running on snapshot/sosreport environment
        if True:
            if True:
                # Plugin tests passed
                exitcitellus(code=citellus.RC_OKAY)
            else:
                # Error with plugin tests
github citellusorg / citellus / citellus / extensions / ansible-playbook.py View on Github external
# 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, ', '')

    # Now, fake 'skipped' for all the plugins which were tied to the mode we're not running in:
    for playbook in playbookskipped:
        dictionary = {'plugin': playbook,
                      'result': {'rc': citellus.RC_SKIPPED, 'err': 'Skipped for incompatible operating mode', 'out': ''}}
        results.append(dictionary)

citellus

Utility for running set of tests against a Live System or a snapshot/sosreport

GPL-3.0
Latest version published 3 years ago

Package Health Score

60 / 100
Full package analysis

Similar packages