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

Trouble with use JSNAPy from python for more than one devices #384

Closed
yurys555 opened this issue Jan 15, 2021 · 5 comments
Closed

Trouble with use JSNAPy from python for more than one devices #384

yurys555 opened this issue Jan 15, 2021 · 5 comments
Assignees

Comments

@yurys555
Copy link

Hello! I have an error with this Python code. AttributeError: 'SnapAdmin' object has no attribute 'host_list'
What i'm doing wrong?

from jnpr.jsnapy import SnapAdmin
from jnpr.junos import Device

js = SnapAdmin()

config_file = """
hosts:

  • device: jun_sw1
    port: 22
    username: test
    passwd: test
  • device: jun_sw2
    port: 22
    username: test
    passwd: test
    tests:
  • test_interfaces.yml
    """

js.snap(config_file, "pre")

Python 3.7.9
jsnapy==1.3.5
junos-eznc==2.5.4

@rahkumar651991 rahkumar651991 self-assigned this Jan 28, 2021
@will-mcdermott
Copy link

I had the same issue. The following resolved this for me:

+++ b/lib/jnpr/jsnapy/jsnapy.py
@@ -47,6 +47,7 @@ class SnapAdmin:

  •    self.host_list = []
    

@@ -969,8 +970,7 @@ class SnapAdmin:

  •                    host_dict[iter] = deepcopy(val.get(hostname))
    
  •                    host_dict[iter]["device"] = hostname
    
  •                    host_dict[iter] = deepcopy(val)
    

@yurys555
Copy link
Author

yurys555 commented Feb 1, 2021

@will-mcdermott Thanks! It's helped.

@niklash-dev
Copy link

@will-mcdermott Thank you, I was about to get a headache 👍

@chidanandpujar
Copy link
Collaborator

issue is not reproducible in the latest jsnapy verision 1.3.8.dev0, we will close this issue as fixed.

Please refer the following pass logs.

from jnpr.jsnapy import SnapAdmin
from pprint import pprint
from jnpr.junos import Device

js = SnapAdmin()

config_data = """
hosts:
  - device: x.x.x.x
    username : xyz
    passwd: xyz

  - device: x.x.x.x
    username : xyz
    passwd: xyz
tests:
  - test_snmp.yml 
"""

snap = js.snap(config_data, "pre")


python issu_384_mult_dev.py 
Connecting to device x.x.x.x ................
Taking snapshot of RPC: get-configuration
Connecting to device x.x.x.x ................
Taking snapshot of RPC: get-configuration

Thanks
Chidanand

@chidanandpujar
Copy link
Collaborator

issue is not reproducible in the latest jsnapy verision 1.3.8.dev0, we will close this issue as fixed.

Thanks
Chidanand

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

No branches or pull requests

5 participants