Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX 60515] - Fix bug when specifying template_source using net.load_template #67715

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stiltzkin10
Copy link

@stiltzkin10 stiltzkin10 commented Feb 9, 2025

What does this PR do?

Remove unsued code block that causes the script to fail. It sets the local variables salt_render and file_exists, neither of them is used later in the code.

The code block uses template_name which is not mandatory if the user specifies template_source. If template_name is not set, the code crashes.

What issues does this PR fix or reference?

Fixes #60515

Previous Behavior

$ sudo salt XXXX net.load_template template_source='ntp server 192.168.1.100' test=true
XXXX:
    The minion function caused an exception: Traceback (most recent call last):
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/metaproxy/proxy.py", line 479, in thread_return
        return_data = minion_instance.executors[fname](
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1232, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1247, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
        return func(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1232, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1247, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/napalm.py", line 502, in func_wrapper
        ret = func(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/napalm_network.py", line 1959, in load_template
        salt_render = False
    AttributeError: 'NoneType' object has no attribute 'startswith'

New Behavior

$ sudo salt XXXX net.load_template template_source='ntp server 192.168.1.100' test=true
XXXX:
    ----------
    already_configured:
        False
    comment:
        Configuration discarded.
    diff:
        +ntp server 192.168.1.100
    loaded_config:
    result:
        True

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@stiltzkin10 stiltzkin10 requested a review from a team as a code owner February 9, 2025 09:02
@stiltzkin10 stiltzkin10 changed the title [BUG 60515] - Fix bug when specifying template_source using net.load_template [BUGFIX 60515] - Fix bug when specifying template_source using net.load_template Feb 9, 2025
@stiltzkin10 stiltzkin10 force-pushed the fix-60515-load-template branch from 8c0931a to d43f2bc Compare February 9, 2025 19:05
twangboy
twangboy previously approved these changes Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] napalm: net.load_template does not work
2 participants