Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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)
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)
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)
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)
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!")
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)