@ -41,7 +41,7 @@ class Connection(_Connection):
''' CLI (shell) SSH connections on Paramiko '''
''' CLI (shell) SSH connections on Paramiko '''
transport = ' network_cli '
transport = ' network_cli '
has_pipelining = Fals e
has_pipelining = Tru e
def __init__ ( self , play_context , new_stdin , * args , * * kwargs ) :
def __init__ ( self , play_context , new_stdin , * args , * * kwargs ) :
super ( Connection , self ) . __init__ ( 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() ' )
display . debug ( ' starting network_cli._connect() ' )
network_os = self . _play_context . network_os
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 :
if not network_os :
raise AnsibleConnectionFailure (
raise AnsibleConnectionFailure (
' Unable to automatically determine host network os. Please '
' Unable to automatically determine host network os. Please '
' manually configure ansible_network_os value for this host '
' manually configure ansible_network_os value for this host '
)
)
self . _terminal = terminal_loader . get ( network_os , self )
self . _terminal = terminal_loader . get ( network_os , self )
if not self . _terminal :
if not self . _terminal :
raise AnsibleConnectionFailure ( ' network os %s is not supported ' % network_os )
raise AnsibleConnectionFailure ( ' network os %s is not supported ' % network_os )
@ -124,7 +110,7 @@ class Connection(_Connection):
if self . _shell :
if self . _shell :
self . _terminal . on_close_shell ( )
self . _terminal . on_close_shell ( )
if self . _ terminal. supports_multiplexing and self . _ shell:
if self . _ shell:
self . _shell . close ( )
self . _shell . close ( )
self . _shell = None
self . _shell = None
@ -194,12 +180,12 @@ class Connection(_Connection):
def _find_prompt ( self , response ) :
def _find_prompt ( self , response ) :
""" Searches the buffered response for a matching command prompt """
""" Searches the buffered response for a matching command prompt """
errored_response = None
errored_response = None
for regex in self . _terminal . terminal_ errors _re:
for regex in self . _terminal . terminal_ std err_re:
if regex . search ( response ) :
if regex . search ( response ) :
errored_response = response
errored_response = response
break
break
for regex in self . _terminal . terminal_ prompts _re:
for regex in self . _terminal . terminal_ stdout _re:
match = regex . search ( response )
match = regex . search ( response )
if match :
if match :
self . _matched_pattern = regex . pattern
self . _matched_pattern = regex . pattern