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

Merge v0.6.1 to Master #116

Merged
merged 3 commits into from
Apr 23, 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: "ubuntu-20.04"
env:
PYTHON_VER: "${{ matrix.python-version }}"
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
env:
PYTHON_VER: "${{ matrix.python-version }}"
steps:
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: "ubuntu-20.04"
env:
PYTHON_VER: "${{ matrix.python-version }}"
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 0.6.1 - 2024-04

### Added
- #108 Added Support for sdwan interfaces
- #105 Include interface description for get_interfaces method


### Fixed
- #115 Update package dependencies, fix tests

# 0.6.0 - 2022-02

### Added
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is community version of [NAPALM](https://napalm.readthedocs.io/) for the Pa

This table identifies the currently available configuration methods supported:

| Getter | Supported |
| Feature | Supported |
| ------------------------- | --------- |
| Config Replace | ✅ |
| Commit Confirm | ❌ |
Expand All @@ -24,10 +24,10 @@ This table identifies the currently available configuration methods supported:

Configuration Lock is also supported, but the `optional_args` `config_lock` key set to `True`. You can see in this example.

```
```python
from napalm import get_network_driver

panos_device = device"
panos_device = "nyc-sw01"
panos_user = "admin"
panos_password = "pass123"
driver = get_network_driver("panos")
Expand All @@ -36,6 +36,7 @@ optional_args = {"config_lock": True}
with driver(panos_device, panos_user, panos_password, optional_args=optional_args) as device:
device.load_replace_candidate(filename="2022-01-01-intended-config.xml")
device.commit_config()

```

As shown in the example above, the use of NAPALM's context manager is supported and recommended to use.
Expand Down
2 changes: 1 addition & 1 deletion napalm_panos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
# Import local modules
from napalm_panos.panos import PANOSDriver

__version__ = "0.6.0"
__version__ = "0.6.1"

__all__ = ("PANOSDriver",)
26 changes: 15 additions & 11 deletions napalm_panos/panos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Napalm-panos."""

# pylint: disable=abstract-method,raise-missing-from
# Copyright 2016 Dravetech AB. All rights reserved.
#
Expand Down Expand Up @@ -219,6 +220,7 @@ def _import_file(self, filename):
params=params,
headers={"Content-Type": mef.content_type},
data=mef,
timeout=5,
)
# if something goes wrong just raise an exception
request.raise_for_status()
Expand Down Expand Up @@ -265,7 +267,7 @@ def load_replace_candidate(self, filename=None, config=None):
raise ReplaceConfigException(f"Error while loading config from {path}")
self.loaded = True

def _get_file_content(self, filename): # pylint: disable=no-self-use
def _get_file_content(self, filename):
"""Convenience method to get file content."""
try:
with open(filename, "r", encoding="utf-8") as file:
Expand All @@ -278,7 +280,7 @@ def _send_merge_commands(self, config, file_config):
"""Netmiko is being used to push set commands."""
if self.loaded is False:
if self._save_backup() is False:
raise MergeConfigException("Error while storing backup " "config.")
raise MergeConfigException("Error while storing backup config.")
if self.ssh_connection is False:
self._open_ssh()

Expand Down Expand Up @@ -343,7 +345,7 @@ def load_merge_candidate(self, filename=None, config=None):
self._send_merge_commands(config, file_config)

else:
raise MergeConfigException("You must provide either a file " "or a set-format string")
raise MergeConfigException("You must provide either a file or a set-format string")

def compare_config(self):
"""Netmiko is being used to obtain config diffs because pan-python doesn't support the needed command."""
Expand Down Expand Up @@ -414,7 +416,7 @@ def rollback(self):
self.changed = False
self.merge_config = False
except Exception: # noqa pylint: disable=broad-except
ReplaceConfigException("Error while loading backup config")
raise ReplaceConfigException("Error while loading backup config")

def _extract_interface_list(self):
self.device.op(cmd="<show><interface>all</interface></show>")
Expand Down Expand Up @@ -483,7 +485,7 @@ def get_facts(self):
if system_info:
facts["hostname"] = system_info["hostname"]
facts["vendor"] = "Palo Alto Networks"
facts["uptime"] = int(convert_uptime_string_seconds(system_info["uptime"]))
facts["uptime"] = float(convert_uptime_string_seconds(system_info["uptime"]))
facts["os_version"] = system_info["sw-version"]
facts["serial_number"] = system_info["serial"]
facts["model"] = system_info["model"]
Expand Down Expand Up @@ -618,13 +620,15 @@ def get_interfaces(self): # pylint: disable=too-many-locals
subif_defaults = {
"is_up": True,
"is_enabled": True,
"speed": 0,
"speed": 0.0,
"last_flapped": -1.0,
"mac_address": "",
"mtu": 0,
"description": "",
}
interface_pattern = re.compile(r"(ethernet\d+/\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)|(vlan\.)")
interface_pattern = re.compile(
r"(ethernet\d+/\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)|(vlan\.)|(sdwan\.)"
)
interface_dict = {}
interface_descr = {}
interface_list = self._extract_interface_list()
Expand Down Expand Up @@ -676,13 +680,13 @@ def get_interfaces(self): # pylint: disable=too-many-locals
interface["speed"] = interface_info.get("speed")
# Loopback and down interfaces
if interface["speed"] in ("[n/a]", "unknown"):
interface["speed"] = 0
interface["speed"] = 0.0
else:
try:
interface["speed"] = int(interface["speed"])
interface["speed"] = float(interface["speed"])
except ValueError:
# Handle when unable to convert a string to an integer, set it to 0 similar to the unknown state.
interface["speed"] = 0
# Handle when unable to convert a string to an float, set it to 0 similar to the unknown state.
interface["speed"] = 0.0
interface["mac_address"] = standardize_mac(interface_info.get("mac"))
interface["description"] = interface_descr.get(intf, "")
interface_dict[intf] = interface
Expand Down
Loading
Loading