mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-01 00:03:10 +00:00
Fix vyos sending 'None' to device (#33889)
* Fix vyos sending `'None'` to device * Move bytes handling into common cliconf code
This commit is contained in:
@@ -25,6 +25,7 @@ from abc import ABCMeta, abstractmethod
|
||||
from functools import wraps
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.module_utils.six import with_metaclass
|
||||
|
||||
try:
|
||||
@@ -99,10 +100,16 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
||||
the results to the caller. The command output will be returned as a
|
||||
string
|
||||
"""
|
||||
kwargs = {'command': to_bytes(command), 'sendonly': sendonly}
|
||||
if prompt is not None:
|
||||
kwargs['prompt'] = to_bytes(prompt)
|
||||
if answer is not None:
|
||||
kwargs['answer'] = to_bytes(answer)
|
||||
|
||||
if not signal.getsignal(signal.SIGALRM):
|
||||
signal.signal(signal.SIGALRM, self._alarm_handler)
|
||||
signal.alarm(self._connection._play_context.timeout)
|
||||
resp = self._connection.send(command, prompt, answer, sendonly)
|
||||
resp = self._connection.send(**kwargs)
|
||||
signal.alarm(0)
|
||||
return resp
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class Cliconf(CliconfBase):
|
||||
self.send_command(to_bytes(cmd))
|
||||
|
||||
def get(self, command, prompt=None, answer=None, sendonly=False):
|
||||
return self.send_command(to_bytes(command), prompt=to_bytes(prompt), answer=to_bytes(answer), sendonly=sendonly)
|
||||
return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly)
|
||||
|
||||
def commit(self, comment=None):
|
||||
if comment:
|
||||
|
||||
Reference in New Issue
Block a user