Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds new feature to network_cli #19848

Merged
merged 1 commit into from
Jan 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/ansible/plugins/connection/network_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def send(self, obj):
command = obj['command']
self._history.append(command)
self._shell.sendall('%s\r' % command)
if obj.get('sendonly'):
return
return self.receive(obj)
except (socket.timeout, AttributeError):
raise AnsibleConnectionFailure("timeout trying to send command: %s" % command.strip())
Expand Down Expand Up @@ -206,15 +208,13 @@ def exec_command(self, cmd):
* command - the command string to execute
* prompt - the expected prompt generated by executing command
* response - the string to respond to the prompt with
* sendonly - bool to disable waiting for response

:arg cmd: the string that represents the command to be executed
which can be a single command or a json encoded string
:returns: a tuple of (return code, stdout, stderr). The return
code is an integer and stdout and stderr are strings
"""
# TODO: add support for timeout to the cmd to handle non return
# commands such as a system restart

try:
obj = json.loads(cmd)
except ValueError:
Expand Down