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

feat: Unsupported Transceivers #111

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6da04e0
Unsupported transceiver test introduction
adambaumeister Aug 22, 2023
5e82c48
Add unsupported_transceivers to config
adambaumeister Aug 22, 2023
54a49c1
chore: introduce README badges (#112)
FoSix Aug 29, 2023
24acbdb
ci: switch to release token (#110)
FoSix Aug 29, 2023
4b303f9
feat!: check for scheduled update jobs (#106)
FoSix Sep 12, 2023
986d098
chore(release): 0.2.0
semantic-release-bot Sep 13, 2023
3f7450a
chore(deps): bump cycjimmy/semantic-release-action from 3 to 4 (#113)
dependabot[bot] Sep 14, 2023
b035eb1
chore(deps): bump actions/checkout from 3 to 4 (#114)
dependabot[bot] Sep 14, 2023
a11efcc
Minor fixes
adambaumeister Sep 15, 2023
792bdb3
Add supported_sfp_regex argument
adambaumeister Sep 19, 2023
34ad992
Change wording in docstring
adambaumeister Sep 19, 2023
e790bda
feat(FirewallProxy)!: add a constructor (#119)
FoSix Sep 20, 2023
bf99542
chore(release): 0.3.0
semantic-release-bot Sep 20, 2023
5fbd7b9
chore(deps): bump docker/login-action from 2 to 3 (#115)
dependabot[bot] Sep 25, 2023
3b0d0d8
chore(deps): bump docker/build-push-action from 4 to 5 (#117)
dependabot[bot] Sep 25, 2023
27db006
chore(deps): bump docker/metadata-action from 4 to 5 (#116)
dependabot[bot] Sep 25, 2023
50dd7ac
Unsupported transceiver test introduction
adambaumeister Aug 22, 2023
37f2e13
Add unsupported_transceivers to config
adambaumeister Aug 22, 2023
dceac19
Minor fixes
adambaumeister Sep 15, 2023
050765e
Add supported_sfp_regex argument
adambaumeister Sep 19, 2023
b0766a4
Change wording in docstring
adambaumeister Sep 19, 2023
4605fe2
Fix annotation syntax for python <3.11
adambaumeister Sep 28, 2023
175907b
Merge remote-tracking branch 'origin/adam-feat-unsupported-transceive…
adambaumeister Sep 28, 2023
a91f333
Update docs and fix lint issues
adambaumeister Oct 5, 2023
b186eba
Black formatting
adambaumeister Oct 5, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/_discover_python_ver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
pyversion: ${{ steps.pyversion.outputs.pyversion }}
steps:
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: discover Python version
id: pyversion
uses: ./.github/actions/discover_python_version
8 changes: 4 additions & 4 deletions .github/workflows/_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
contents: read
steps:
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag_name }}

Expand All @@ -55,7 +55,7 @@ jobs:

- name: determine docker tags and labels
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/paloaltonetworks/panos_upgrade_assurance
tags: |
Expand All @@ -66,14 +66,14 @@ jobs:

- name: login to GHCR
if: inputs.publish
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: build ${{ inputs.publish && 'and publish' || '' }}
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: ${{ inputs.publish }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: pack the documentation
working-directory: docs
run: tar --exclude .DS_Store --exclude sidebars.js -cvf documentation.tar *
Expand All @@ -84,7 +84,7 @@ jobs:
pull-requests: write
steps:
- name: checkout pan.dev
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: PaloAltoNetworks/pan.dev
token: ${{ secrets.CLSC_PAT }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: pack the documentation
working-directory: docs
run: tar --exclude .DS_Store --exclude sidebars.js -cvf documentation.tar *
Expand All @@ -73,7 +73,7 @@ jobs:
pull-requests: write
steps:
- name: checkout pan.dev
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: PaloAltoNetworks/pan.dev
token: ${{ secrets.CLSC_PAT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_python_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
needs: pyversion
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
ver: ${{ steps.rc.outputs.new_release_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check if new version will be produced
id: rc
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
semantic_version: 19.0
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
tag: ${{ steps.release.outputs.new_release_git_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
Expand All @@ -105,11 +105,11 @@ jobs:

- name: Create release and publish to GitHub
id: release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19.0
extra_plugins: |
conventional-changelog-conventionalcommits@^5.0.0
@semantic-release/git@^10.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
2 changes: 1 addition & 1 deletion .github/workflows/sub_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sub_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sub_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
.phony: lint
lint:
flake8 panos_upgrade_assurance tests

.phony: security
security:
bandit -c pyproject.toml -r .

.phony: format_check
format_check:
black --diff --check panos_upgrade_assurance tests

.phony: format
format:
black panos_upgrade_assurance tests

.phony: test_coverage
test_coverage:
pytest --cov panos_upgrade_assurance --cov-report=term-missing --cov-report=xml:coverage.xml

.phony: documentation
documentation:
pydoc-markdown

.phony: check_line_length
check_line_length:
@for FILE in $$(find . -type f -name '*.py'); do \
echo $$FILE; \
Expand All @@ -29,4 +36,8 @@ check_line_length:
done < "$$FILE"; \
done

.phony: all
all: lint format security test_coverage documentation

.phony: sca
sca: format lint security
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
![GitHub release (latest by date)](https://img.shields.io/github/v/release/PaloAltoNetworks/pan-os-upgrade-assurance?style=flat-square)
![GitHub](https://img.shields.io/github/license/PaloAltoNetworks/terraform-modules-vmseries-ci-workflows?style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/PaloAltoNetworks/pan-os-upgrade-assurance/release.yml?style=flat-square)
![GitHub issues](https://img.shields.io/github/issues/PaloAltoNetworks/pan-os-upgrade-assurance?style=flat-square)
![GitHub pull requests](https://img.shields.io/github/issues-pr/PaloAltoNetworks/pan-os-upgrade-assurance?style=flat-square)
![PyPI - Downloads](https://img.shields.io/pypi/dm/panos-upgrade-assurance?style=flat-square)


# PAN-OS Upgrade Assurance

## Overview
Expand Down
97 changes: 97 additions & 0 deletions docs/panos-upgrade-assurance/api/check_firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,76 @@ __Returns__
* [`CheckStatus.ERROR`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) when the certificate's
properties (installed or required) are not supported.

### `CheckFirewall._calculate_schedule_time_diff`

```python
def _calculate_schedule_time_diff(now_dt: datetime, schedule_type: str,
schedule: dict) -> (int, str)
```

A method that calculates the time distance between two `datetime` objects.

:::note
This method is used only by [`CheckFirewall.check_scheduled_updates()`](#checkfirewallcheck_scheduled_updates) method and it expects some information
to be already available.
:::

__Parameters__


- __now_dt__ (`datetime`): A `datetime` object representing the current moment in time. Ideally this should be the device's local
time, taken from the management plane clock.
- __schedule_type__ (`str`): A schedule type returned by PanOS, can be one of: `every-*`, `hourly`, `daily`, `weekly`,
`real-time`.
- __schedule__ (`dict`): Value of the `recurring` key in the API response, see
[`FirewallProxy.get_update_schedules()`](/panos/docs/panos-upgrade-assurance/api/firewall_proxy#firewallproxyget_update_schedules)
documentation for details. Both formats (locally configured and pushed from a Panorama template) are supported.

__Raises__


- `MalformedResponseException`: Thrown then the `schedule_type` is not recognizable.

__Returns__


`tuple(int, str)`: A tuple containing the calculated time difference (in minutes) and human-readable description.

### `CheckFirewall.check_scheduled_updates`

```python
def check_scheduled_updates(test_window: int = 60) -> CheckResult
```

Check if any Dynamic Update job is scheduled to run within the specified time window.

When device is configured via Panorama, this includes schedules set up in Templates. It does not however include schedules
configured in `Panorama/Device Deployment/Dynamic Updates/Schedules`.

__Parameters__


- __test_window__ (`int, optional`): (defaults to 60 minutes). A time window in minutes to look for an update job occurrence.
Has to be a value between `60` and `10080` (1 week equivalent). The time window is calculated based on the device's
local time (taken from the management plane).

__Raises__


- `MalformedResponseException`: Thrown in case API response does not meet expectations.

__Returns__


`CheckResult`: Object of [`CheckResult`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkresult) class taking value of:

* [`CheckStatus.SUCCESS`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) when there is no update job
planned within the test window.
* [`CheckStatus.FAIL`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) otherwise, `CheckResult.reason`
field contains information about the planned jobs with next occurrence time provided if possible.
* [`CheckStatus.ERROR`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) when the `test_window` parameter
does not meet criteria.

### `CheckFirewall.check_non_finished_jobs`

```python
Expand All @@ -479,6 +549,33 @@ __Returns__
* [`CheckStatus.SKIPPED`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) when there are no jobs on a
device.

### `CheckFirewall.check_unsupported_transceivers`

```python
def check_unsupported_transceivers(
supported_sfp_regex: Optional[List[str]] = None) -> CheckResult
```

Check for any Optical Transceivers (SFPs or otherwise) that aren't supported by Palo Alto Networks.

__Parameters__


- __supported_sfp_regex__ (`list, optional`): List of supported transceivers, as regex strings, to mark SFP's as
supported even if they aren't OEM.

__Returns__


`CheckResult`: Object of [`CheckResult`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkresult) class taking value of:

* [`CheckStatus.SUCCESS`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) When all optics are OEM and
PAN supported
* [`CheckStatus.FAIL`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) otherwise, `CheckResult.reason`
field contains information about which Slots and Physical ports currently have unsupported transceivers installed
* [`CheckStatus.SKIPPED`](/panos/docs/panos-upgrade-assurance/api/utils#class-checkstatus) when there are no transceiver
slots at all.

### `CheckFirewall.get_content_db_version`

```python
Expand Down
9 changes: 9 additions & 0 deletions docs/panos-upgrade-assurance/api/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ module.

Parent class for all exceptions coming from [Utils](/panos/docs/panos-upgrade-assurance/api/utils) module.

## class `WrongNumberOfArgumentsException`

Thrown when [FirewallProxy](/panos/docs/panos-upgrade-assurance/api/firewall_proxy) constructor is given wrong number or
set of arguments.

## class `CommandRunFailedException`

Used when a command run on a device does not return the `success` status.

## class `GetXpathConfigFailedException`

Used when XAPI does not return a `success` state when running a `get` operation.

## class `MalformedResponseException`

A generic exception class used when a response does not meet the expected standards.
Expand Down
Loading