Skip to content

Commit

Permalink
Bump Packages, Update Tests (#115)
Browse files Browse the repository at this point in the history
* Update napalm, netmiko, python versions

---------

Co-authored-by: Anthony House <[email protected]>
  • Loading branch information
housepbass and Anthony House authored Apr 23, 2024
1 parent 36b62be commit 7197c80
Show file tree
Hide file tree
Showing 10 changed files with 1,349 additions and 1,433 deletions.
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
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\.)|(sdwan\.)")
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

0 comments on commit 7197c80

Please sign in to comment.