|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|