Skip to content

Commit bfc71e2

Browse files
authored
Merge pull request #2254 from napalm-automation/develop
Release 5.1.0 (attempt 2)
2 parents 539ca85 + db485ea commit bfc71e2

File tree

90 files changed

+2857
-2790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2857
-2790
lines changed

.github/workflows/commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
max-parallel: 4
1212
matrix:
13-
python-version: [3.8, 3.9, 3.10.9, 3.11, 3.12.0]
13+
python-version: ["3.9", "3.10.9", "3.11", "3.12", "3.13"]
1414

1515
steps:
1616
- name: Checkout repository

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ docs/_static/
5959
.venv
6060
.vscode
6161
.devcontainer
62+
.python-version
6263

6364
env
6465
*.swp

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Install
3131
pip install napalm
3232
```
3333

34+
*Note*: Beginning with release 5.1.0 and later, NAPALM offers support for
35+
Python 3.9+ only.
36+
3437
*Note*: Beginning with release 5.0.0 and later, NAPALM offers support for
3538
Python 3.8+ only.
3639

3740
*Note*: Beginning with release 4.0.0 and later, NAPALM offers support for
3841
Python 3.7+ only.
3942

40-
*Note*: Beginning with release 3.0.0 and later, NAPALM offers support for
41-
Python 3.6+ only.
42-
4343

4444
Upgrading
4545
=========

docs/requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
urllib3==2.2.1 # https://github.com/readthedocs/readthedocs.org/issues/10290
2-
sphinx==7.2.6
1+
urllib3==2.3.0 # https://github.com/readthedocs/readthedocs.org/issues/10290
2+
sphinx==7.4.7
33
sphinx-rtd-theme==2.0.0
44
invoke==2.2.0
5-
jinja2==3.1.3
6-
MarkupSafe==2.1.5
7-
pytest==7.3.1
8-
ansible==9.4.0
5+
jinja2==3.1.6
6+
MarkupSafe==3.0.2
7+
pytest==8.3.5
8+
ansible==11.3.0

napalm/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pkg_resources
1+
from importlib.metadata import version, PackageNotFoundError
22
import sys
33
import logging
44

@@ -17,14 +17,14 @@
1717

1818
# Verify Python Version that is running
1919
try:
20-
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
21-
raise RuntimeError("NAPALM requires Python 3.7 or greater")
20+
if not (sys.version_info.major == 3 and sys.version_info.minor >= 9):
21+
raise RuntimeError("NAPALM requires Python 3.9 or greater")
2222
except AttributeError:
23-
raise RuntimeError("NAPALM requires Python 3.7 or greater")
23+
raise RuntimeError("NAPALM requires Python 3.9 or greater")
2424

2525
try:
26-
__version__ = pkg_resources.get_distribution("napalm").version
27-
except pkg_resources.DistributionNotFound:
26+
__version__ = version("napalm")
27+
except PackageNotFoundError:
2828
__version__ = "Not installed"
2929

3030
__all__ = ("get_network_driver", "SUPPORTED_DRIVERS")

napalm/base/base.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def get_lldp_neighbors_detail(
639639

640640
def get_bgp_config(
641641
self, group: str = "", neighbor: str = ""
642-
) -> models.BPGConfigGroupDict:
642+
) -> models.BGPConfigGroupDict:
643643
"""
644644
Returns a dictionary containing the BGP configuration.
645645
Can return either the whole config, either the config only for a group or neighbor.
@@ -921,12 +921,23 @@ def get_ntp_servers(self) -> Dict[str, models.NTPServerDict]:
921921
"""
922922
Returns the NTP servers configuration as dictionary.
923923
The keys of the dictionary represent the IP Addresses of the servers.
924-
Inner dictionaries do not have yet any available keys.
924+
Inner dictionaries MAY contain information regarding per-server configuration.
925925
926926
Example::
927927
928928
{
929-
'192.168.0.1': {},
929+
'192.168.0.1':
930+
{
931+
'address': '192.168.0.1',
932+
'port': 123,
933+
'version': 4,
934+
'association_type': 'SERVER',
935+
'iburst': False,
936+
'prefer': False,
937+
'network_instance': 'default',
938+
'source_address': '192.0.2.1',
939+
'key_id': -1,
940+
},
930941
'17.72.148.53': {},
931942
'37.187.56.220': {},
932943
'162.158.20.18': {}

napalm/base/clitools/cl_napalm.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import logging
88
import argparse
99
import getpass
10-
import pkg_resources
10+
import pkgutil
11+
from importlib.metadata import version
1112
from functools import wraps
1213

1314

@@ -156,9 +157,9 @@ def check_installed_packages():
156157
logger.debug("Gathering napalm packages")
157158
napalm_packages = sorted(
158159
[
159-
"{}=={}".format(i.key, i.version)
160-
for i in pkg_resources.working_set
161-
if i.key.startswith("napalm")
160+
"{}=={}".format(i.name, version(i.name))
161+
for i in list(pkgutil.iter_modules())
162+
if i.name.startswith("napalm")
162163
]
163164
)
164165
for n in napalm_packages:

napalm/base/models.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@
153153
"AFDict", {"sent_prefixes": int, "accepted_prefixes": int, "received_prefixes": int}
154154
)
155155

156-
BPGConfigGroupDict = TypedDict(
157-
"BPGConfigGroupDict",
156+
BGPConfigGroupDict = TypedDict(
157+
"BGPConfigGroupDict",
158158
{
159159
"type": str,
160160
"description": str,
@@ -188,8 +188,8 @@
188188
},
189189
)
190190

191-
BGPStateAdressFamilyDict = TypedDict(
192-
"BGPStateAdressFamilyDict",
191+
BGPStateAddressFamilyDict = TypedDict(
192+
"BGPStateAddressFamilyDict",
193193
{"received_prefixes": int, "accepted_prefixes": int, "sent_prefixes": int},
194194
)
195195

@@ -203,7 +203,7 @@
203203
"is_enabled": bool,
204204
"description": str,
205205
"uptime": int,
206-
"address_family": Dict[str, BGPStateAdressFamilyDict],
206+
"address_family": Dict[str, BGPStateAddressFamilyDict],
207207
},
208208
)
209209

@@ -223,16 +223,22 @@
223223

224224
NTPPeerDict = TypedDict(
225225
"NTPPeerDict",
226-
{
227-
# will populate it in the future wit potential keys
228-
},
226+
{},
229227
total=False,
230228
)
231229

232230
NTPServerDict = TypedDict(
233231
"NTPServerDict",
234232
{
235-
# will populate it in the future wit potential keys
233+
"address": str,
234+
"port": int,
235+
"version": int,
236+
"association_type": str,
237+
"iburst": bool,
238+
"prefer": bool,
239+
"network_instance": str,
240+
"source_address": str,
241+
"key_id": int,
236242
},
237243
total=False,
238244
)

napalm/base/test/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def test_get_bgp_config(self):
323323
result = len(get_bgp_config) > 0
324324

325325
for bgp_group in get_bgp_config.values():
326-
result = result and self._test_model(models.BPGConfigGroupDict, bgp_group)
326+
result = result and self._test_model(models.BGPConfigGroupDict, bgp_group)
327327
for bgp_neighbor in bgp_group.get("neighbors", {}).values():
328328
result = result and self._test_model(
329329
models.BGPConfigNeighborDict, bgp_neighbor

napalm/base/test/getters.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def mock_wrapper(cls, test_case):
9090
attr.current_test = "" # Empty them to avoid side effects
9191
attr.current_test_case = "" # Empty them to avoid side effects
9292

93-
return result
93+
return None
9494

9595
@functools.wraps(func)
9696
def real_wrapper(cls, test_case):
@@ -249,7 +249,7 @@ def test_get_bgp_config(self, test_case):
249249
assert get_bgp_config == {} or len(get_bgp_config) > 0
250250

251251
for bgp_group in get_bgp_config.values():
252-
assert helpers.test_model(models.BPGConfigGroupDict, bgp_group)
252+
assert helpers.test_model(models.BGPConfigGroupDict, bgp_group)
253253
for bgp_neighbor in bgp_group.get("neighbors", {}).values():
254254
assert helpers.test_model(models.BGPConfigNeighborDict, bgp_neighbor)
255255

@@ -311,7 +311,9 @@ def test_get_ntp_peers(self, test_case):
311311

312312
for peer, peer_details in get_ntp_peers.items():
313313
assert isinstance(peer, str)
314-
assert helpers.test_model(models.NTPPeerDict, peer_details)
314+
assert helpers.test_model(
315+
models.NTPPeerDict, peer_details, allow_subset=True
316+
)
315317

316318
return get_ntp_peers
317319

@@ -323,7 +325,9 @@ def test_get_ntp_servers(self, test_case):
323325

324326
for server, server_details in get_ntp_servers.items():
325327
assert isinstance(server, str)
326-
assert helpers.test_model(models.NTPServerDict, server_details)
328+
assert helpers.test_model(
329+
models.NTPServerDict, server_details, allow_subset=True
330+
)
327331

328332
return get_ntp_servers
329333

0 commit comments

Comments
 (0)