Skip to content

Commit

Permalink
Merge branch 'PaloAltoNetworks:develop' into advanced-routing-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianczech authored Feb 6, 2024
2 parents 58fed92 + 17c2cf0 commit 9450bf2
Show file tree
Hide file tree
Showing 40 changed files with 1,933 additions and 712 deletions.
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:1-3.9-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/poetry:2": {
"version": "latest"
},
"ghcr.io/dhoeric/features/google-cloud-cli:1": {}
},
"postCreateCommand": "poetry install",
"customizations": {
"vscode": {
"extensions": [
// Python
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"ms-python.flake8",
"matangover.mypy",
"nwgh.bandit",
"KevinRose.vsc-python-indent",
// RestructuredText
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
// Helpers
"tamasfe.even-better-toml",
"njpwerner.autodocstring",
"aaron-bond.better-comments",
// Tools
"github.vscode-github-actions",
"GitHub.copilot",
"ms-toolsai.jupyter",
// VIM
"vscodevim.vim"
]
}
}
}
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9"]
steps:
- uses: actions/checkout@v2

Expand All @@ -30,11 +30,11 @@ jobs:
- name: Install Poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.3.2
poetry-version: 1.7.1

- name: Get poetry cache directory
id: poetry-cache
run: echo "::set-output name=dir::$(poetry config cache-dir)"
run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache poetry dependencies
uses: actions/cache@v2
Expand All @@ -58,27 +58,27 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.8

- name: Install Poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.3.2
poetry-version: 1.7.1

- name: Get poetry cache directory
id: poetry-cache
run: echo "::set-output name=dir::$(poetry config cache-dir)"
run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache poetry dependencies
uses: actions/cache@v1
with:
path: ${{ steps.poetry-cache.outputs.dir }}
key: ${{ runner.os }}-poetry-3.7-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-poetry-3.8-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-3.7-
${{ runner.os }}-poetry-3.8-
- name: Install dependencies
run: poetry install
Expand All @@ -95,27 +95,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.8

- name: Install Poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.3.2
poetry-version: 1.7.1

- name: Get poetry cache directory
id: poetry-cache
run: echo "::set-output name=dir::$(poetry config cache-dir)"
run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache poetry dependencies
uses: actions/cache@v1
with:
path: ${{ steps.poetry-cache.outputs.dir }}
key: ${{ runner.os }}-poetry-3.7-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-poetry-3.8-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-3.7-
${{ runner.os }}-poetry-3.8-
- name: Install dependencies
run: poetry install
Expand Down
22 changes: 22 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.7"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# We recommend specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
26 changes: 13 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@
"source.organizeImports": "explicit"
},
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["--no-cov"],
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.banditEnabled": true,
"python.linting.banditArgs": ["-r", "--ini .bandit"],
"python.linting.flake8Enabled": true,
"python.linting.flake8CategorySeverity.E": "Warning",
"python.linting.mypyEnabled": false,
"python.formatting.provider": "black",
"python.testing.pytestArgs": [
"--no-cov"
],
"editor.formatOnSave": true,
"restructuredtext.confPath": "${workspaceFolder}/docs",
"cSpell.words": [
"Vlan",
"etree",
Expand All @@ -27,5 +19,13 @@
"pandevice",
"pan-os-python",
"refreshall"
]
}
],
"black-formatter.importStrategy": "fromEnvironment",
"bandit.importStrategy": "fromEnvironment",
"bandit.args": [
"-r",
"--ini .bandit"
],
"flake8.importStrategy": "fromEnvironment",
"flake8.args": ["--config=.flake8"]
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ bandit:
bandit -r --ini .bandit

format:
isort --recursive --atomic panos
isort --atomic panos
black .

check-format:
isort --recursive --atomic --check-only panos
isort --atomic --check-only panos
black --check --diff .

test:
Expand Down
6 changes: 4 additions & 2 deletions docs/configtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ def node_style(cls):
style = "style=filled " + nodestyle[module] + " "
except:
pass
result = ' {0} [{1}URL="../module-{2}.html#panos.{3}" target="_top"];\n'.format(
cls_name, style, module, cls
result = (
' {0} [{1}URL="../module-{2}.html#panos.{3}" target="_top"];\n'.format(
cls_name, style, module, cls
)
)
else:
if style:
Expand Down
4 changes: 3 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
mistune<2.0.0
m2r==0.2.1
m2r==0.3.1
sphinx_rtd_theme
pan-python==0.17.0
7 changes: 5 additions & 2 deletions examples/dyn_address_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@


def main():

# Get command line arguments
parser = argparse.ArgumentParser(
description="Tag an IP address on a Palo Alto Networks Next generation Firewall"
Expand Down Expand Up @@ -111,7 +110,11 @@ def main():
logging.basicConfig(format=logging_format, level=logging_level)

# Connect to the device and determine its type (Firewall or Panorama).
device = PanDevice.create_from_device(args.hostname, args.username, args.password,)
device = PanDevice.create_from_device(
args.hostname,
args.username,
args.password,
)

# Panorama does not have a userid API, so exit.
# You can use the userid API on a firewall with the Panorama 'target'
Expand Down
7 changes: 5 additions & 2 deletions examples/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@


def main():

# Get command line arguments
parser = argparse.ArgumentParser(
description="Upgrade a Palo Alto Networks Firewall or Panorama to the specified version"
Expand Down Expand Up @@ -95,7 +94,11 @@ def main():

# Connect to the device and determine its type (Firewall or Panorama).
# This is important to know what version to upgrade to next.
device = PanDevice.create_from_device(args.hostname, args.username, args.password,)
device = PanDevice.create_from_device(
args.hostname,
args.username,
args.password,
)

# Perform the upgrades in sequence with reboots between each upgrade
device.software.upgrade_to_version(args.version, args.dryrun)
Expand Down
7 changes: 5 additions & 2 deletions examples/userid.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@


def main():

# Get command line arguments
parser = argparse.ArgumentParser(
description="Update User-ID by adding or removing a user-to-ip mapping"
Expand Down Expand Up @@ -90,7 +89,11 @@ def main():
logging.basicConfig(format=logging_format, level=logging_level)

# Connect to the device and determine its type (Firewall or Panorama).
device = PanDevice.create_from_device(args.hostname, args.username, args.password,)
device = PanDevice.create_from_device(
args.hostname,
args.username,
args.password,
)

logging.debug("Detecting type of device")

Expand Down
36 changes: 36 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Global options:

[mypy]
ignore_missing_imports = True
; follow_imports = silent
show_column_numbers = True
warn_unused_configs = False
disallow_subclassing_any = False
disallow_any_generics = False
disallow_untyped_calls = False
disallow_untyped_defs = False
disallow_incomplete_defs = False
check_untyped_defs = True
disallow_untyped_decorators = False
no_implicit_optional = False
warn_redundant_casts = False
warn_unused_ignores = False
warn_return_any = False

# Per-module options:

## In this section, add overrides for specific files, modules, or functions
## that don't yet have type annotations. For example:
## [mypy-older_module.older_file]
## disallow_untyped_defs = False

[mypy-panos.updater]
disallow_subclassing_any = True
disallow_any_generics = True
disallow_untyped_defs = False
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_unused_ignores = True
warn_return_any = True
Loading

0 comments on commit 9450bf2

Please sign in to comment.