napalm
napalm copied to clipboard
Arista SSH not closing connections correctly
Description of Issue/Question
Napalm is not closing correctly the objects created for Arista SSH session. We identified this when noted a thread that remains open after a getter is completed for an EOS device. Trying to use the close() method is causing an exception (see below)
Did you follow the steps from https://github.com/napalm-automation/napalm#faq
- [x] Yes
- [] No
Setup
napalm version
napalm==4.0.0
Network operating system version
vEOS
Hardware version:
Serial number:
Hardware MAC address: 5000.005b.6ff5
System MAC address: 5000.005b.6ff5
Software image version: 4.26.1F
Architecture: x86_64
Internal build version: 4.26.1F-22602519.4261F
Internal build ID: 1eca5f74-3ced-441a-9137-c966e8f0319d
Image format version: 01.00
Uptime: 0 weeks, 4 days, 8 hours and 42 minutes
Total memory: 2006832 kB
Free memory: 953144 kB
Steps to Reproduce the Issue
Run a script including a Napalm getter inside a loop and monitor the threads. It will show a new thread after each run:
import napalm
from threading import enumerate
eos = napalm.get_network_driver("eos")
optional_args={
'port':22,
'transport': 'ssh',
}
for _ in range(10):
# Connect:
device = eos(
hostname="192.168.0.1",
username="user",
password="password",
optional_args=optional_args
)
device.open()
result = device.get_interfaces()
#device.close()
print(result)
for thread in enumerate():
print(thread.name)
device.close() is commented as it causes an exception
Error Traceback
Traceback (most recent call last):
File "test_napalm.py", line 21, in <module>
device.close()
File ".../venv/lib/python3.8/site-packages/napalm/eos/eos.py", line 234, in close
if hasattr(self.device.connection, "close") and callable(
AttributeError: 'AristaSSH' object has no attribute 'connection'