clean up of terminal plugins (#21549)

* removes unneeded supports_multiplexing var
* refactors terminal_prompts_re to terminal_stdout_re
* refactors terminal_errors_re to terminal_stderr_re
* updates network_cli unit test cases
This commit is contained in:
Peter Sprygada 2017-02-17 10:00:23 -05:00 committed by GitHub
parent c5452eef6f
commit a6cecef6bc
11 changed files with 26 additions and 59 deletions

View file

@ -41,7 +41,7 @@ class Connection(_Connection):
''' CLI (shell) SSH connections on Paramiko '''
transport = 'network_cli'
has_pipelining = False
has_pipelining = True
def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
@ -71,26 +71,12 @@ class Connection(_Connection):
display.debug('starting network_cli._connect()')
network_os = self._play_context.network_os
if not network_os:
for cls in terminal_loader.all(class_only=True):
try:
network_os = cls.guess_network_os(self.ssh)
if network_os:
break
except:
raise AnsibleConnectionFailure(
'Unable to automatically determine host network os. '
'Please manually configure ansible_network_os value '
'for this host'
)
if not network_os:
raise AnsibleConnectionFailure(
'Unable to automatically determine host network os. Please '
'manually configure ansible_network_os value for this host'
)
self._terminal = terminal_loader.get(network_os, self)
if not self._terminal:
raise AnsibleConnectionFailure('network os %s is not supported' % network_os)
@ -124,7 +110,7 @@ class Connection(_Connection):
if self._shell:
self._terminal.on_close_shell()
if self._terminal.supports_multiplexing and self._shell:
if self._shell:
self._shell.close()
self._shell = None
@ -194,12 +180,12 @@ class Connection(_Connection):
def _find_prompt(self, response):
"""Searches the buffered response for a matching command prompt"""
errored_response = None
for regex in self._terminal.terminal_errors_re:
for regex in self._terminal.terminal_stderr_re:
if regex.search(response):
errored_response = response
break
for regex in self._terminal.terminal_prompts_re:
for regex in self._terminal.terminal_stdout_re:
match = regex.search(response)
if match:
self._matched_pattern = regex.pattern