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

Changes backup_file to be conditional #96

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions nornir_nautobot/plugins/tasks/dispatcher/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ def get_config(
logger.log_debug("Substitute lines from configuration based on `substitute_lines` definition")
running_config = sanitize_config(running_config, substitute_lines)

make_folder(os.path.dirname(backup_file))
if backup_file:
itdependsnetworks marked this conversation as resolved.
Show resolved Hide resolved
make_folder(os.path.dirname(backup_file))

with open(backup_file, "w", encoding="utf8") as filehandler:
filehandler.write(running_config)
with open(backup_file, "w", encoding="utf8") as filehandler:
filehandler.write(running_config)
return Result(host=task.host, result={"config": running_config})

@staticmethod
Expand Down Expand Up @@ -330,10 +331,11 @@ def get_config(
logger.log_debug("Substitute lines from configuration based on `substitute_lines` definition")
running_config = sanitize_config(running_config, substitute_lines)

make_folder(os.path.dirname(backup_file))
if backup_file:
make_folder(os.path.dirname(backup_file))

with open(backup_file, "w", encoding="utf8") as filehandler:
filehandler.write(running_config)
with open(backup_file, "w", encoding="utf8") as filehandler:
filehandler.write(running_config)
return Result(host=task.host, result={"config": running_config})

@staticmethod
Expand Down