@ -39,14 +39,8 @@ class Connection(_Connection):
def __init__ ( self , play_context , new_stdin , * args , * * kwargs ) :
super ( Connection , self ) . __init__ ( play_context , new_stdin , * args , * * kwargs )
assert self . _play_context . network_os , ' ansible_network_os must be set '
self . _terminal = terminal_loader . get ( self . _play_context . network_os , self )
if not self . _terminal :
raise AnsibleConnectionFailure ( ' network os %s is not supported ' % self . _play_context . network_os )
self . _terminal = None
self . _shell = None
self . _matched_prompt = None
self . _matched_pattern = None
self . _last_response = None
@ -64,6 +58,24 @@ class Connection(_Connection):
def _connect ( self ) :
super ( Connection , self ) . _connect ( )
network_os = self . _play_context . network_os
if not network_os :
for cls in terminal_loader . all ( class_only = True ) :
network_os = cls . guess_network_os ( self . ssh )
if network_os :
break
if not network_os :
raise AnsibleConnectionFailure (
' unable to determine device network os. Please configure '
' ansible_network_os value '
)
self . _terminal = terminal_loader . get ( network_os , self )
if not self . _terminal :
raise AnsibleConnectionFailure ( ' network os %s is not supported ' % network_os )
return ( 0 , ' connected ' , ' ' )
def open_shell ( self , timeout = 10 ) :