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_template_string(self, nornir):
result = nornir.run(text.template_string, template=simple_j2)
assert result
for h, r in result.items():
assert "host-name: {}".format(h) in r.result
if h == "host1.group_1":
assert "my_var: comes_from_host1.group_1" in r.result
if h == "host2.group_1":
assert "my_var: comes_from_group_1" in r.result
def junos_acl(task):
in_yaml = task.run(task=data.load_yaml, file=f"acl.yaml")
in_yaml = in_yaml[0].result
multi_result = task.run(
task=text.template_file, template="acl.j2", path=".", acls=in_yaml
)
print()
print("#" * 80, end="")
print(multi_result[0].result)
print("#" * 80)
print()
def render_configurations(task):
task.run(task=text.template_file, template="loopback.j2", path=".", **task.host)
def render_configurations(task):
bgp = task.run(
task=text.template_file, template="bgp.j2", path="nxos/", **task.host
)
intf = task.run(
task=text.template_file, template="routed_int.j2", path="nxos/", **task.host
)
task.host["bgp_config"] = bgp.result
task.host["intf_config"] = intf.result
def render_configurations(task):
bgp = task.run(
task=text.template_file, template="bgp.j2", path="nxos/", **task.host
)
intf = task.run(
task=text.template_file, template="routed_int.j2", path="nxos/", **task.host
)
task.host["bgp_config"] = bgp.result
task.host["intf_config"] = intf.result