Open ITJamie opened 2 years ago
This issue is confirmed but it's not related to the onedir builds of Salt.
Currently, Salt does not support napalm 4.x.
If napalm 3.x is installed, this issue does not happen.
I haven't tested 3005 thoroughly yet, but I'm seeing a similar (if not the exact same) error in 3004.2. The Proxy Minion starts correctly however, it just seems like this is caused by the chicken-and-egg problem PMs have, and the error is thrown when the proxy isn't fully loaded yet, so it's just cosmetic. In my environment I've worked around this by patching the napalm.py
proxy module:
diff --git a/salt/proxy/napalm.py b/salt/proxy/napalm.py
index 7e81ded4d5..bed6ae456e 100644
--- a/salt/proxy/napalm.py
+++ b/salt/proxy/napalm.py
@@ -248,6 +248,8 @@ def get_device():
"""
Returns the network device object.
"""
+ if "napalm_device" not in __context__:
+ return {}
return __context__["napalm_device"]["network_device"]
@@ -344,6 +346,8 @@ def call(method, *args, **kwargs):
# thus the NAPALM methods will be called with their defaults
if warg is None:
kwargs.pop(karg)
+ if "napalm_device" not in __context__:
+ return {"result": False, "comment": "Not initialised yet", "out": None}
return salt.utils.napalm.call(
__context__["napalm_device"]["network_device"], method, *args, **kwargs
)
Hi,
Currently, Salt does not support napalm 4.x. If napalm 3.x is installed, this issue does not happen.
Actually, I seem to be getting messages like this with napalm 3.3.1...
File "/usr/lib/python3/dist-packages/salt/proxy/napalm.py", line 258, in get_grains
return call("get_facts", **{})
File "/usr/lib/python3/dist-packages/salt/proxy/napalm.py", line 348, in call
__context__["napalm_device"]["network_device"], method, *args, **kwargs
File "/usr/lib/python3/dist-packages/salt/loader/context.py", line 78, in __getitem__
return self.value()[item]
File "/usr/lib/python3/dist-packages/salt/utils/context.py", line 221, in __getitem__
return self._dict()[key]
KeyError: 'napalm_device'
>>> import napalm
>>> napalm.__version__
'3.3.1'
Description Latest dev build from this pipeline: https://gitlab.com/saltstack/open/salt-pkg/-/pipelines/613600623 napalm proxy grains is throwing an error related to napalm.version
This is a follow on from https://github.com/saltstack/salt/issues/62393
Setup (Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.) Latest dev build from this pipeline: https://gitlab.com/saltstack/open/salt-pkg/-/pipelines/613600623 a working device to connect to salt-proxy
Steps to Reproduce the behavior https://github.com/napalm-automation/napalm-salt/tree/master/saltstack - a quick example of a salt setup with napalm install napalm with salt pip (salt-pip install napalm) Start a proxy module and watch /var/log/salt/proxy. the following error will appear
Expected behavior No errors related to proxy process
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ```yaml Salt Version: Salt: 3005rc2+86.g54e2c9fa06 Dependency Versions: cffi: 1.14.6 cherrypy: 18.6.1 dateutil: 2.8.1 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.0 libgit2: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack: 1.0.2 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: 2.21 pycrypto: Not Installed pycryptodome: 3.9.8 pygit2: Not Installed Python: 3.9.13 (main, Aug 15 2022, 10:08:44) python-gnupg: 0.4.8 PyYAML: 5.4.1 PyZMQ: 23.2.0 smmap: Not Installed timelib: 0.2.4 Tornado: 4.5.3 ZMQ: 4.3.4 System Versions: dist: debian 11 bullseye locale: utf-8 machine: x86_64 release: 5.10.0-12-amd64 system: Linux version: Debian GNU/Linux 11 bullseye ```