1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Plumb newline param on cliconf (#34868)

Change cb1b705218 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
This commit is contained in:
Ricardo Carrillo Cruz 2018-01-15 14:16:56 +01:00 committed by GitHub
parent 74eb0bfb13
commit 9851a0540f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -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) display.display('closing shell due to command timeout (%s seconds).' % self._connection._play_context.timeout, log_only=True)
self.close() 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 """Executes a cli command and returns the results
This method will execute the CLI command on the connection and return 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 the results to the caller. The command output will be returned as a
string string
""" """
kwargs = {'command': to_bytes(command), 'sendonly': sendonly} kwargs = {'command': to_bytes(command), 'sendonly': sendonly,
'newline': newline}
if prompt is not None: if prompt is not None:
kwargs['prompt'] = to_bytes(prompt) kwargs['prompt'] = to_bytes(prompt)
if answer is not None: if answer is not None:

View file

@ -75,12 +75,15 @@ class Cliconf(CliconfBase):
command = cmd['command'] command = cmd['command']
prompt = cmd['prompt'] prompt = cmd['prompt']
answer = cmd['answer'] answer = cmd['answer']
newline = cmd.get('newline', True)
except: except:
command = cmd command = cmd
prompt = None prompt = None
answer = 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): def get(self, command, prompt=None, answer=None, sendonly=False):
return self.send_command(to_bytes(command), prompt=to_bytes(prompt), return self.send_command(to_bytes(command), prompt=to_bytes(prompt),