saltstack / saltstack/salt

[BUG] Filter option for napalm.junos_rpc get_config not working after upgrading from 3004 to 3006.5 onedir

Open
#65,867 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
After upgrading from salt 3004 to 3006.5 onedir I'm unable to apply filter using napalm.junos_rpc get_config

Please be as specific as possible and give set-up details.

  • on-prem machine
  • [X ] VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • [X ] onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior
On salt 3004 I was able to use this command:

salt 'foo-bar-01' napalm.junos_rpc get_config filter='<configuration><security><address-book></address-book></security></configuration>'

On salt salt 3006.5 I got this error:

salt 'foo-bar-01' napalm.junos_rpc get_config filter='<configuration><security><address-book></address-book></security></configuration>'

foo-bar-01:
   The minion function caused an exception: Traceback (most recent call last):
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/junos.py", line 373, in rpc
       reply = getattr(conn.rpc, cmd.replace("-", "_"))(filter_reply, options=op)
     File "/opt/saltstack/salt/extras-3.10/jnpr/junos/rpcmeta.py", line 117, in get_config
       rpc = E("get-configuration", options)
     File "src/lxml/builder.py", line 222, in lxml.builder.ElementMaker.__call__
     File "src/lxml/builder.py", line 186, in lxml.builder.ElementMaker.__init__.add_dict
   KeyError: <class 'bool'>

   During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/metaproxy/proxy.py", line 485, in thread_return
       return_data = minion_instance.executors[fname](
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
       ret = self.loader.run(run_func, *args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
       return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
       return _func_or_method(*args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
       return func(*args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
       ret = self.loader.run(run_func, *args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
       return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
       return _func_or_method(*args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/napalm.py", line 502, in func_wrapper
       ret = func(*args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/napalm_mod.py", line 824, in junos_rpc
       rpc_ret = __salt__["junos.rpc"](cmd=cmd, dest=dest, format=format, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
       ret = self.loader.run(run_func, *args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
       return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
       return _func_or_method(*args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/junos.py", line 169, in wrapper
       return function(*args, **kwargs)
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/junos.py", line 377, in rpc
       _restart_connection()
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/junos.py", line 234, in _restart_connection
       __proxy__["junos.shutdown"](__opts__)  # safely close connection
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/context.py", line 78, in __getitem__
       return self.value()[item]
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 349, in __getitem__
       super().__getitem__(item)  # try to get the item from the dictionary
     File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/lazy.py", line 107, in __getitem__
       return self._dict[key]
   KeyError: 'junos.shutdown'
ERROR: Minions returned with non-zero exit code

Expected behavior
The device configuration filtered as specified in the command

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3006.5

Python Version:
        Python: 3.10.13 (main, Nov 15 2023, 04:34:27) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.14.2
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: oracle 8.9
        locale: utf-8
       machine: x86_64
       release: 5.4.17-2136.326.6.el8uek.x86_64
        system: Linux
       version: Oracle Linux Server 8.9

Additional context

Both salt-master and proxy are using the same version
salt 'foo-bar-01' napalm.junos_rpc get_config (without filter) works fine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rpc entry point in salt/modules/junos.py and the junos_rpc entry point in salt/modules/napalm_mod.py, then reproduce the reported get_config command with its XML filter. Trace the get_config call through the Junos RPC dependency and verify that the filtered device configuration is returned without the reported exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.