[BUG] Netmiko proxy module multi_call behavior is broken on salt-sproxy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
Invoking netmiko.multi_call and providing a dictionary with keys 'name', 'args' and/or 'kwargs' results in a python error
Setup
Pillar: somehost1.sls
proxy:
proxytype: netmiko
device_type: linux
ip: 127.0.0.5
username: root
password: w34k
Steps to Reproduce the behavior
salt-sproxy 'somehost1' netmiko.multi_call "{'name': 'send_command', 'kwargs': {'command_string': 'echo part one'}}" "{'name': 'send_command', 'kwargs': {'command_string':'echo part two'}}"
You get
File "/usr/local/lib/python3.7/dist-packages/netmiko/base_connection.py", line 496, in _read_channel
if self.remote_conn.recv_ready():
AttributeError: 'NoneType' object has no attribute 'recv_ready'
And alternatively if you use args and kwargs is not specified within the dictionary:
TypeError: send_command() argument after ** must be a mapping, not list
Expected behavior
Should receive a list of output of each command similar to we get if running
salt-sproxy 'somehost1' netmiko.call method="send_command" command_string="echo part one"
Versions Report
# pip3 show salt-sproxy
Name: salt-sproxy
Version: 2020.10.2
# salt --versions-report
Salt Version:
Salt: 3002.2
Dependency Versions:
cffi: 1.14.4
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: Not Installed
gitdb: 2.0.5
gitpython: 2.1.11
Jinja2: 2.10
libgit2: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 0.5.6
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.20
pycrypto: 2.6.1
pycryptodome: 3.6.1
pygit2: Not Installed
Python: 3.7.3 (default, Jul 25 2020, 13:03:44)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.1.2
smmap: 2.0.5
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist: debian 10 buster
locale: UTF-8
machine: x86_64
release: 4.19.0-13-amd64
system: Linux
version: Debian GNU/Linux 10 buster
I have tested a very simple patch successfully in the same environment as above. The patch does:
- Default kwargs to an empty dictionary instead of an empty list
- Call the netmiko method via the magic
__proxy__method if available (in the same fashion that netmiko.call operates) - Provide a CLI example of multi_call as it is not very intuitive
I could use some help in writing a test procedure however, my dev experience is minimal..
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the netmiko proxy module's multi_call entry point and compare it with the netmiko.call path, focusing on the kwargs handling and proxy invocation mentioned in the report. Reproduce the two failures with the supplied salt-sproxy commands, then add coverage showing that multi_call returns a list of outputs for both commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100