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

Arista SSH not closing connections correctly #1735

Closed
1 task done
Gobam opened this issue Aug 18, 2022 · 0 comments · Fixed by #1736
Closed
1 task done

Arista SSH not closing connections correctly #1735

Gobam opened this issue Aug 18, 2022 · 0 comments · Fixed by #1736
Assignees

Comments

@Gobam
Copy link

Gobam commented Aug 18, 2022

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

  • 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'
@bewing bewing self-assigned this Aug 18, 2022
bewing added a commit that referenced this issue Aug 18, 2022
bewing added a commit that referenced this issue Aug 22, 2022
bewing added a commit that referenced this issue Aug 22, 2022
bewing added a commit that referenced this issue Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants