How to use the nornir.plugins.functions.text.print_result function in nornir

To help you get started, we’ve selected a few nornir 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 nornir-automation / nornir / tests / plugins / functions / text / test_print_result.py View on Github external
def test_print_failed_with_severity(self, nornir):
        nornir.config.logging.configure()
        result = nornir.run(read_data)
        print_result(result, vars=["exception", "output"], severity_level=logging.ERROR)
github twin-bridges / nornir_course / class5 / exercises / exercise2 / exercise2.py View on Github external
def main():
    nr = InitNornir(config_file="config.yaml")
    nr = nr.filter(F(groups__contains="eos"))
    for hostname, host_obj in nr.inventory.hosts.items():
        host_obj.password = PASSWORD
    agg_result = nr.run(task=networking.napalm_get, getters=["config"])
    print_result(agg_result)
github twin-bridges / nornir_course / class3 / exercises / exercise6 / exercise6a.py View on Github external
def main():
    nr = InitNornir(config_file="config.yaml")
    nr = nr.filter(F(groups__contains="nxos"))
    agg_result = nr.run(task=napalm_get, getters=["config"])
    print_result(agg_result)
github twin-bridges / nornir_course / class6 / exercises / exercise5 / exercise5c.py View on Github external
def main():
    nr = InitNornir(config_file="config.yaml")
    for hostname, host_obj in nr.inventory.hosts.items():
        if random.choice([True, False]):
            host_obj.password = BAD_PASSWORD
    agg_result = nr.run(task=send_command)
    print_result(agg_result)
github twin-bridges / nornir_course / bonus1 / exercises / exercise5 / exercise5b.py View on Github external
def main():
    nr = InitNornir(config_file="config.yaml")
    nr = nr.filter(F(groups__contains="nxos"))
    agg_result = nr.run(task=get_checkpoint_file)
    print_result(agg_result)
github twin-bridges / nornir_course / class5 / exercises / exercise5 / exercise5c.py View on Github external
def main():
    nr = InitNornir(config_file="config.yaml")
    nr = nr.filter(F(groups__contains="nxos"))
    agg_result = nr.run(task=render_configurations)
    print_result(agg_result)
    agg_result = nr.run(task=write_configurations)
    print_result(agg_result)
    agg_result = nr.run(task=deploy_configurations)
    print_result(agg_result)
    nr.run(task=validate_bgp)
github twin-bridges / nornir_course / bonus2 / exercises / bgp_config_tool_final.py View on Github external
prepare_interfaces,
        ensure_config_flags,
        get_current_checkpoint,
        render_configurations,
        create_new_checkpoint,
        push_updated_checkpoint,
    ]
    nr = InitNornir(config_file="config.yaml")
    nr = nr.filter(F(groups__contains="nxos"))
    for task in task_list:
        result = nr.run(task=task)
        if any(v.changed for k, v in result.items()):
            print(f">>> Task '{result.name.upper()}' changed...")
        if result.failed:
            print(f">>> Task '{result.name.upper()}' failed... result:")
            print_result(result)
        else:
            print(f">>> Task '{result.name.upper()}' completed successfully!")
github twin-bridges / nornir_course / bonus1 / exercises / exercise2 / exercise2b.py View on Github external
def main():
    nr = InitNornir(config_file="config_b.yaml")
    nr = nr.filter(F(groups__contains="nxos"))
    agg_result = nr.run(task=networking.napalm_get, getters=["facts"])
    print_result(agg_result)