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

Fix default ports. #300

Merged
merged 4 commits into from
Nov 28, 2023
Merged

Fix default ports. #300

merged 4 commits into from
Nov 28, 2023

Conversation

pszulczewski
Copy link
Contributor

@pszulczewski pszulczewski commented Nov 28, 2023

When using nautobot-nornir the default value of device port is None.

In [16]: nornir_obj.inventory.hosts['3750-x'].dict()
Out[16]: 
{'name': '3750-x',
 'connection_options': {'netmiko': {'extras': {'secret': None},
   'hostname': None,
   'port': None,
   'username': None,
   'password': None,
   'platform': 'cisco_ios'},
    ...

This causes an error on int(port) in the constructor:

nautobot_os_upgrades-worker-1    |   File "/usr/local/lib/python3.8/site-packages/pyntc/devices/ios_device.py", line 65, in __init__
nautobot_os_upgrades-worker-1    |     self.port = int(port)
nautobot_os_upgrades-worker-1    | TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

This PR fixes this behavior, by allowing port=None to be passed, but still falls back to the default value of 22.
Port default value in the constructor has been changed fro 22 to None for uniformity with other drivers.
This change also eliminates the need to set ports in nautobot plugin configuration options.

@jeffkala
Copy link
Contributor

can you drop py3.7?

@pszulczewski
Copy link
Contributor Author

can you drop py3.7?

Yes, just realized that a while ago. It's done.

@jeffkala jeffkala merged commit d060ae1 into develop Nov 28, 2023
15 checks passed
@pszulczewski pszulczewski deleted the fix_ports branch November 28, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants