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

106 firewall snapshot after upgrade not generated #107

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ WORKDIR /app
ADD settings.yaml /app

# Install any needed packages specified in requirements.txt
# Note: The requirements.txt should contain pan-os-upgrade==1.3.3
RUN pip install --no-cache-dir pan-os-upgrade==1.3.3
# Note: The requirements.txt should contain pan-os-upgrade==1.3.4
RUN pip install --no-cache-dir pan-os-upgrade==1.3.4

# Set the locale to avoid issues with emoji rendering
ENV LANG C.UTF-8
Expand Down
9 changes: 9 additions & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

Welcome to the release notes for the `pan-os-upgrade` tool. This document provides a detailed record of changes, enhancements, and fixes in each version of the tool.

## Version 1.3.4

**Release Date:** *<20240303>*

<!-- trunk-ignore(markdownlint/MD024) -->
### What's New

- Resolved an issue where snapshots would not be taken after an upgrade if settings.yaml file was present in the current working directory.

## Version 1.3.3

**Release Date:** *<20240228>*
Expand Down
81 changes: 38 additions & 43 deletions pan_os_upgrade/components/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,57 +726,52 @@ def upgrade_firewall(
# Early return, no snapshot performed
return None

else:
# Perform the post-upgrade snapshot
post_snapshot = perform_snapshot(
actions=selected_actions,
file_path=f'assurance/snapshots/{hostname}/post/{time.strftime("%Y-%m-%d_%H-%M-%S")}.json',
firewall=firewall,
hostname=hostname,
settings_file_path=settings_file_path,
)
# Perform the post-upgrade snapshot
post_snapshot = perform_snapshot(
actions=selected_actions,
file_path=f'assurance/snapshots/{hostname}/post/{time.strftime("%Y-%m-%d_%H-%M-%S")}.json',
firewall=firewall,
hostname=hostname,
settings_file_path=settings_file_path,
)

# initialize object storing both snapshots
snapshot_compare = SnapshotCompare(
left_snapshot=pre_snapshot.model_dump(),
right_snapshot=post_snapshot.model_dump(),
)
# initialize object storing both snapshots
snapshot_compare = SnapshotCompare(
left_snapshot=pre_snapshot.model_dump(),
right_snapshot=post_snapshot.model_dump(),
)

pre_post_diff = snapshot_compare.compare_snapshots(selected_actions)
pre_post_diff = snapshot_compare.compare_snapshots(selected_actions)

logging.debug(
f"{get_emoji(action='report')} {hostname}: Snapshot comparison before and after upgrade {pre_post_diff}"
)
logging.debug(
f"{get_emoji(action='report')} {hostname}: Snapshot comparison before and after upgrade {pre_post_diff}"
)

folder_path = f"assurance/snapshots/{hostname}/diff"
pdf_report = (
f'{folder_path}/{time.strftime("%Y-%m-%d_%H-%M-%S")}_report.pdf'
)
ensure_directory_exists(file_path=pdf_report)

# Generate the PDF report for the diff
generate_diff_report_pdf(
file_path=pdf_report,
hostname=hostname,
pre_post_diff=pre_post_diff,
target_version=target_version,
)
folder_path = f"assurance/snapshots/{hostname}/diff"
pdf_report = f'{folder_path}/{time.strftime("%Y-%m-%d_%H-%M-%S")}_report.pdf'
ensure_directory_exists(file_path=pdf_report)

logging.info(
f"{get_emoji(action='save')} {hostname}: Snapshot comparison PDF report saved to {pdf_report}"
)
# Generate the PDF report for the diff
generate_diff_report_pdf(
file_path=pdf_report,
hostname=hostname,
pre_post_diff=pre_post_diff,
target_version=target_version,
)

json_report = (
f'{folder_path}/{time.strftime("%Y-%m-%d_%H-%M-%S")}_report.json'
)
logging.info(
f"{get_emoji(action='save')} {hostname}: Snapshot comparison PDF report saved to {pdf_report}"
)

# Write the file to the local filesystem as JSON
with open(json_report, "w") as file:
file.write(json.dumps(pre_post_diff))
json_report = f'{folder_path}/{time.strftime("%Y-%m-%d_%H-%M-%S")}_report.json'

logging.debug(
f"{get_emoji(action='save')} {hostname}: Snapshot comparison JSON report saved to {json_report}"
)
# Write the file to the local filesystem as JSON
with open(json_report, "w") as file:
file.write(json.dumps(pre_post_diff))

logging.debug(
f"{get_emoji(action='save')} {hostname}: Snapshot comparison JSON report saved to {json_report}"
)

else:
logging.error(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pan-os-upgrade"
version = "1.3.3"
version = "1.3.4"
description = "Python script to automate the upgrade process of PAN-OS firewalls."
authors = ["Calvin Remsburg <[email protected]>"]
documentation = "https://cdot65.github.io/pan-os-upgrade/"
Expand Down
Loading