Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent/missing host names in messages. #15174

Merged
merged 1 commit into from
Mar 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/ansible/plugins/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ def check_missing_password(self, output):

def connection_lock(self):
f = self._play_context.connection_lockfd
display.vvvv('CONNECTION: pid %d waiting for lock on %d' % (os.getpid(), f))
display.vvvv('CONNECTION: pid %d waiting for lock on %d' % (os.getpid(), f), host=self._play_context.remote_addr)
fcntl.lockf(f, fcntl.LOCK_EX)
display.vvvv('CONNECTION: pid %d acquired lock on %d' % (os.getpid(), f))
display.vvvv('CONNECTION: pid %d acquired lock on %d' % (os.getpid(), f), host=self._play_context.remote_addr)

def connection_unlock(self):
f = self._play_context.connection_lockfd
fcntl.lockf(f, fcntl.LOCK_UN)
display.vvvv('CONNECTION: pid %d released lock on %d' % (os.getpid(), f))
display.vvvv('CONNECTION: pid %d released lock on %d' % (os.getpid(), f), host=self._play_context.remote_addr)
44 changes: 22 additions & 22 deletions lib/ansible/plugins/connection/accelerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ def _connect(self):
tries = 3
self.conn = socket.socket()
self.conn.settimeout(C.ACCELERATE_CONNECT_TIMEOUT)
display.vvvv("attempting connection to %s via the accelerated port %d" % (self._play_context.remote_addr,self._play_context.accelerate_port))
display.vvvv("attempting connection to %s via the accelerated port %d" % (self._play_context.remote_addr, self._play_context.accelerate_port), host=self._play_context.remote_addr)
while tries > 0:
try:
self.conn.connect((self._play_context.remote_addr,self._play_context.accelerate_port))
break
except socket.error:
display.vvvv("connection to %s failed, retrying..." % self._play_context.remote_addr)
display.vvvv("connection to %s failed, retrying..." % self._play_context.remote_addr, host=self._play_context.remote_addr)
time.sleep(0.1)
tries -= 1
if tries == 0:
display.vvv("Could not connect via the accelerated connection, exceeded # of tries")
display.vvv("Could not connect via the accelerated connection, exceeded # of tries", host=self._play_context.remote_addr)
raise AnsibleConnectionFailure("Failed to connect to %s on the accelerated port %s" % (self._play_context.remote_addr, self._play_context.accelerate_port))
elif wrong_user:
display.vvv("Restarting daemon with a different remote_user")
display.vvv("Restarting daemon with a different remote_user", host=self._play_context.remote_addr)
raise AnsibleError("The accelerated daemon was started on the remote with a different user")

self.conn.settimeout(C.ACCELERATE_TIMEOUT)
Expand All @@ -102,25 +102,25 @@ def recv_data(self):
header_len = 8 # size of a packed unsigned long long
data = b""
try:
display.vvvv("%s: in recv_data(), waiting for the header" % self._play_context.remote_addr)
display.vvvv("in recv_data(), waiting for the header", host=self._play_context.remote_addr)
while len(data) < header_len:
d = self.conn.recv(header_len - len(data))
if not d:
display.vvvv("%s: received nothing, bailing out" % self._play_context.remote_addr)
display.vvvv("received nothing, bailing out", host=self._play_context.remote_addr)
return None
data += d
display.vvvv("%s: got the header, unpacking" % self._play_context.remote_addr)
display.vvvv("got the header, unpacking", host=self._play_context.remote_addr)
data_len = struct.unpack('!Q',data[:header_len])[0]
data = data[header_len:]
display.vvvv("%s: data received so far (expecting %d): %d" % (self._play_context.remote_addr,data_len,len(data)))
display.vvvv("data received so far (expecting %d): %d" % (data_len, len(data)), host=self._play_context.remote_addr)
while len(data) < data_len:
d = self.conn.recv(data_len - len(data))
if not d:
display.vvvv("%s: received nothing, bailing out" % self._play_context.remote_addr)
display.vvvv("received nothing, bailing out", host=self._play_context.remote_addr)
return None
display.vvvv("%s: received %d bytes" % (self._play_context.remote_addr, len(d)))
display.vvvv("received %d bytes" % (len(d)), host=self._play_context.remote_addr)
data += d
display.vvvv("%s: received all of the data, returning" % self._play_context.remote_addr)
display.vvvv("received all of the data, returning", host=self._play_context.remote_addr)
return data
except socket.timeout:
raise AnsibleError("timed out while waiting to receive data")
Expand All @@ -132,7 +132,7 @@ def validate_user(self):
daemon to exit if they don't match
'''

display.vvvv("%s: sending request for validate_user" % self._play_context.remote_addr)
display.vvvv("sending request for validate_user", host=self._play_context.remote_addr)
data = dict(
mode='validate_user',
username=self._play_context.remote_user,
Expand All @@ -142,7 +142,7 @@ def validate_user(self):
if self.send_data(data):
raise AnsibleError("Failed to send command to %s" % self._play_context.remote_addr)

display.vvvv("%s: waiting for validate_user response" % self._play_context.remote_addr)
display.vvvv("waiting for validate_user response", host=self._play_context.remote_addr)
while True:
# we loop here while waiting for the response, because a
# long running command may cause us to receive keepalive packets
Expand All @@ -154,10 +154,10 @@ def validate_user(self):
response = json.loads(response)
if "pong" in response:
# it's a keepalive, go back to waiting
display.vvvv("%s: received a keepalive packet" % self._play_context.remote_addr)
display.vvvv("received a keepalive packet", host=self._play_context.remote_addr)
continue
else:
display.vvvv("%s: received the validate_user response: %s" % (self._play_context.remote_addr, response))
display.vvvv("received the validate_user response: %s" % (response), host=self._play_context.remote_addr)
break

if response.get('failed'):
Expand All @@ -174,7 +174,7 @@ def exec_command(self, cmd, in_data=None, sudoable=True):
if in_data:
raise AnsibleError("Internal Error: this module does not support optimized module pipelining")

display.vvv("EXEC COMMAND %s" % cmd)
display.vvv("EXEC COMMAND %s" % cmd, host=self._play_context.remote_addr)

data = dict(
mode='command',
Expand All @@ -197,10 +197,10 @@ def exec_command(self, cmd, in_data=None, sudoable=True):
response = json.loads(response)
if "pong" in response:
# it's a keepalive, go back to waiting
display.vvvv("%s: received a keepalive packet" % self._play_context.remote_addr)
display.vvvv("received a keepalive packet", host=self._play_context.remote_addr)
continue
else:
display.vvvv("%s: received the response" % self._play_context.remote_addr)
display.vvvv("received the response", host=self._play_context.remote_addr)
break

return (response.get('rc', None), response.get('stdout', ''), response.get('stderr', ''))
Expand All @@ -216,10 +216,10 @@ def put_file(self, in_path, out_path):
fd = file(in_path, 'rb')
fstat = os.stat(in_path)
try:
display.vvv("PUT file is %d bytes" % fstat.st_size)
display.vvv("PUT file is %d bytes" % fstat.st_size, host=self._play_context.remote_addr)
last = False
while fd.tell() <= fstat.st_size and not last:
display.vvvv("file position currently %ld, file size is %ld" % (fd.tell(), fstat.st_size))
display.vvvv("file position currently %ld, file size is %ld" % (fd.tell(), fstat.st_size), host=self._play_context.remote_addr)
data = fd.read(CHUNK_SIZE)
if fd.tell() >= fstat.st_size:
last = True
Expand All @@ -242,7 +242,7 @@ def put_file(self, in_path, out_path):
raise AnsibleError("failed to put the file in the requested location")
finally:
fd.close()
display.vvvv("waiting for final response after PUT")
display.vvvv("waiting for final response after PUT", host=self._play_context.remote_addr)
response = self.recv_data()
if not response:
raise AnsibleError("Failed to get a response from %s" % self._play_context.remote_addr)
Expand Down Expand Up @@ -290,7 +290,7 @@ def fetch_file(self, in_path, out_path):
# point in the future or we may just have the put/fetch
# operations not send back a final response at all
response = self.recv_data()
display.vvv("FETCH wrote %d bytes to %s" % (bytes, out_path))
display.vvv("FETCH wrote %d bytes to %s" % (bytes, out_path), host=self._play_context.remote_addr)
fh.close()

def close(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/connection/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _connect(self, port=None):
super(Connection, self)._connect()
if not self._connected:
display.vvv(u"ESTABLISH DOCKER CONNECTION FOR USER: {0}".format(
self.actual_user or '?', host=self._play_context.remote_addr)
self.actual_user or '?'), host=self._play_context.remote_addr
)
self._connected = True

Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/plugins/connection/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _connect(self):
self._play_context.remote_user = getpass.getuser()

if not self._connected:
display.vvv(u"ESTABLISH LOCAL CONNECTION FOR USER: {0}".format(self._play_context.remote_user, host=self._play_context.remote_addr))
display.vvv(u"ESTABLISH LOCAL CONNECTION FOR USER: {0}".format(self._play_context.remote_user), host=self._play_context.remote_addr)
self._connected = True
return self

Expand All @@ -68,7 +68,7 @@ def exec_command(self, cmd, in_data=None, sudoable=True):

executable = C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else None

display.vvv(u"{0} EXEC {1}".format(self._play_context.remote_addr, cmd))
display.vvv(u"EXEC {0}".format(cmd), host=self._play_context.remote_addr)
# FIXME: cwd= needs to be set to the basedir of the playbook
display.debug("opening command with Popen()")

Expand Down Expand Up @@ -122,7 +122,7 @@ def put_file(self, in_path, out_path):

super(Connection, self).put_file(in_path, out_path)

display.vvv(u"{0} PUT {1} TO {2}".format(self._play_context.remote_addr, in_path, out_path))
display.vvv(u"PUT {0} TO {1}".format(in_path, out_path), host=self._play_context.remote_addr)
if not os.path.exists(to_bytes(in_path, errors='strict')):
raise AnsibleFileNotFound("file or module does not exist: {0}".format(to_str(in_path)))
try:
Expand All @@ -137,7 +137,7 @@ def fetch_file(self, in_path, out_path):

super(Connection, self).fetch_file(in_path, out_path)

display.vvv(u"{0} FETCH {1} TO {2}".format(self._play_context.remote_addr, in_path, out_path))
display.vvv(u"FETCH {0} TO {1}".format(in_path, out_path), host=self._play_context.remote_addr)
self.put_file(in_path, out_path)

def close(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/connection/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def exec_command(self, *args, **kwargs):
else:
msg = "ssh_retry: attempt: %d, caught exception(%s) from cmd (%s), pausing for %d seconds" % (attempt, e, cmd_summary, pause)

display.vv(msg)
display.vv(msg, host=self.host)

time.sleep(pause)
continue
Expand Down