self._display.vvvv("connection to %s failed, retrying..."%self._play_context.remote_addr)
display.vvvv("connection to %s failed, retrying..."%self._play_context.remote_addr)
time.sleep(0.1)
tries-=1
iftries==0:
self._display.vvv("Could not connect via the accelerated connection, exceeded # of tries")
display.vvv("Could not connect via the accelerated connection, exceeded # of tries")
raiseAnsibleConnectionFailure("Failed to connect to %s on the accelerated port %s"%(self._play_context.remote_addr,self._play_context.accelerate_port))
elifwrong_user:
self._display.vvv("Restarting daemon with a different remote_user")
display.vvv("Restarting daemon with a different remote_user")
raiseAnsibleError("The accelerated daemon was started on the remote with a different user")
self.conn.settimeout(C.ACCELERATE_TIMEOUT)
@ -97,25 +103,25 @@ class Connection(ConnectionBase):
header_len=8# size of a packed unsigned long long
data=b""
try:
self._display.vvvv("%s: in recv_data(), waiting for the header"%self._play_context.remote_addr)
display.vvvv("%s: in recv_data(), waiting for the header"%self._play_context.remote_addr)
whilelen(data)<header_len:
d=self.conn.recv(header_len-len(data))
ifnotd:
self._display.vvvv("%s: received nothing, bailing out"%self._play_context.remote_addr)
display.vvvv("%s: received nothing, bailing out"%self._play_context.remote_addr)
returnNone
data+=d
self._display.vvvv("%s: got the header, unpacking"%self._play_context.remote_addr)
display.vvvv("%s: got the header, unpacking"%self._play_context.remote_addr)
data_len=struct.unpack('!Q',data[:header_len])[0]
data=data[header_len:]
self._display.vvvv("%s: data received so far (expecting %d): %d"%(self._play_context.remote_addr,data_len,len(data)))
display.vvvv("%s: data received so far (expecting %d): %d"%(self._play_context.remote_addr,data_len,len(data)))
whilelen(data)<data_len:
d=self.conn.recv(data_len-len(data))
ifnotd:
self._display.vvvv("%s: received nothing, bailing out"%self._play_context.remote_addr)
display.vvvv("%s: received nothing, bailing out"%self._play_context.remote_addr)
returnNone
self._display.vvvv("%s: received %d bytes"%(self._play_context.remote_addr,len(d)))
display.vvvv("%s: received %d bytes"%(self._play_context.remote_addr,len(d)))
data+=d
self._display.vvvv("%s: received all of the data, returning"%self._play_context.remote_addr)
display.vvvv("%s: received all of the data, returning"%self._play_context.remote_addr)
returndata
exceptsocket.timeout:
raiseAnsibleError("timed out while waiting to receive data")
@ -127,7 +133,7 @@ class Connection(ConnectionBase):
daemontoexitiftheydon't match
'''
self._display.vvvv("%s: sending request for validate_user"%self._play_context.remote_addr)
display.vvvv("%s: sending request for validate_user"%self._play_context.remote_addr)
data=dict(
mode='validate_user',
username=self._play_context.remote_user,
@ -137,7 +143,7 @@ class Connection(ConnectionBase):
ifself.send_data(data):
raiseAnsibleError("Failed to send command to %s"%self._play_context.remote_addr)
self._display.vvvv("%s: waiting for validate_user response"%self._play_context.remote_addr)
display.vvvv("%s: waiting for validate_user response"%self._play_context.remote_addr)
whileTrue:
# we loop here while waiting for the response, because a
# long running command may cause us to receive keepalive packets
@ -149,10 +155,10 @@ class Connection(ConnectionBase):
response=json.loads(response)
if"pong"inresponse:
# it's a keepalive, go back to waiting
self._display.vvvv("%s: received a keepalive packet"%self._play_context.remote_addr)
display.vvvv("%s: received a keepalive packet"%self._play_context.remote_addr)
continue
else:
self._display.vvvv("%s: received the validate_user response: %s"%(self._play_context.remote_addr,response))
display.vvvv("%s: received the validate_user response: %s"%(self._play_context.remote_addr,response))
break
ifresponse.get('failed'):
@ -169,7 +175,7 @@ class Connection(ConnectionBase):
ifin_data:
raiseAnsibleError("Internal Error: this module does not support optimized module pipelining")
self._display.vvv("EXEC COMMAND %s"%cmd)
display.vvv("EXEC COMMAND %s"%cmd)
data=dict(
mode='command',
@ -192,10 +198,10 @@ class Connection(ConnectionBase):
response=json.loads(response)
if"pong"inresponse:
# it's a keepalive, go back to waiting
self._display.vvvv("%s: received a keepalive packet"%self._play_context.remote_addr)
display.vvvv("%s: received a keepalive packet"%self._play_context.remote_addr)
continue
else:
self._display.vvvv("%s: received the response"%self._play_context.remote_addr)
display.vvvv("%s: received the response"%self._play_context.remote_addr)
paramiko:Theauthenticityofhost'%s'can't be established.
The%skeyfingerprintis%s.
@ -114,6 +118,7 @@ class MyAddPolicy(object):
SSH_CONNECTION_CACHE={}
SFTP_CONNECTION_CACHE={}
classConnection(ConnectionBase):
''' SSH based connections with Paramiko '''
@ -140,7 +145,7 @@ class Connection(ConnectionBase):
raiseAnsibleError("paramiko is not installed")
port=self._play_context.portor22
self._display.vvv("ESTABLISH CONNECTION FOR USER: %s on PORT %s TO %s"%(self._play_context.remote_user,port,self._play_context.remote_addr),host=self._play_context.remote_addr)
display.vvv("ESTABLISH CONNECTION FOR USER: %s on PORT %s TO %s"%(self._play_context.remote_user,port,self._play_context.remote_addr),host=self._play_context.remote_addr)
ssh=paramiko.SSHClient()
@ -214,7 +219,7 @@ class Connection(ConnectionBase):