jsnapy icon indicating copy to clipboard operation
jsnapy copied to clipboard

Trouble with use JSNAPy from python for more than one devices

Open yurys555 opened this issue 4 years ago • 3 comments

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

yurys555 avatar Jan 15 '21 14:01 yurys555

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)
    

will-mcdermott avatar Jan 31 '21 16:01 will-mcdermott

@will-mcdermott Thanks! It's helped.

yurys555 avatar Feb 01 '21 08:02 yurys555

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

niklash-dev avatar Feb 01 '21 12:02 niklash-dev

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 avatar Jun 11 '24 04:06 chidanandpujar

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

Thanks Chidanand

chidanandpujar avatar Jun 11 '24 09:06 chidanandpujar