Skip to content

Fix default ports.#300

Merged
jeffkala merged 4 commits into
developfrom
fix_ports
Nov 28, 2023
Merged

Fix default ports.#300
jeffkala merged 4 commits into
developfrom
fix_ports

Conversation

@pszulczewski

@pszulczewski pszulczewski commented Nov 28, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

can you drop py3.7?

@pszulczewski

Copy link
Copy Markdown
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
@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