Skip to content

Commit d43f2bc

Browse files
committed
Remove unused code block, neither salt_render or file_exists was being used
1 parent 029b96c commit d43f2bc

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

changelog/60515.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug when specifying template_source using net.load_template

salt/modules/napalm_network.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -1940,21 +1940,10 @@ def load_template(
19401940
)
19411941
return _loaded # exit
19421942

1943-
# to check if will be rendered by salt or NAPALM
1944-
salt_render_prefixes = ("salt://", "http://", "https://", "ftp://")
1945-
salt_render = False
1946-
file_exists = False
1947-
if not isinstance(template_name, (tuple, list)):
1948-
for salt_render_prefix in salt_render_prefixes:
1949-
if not salt_render:
1950-
salt_render = salt_render or template_name.startswith(
1951-
salt_render_prefix
1952-
)
1953-
file_exists = __salt__["file.file_exists"](template_name)
1954-
19551943
if context is None:
19561944
context = {}
19571945
context.update(template_vars)
1946+
19581947
# if needed to render the template send as inline arg
19591948
if template_source:
19601949
# render the content

tests/pytests/unit/modules/napalm/test_network.py

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def configure_loader_modules():
2020
"file.join": napalm_test_support.join,
2121
"file.get_managed": napalm_test_support.get_managed_file,
2222
"random.hash": napalm_test_support.random_hash,
23+
"file.apply_template_on_contents": MagicMock()
2324
}
2425
}
2526

@@ -181,9 +182,13 @@ def test_load_template():
181182
"salt.utils.napalm.get_device",
182183
MagicMock(return_value=napalm_test_support.MockNapalmDevice()),
183184
):
185+
# template_name
184186
ret = napalm_network.load_template("set_ntp_peers", peers=["192.168.0.1"])
185187
assert ret["out"] is None
186188

189+
# template_source
190+
ret = napalm_network.load_template(template_source="ntp server 192.168.0.1")
191+
assert ret["out"] is None
187192

188193
def test_commit():
189194
with patch(

0 commit comments

Comments
 (0)