From 9851a0540f55b1440b73058805e638786928205e Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Mon, 15 Jan 2018 14:16:56 +0100 Subject: [PATCH] Plumb newline param on cliconf (#34868) Change cb1b7052182d675d24bbf0f815587165f0cf6f0a introduced the newline parameter on network_cli plugin, but that was never introduced on cliconf. This causes ios_user to break, since the newline value is never plumbed thru to network_cli --- lib/ansible/plugins/cliconf/__init__.py | 5 +++-- lib/ansible/plugins/cliconf/ios.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/cliconf/__init__.py b/lib/ansible/plugins/cliconf/__init__.py index 0aaca9e47f..cc631adf7c 100644 --- a/lib/ansible/plugins/cliconf/__init__.py +++ b/lib/ansible/plugins/cliconf/__init__.py @@ -94,13 +94,14 @@ class CliconfBase(with_metaclass(ABCMeta, object)): display.display('closing shell due to command timeout (%s seconds).' % self._connection._play_context.timeout, log_only=True) self.close() - def send_command(self, command, prompt=None, answer=None, sendonly=False): + def send_command(self, command, prompt=None, answer=None, sendonly=False, newline=True): """Executes a cli command and returns the results This method will execute the CLI command on the connection and return the results to the caller. The command output will be returned as a string """ - kwargs = {'command': to_bytes(command), 'sendonly': sendonly} + kwargs = {'command': to_bytes(command), 'sendonly': sendonly, + 'newline': newline} if prompt is not None: kwargs['prompt'] = to_bytes(prompt) if answer is not None: diff --git a/lib/ansible/plugins/cliconf/ios.py b/lib/ansible/plugins/cliconf/ios.py index 2b730b08da..972d4a07e5 100644 --- a/lib/ansible/plugins/cliconf/ios.py +++ b/lib/ansible/plugins/cliconf/ios.py @@ -75,12 +75,15 @@ class Cliconf(CliconfBase): command = cmd['command'] prompt = cmd['prompt'] answer = cmd['answer'] + newline = cmd.get('newline', True) except: command = cmd prompt = None answer = None + newline = True - self.send_command(to_bytes(command), to_bytes(prompt), to_bytes(answer)) + self.send_command(to_bytes(command), to_bytes(prompt), to_bytes(answer), + False, newline) def get(self, command, prompt=None, answer=None, sendonly=False): return self.send_command(to_bytes(command), prompt=to_bytes(prompt),