mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
tweak transport_tests to avoid logic duplication (#22158)
This commit is contained in:
@@ -62,7 +62,7 @@ class Connection(ConnectionBase):
|
||||
super(Connection, self).__init__(*args, **kwargs)
|
||||
|
||||
self.host = self._play_context.remote_addr
|
||||
self.port = int(self._play_context.port or 22)
|
||||
self.port = self._play_context.port
|
||||
self.user = self._play_context.remote_user
|
||||
self.control_path = C.ANSIBLE_SSH_CONTROL_PATH
|
||||
self.control_path_dir = C.ANSIBLE_SSH_CONTROL_PATH_DIR
|
||||
@@ -76,8 +76,9 @@ class Connection(ConnectionBase):
|
||||
|
||||
def transport_test(self, connect_timeout):
|
||||
''' Test the transport mechanism, if available '''
|
||||
display.vvv("attempting transport test to %s:%s" % (self.host, self.port))
|
||||
sock = socket.create_connection((self.host, self.port), connect_timeout)
|
||||
port = int(self.port or 22)
|
||||
display.vvv("attempting transport test to %s:%s" % (self.host, port))
|
||||
sock = socket.create_connection((self.host, port), connect_timeout)
|
||||
sock.close()
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -92,8 +92,8 @@ class Connection(ConnectionBase):
|
||||
|
||||
def transport_test(self, connect_timeout):
|
||||
''' Test the transport mechanism, if available '''
|
||||
host = self._play_context.remote_addr
|
||||
port = int(self._play_context.port or 5986)
|
||||
host = self._winrm_host
|
||||
port = int(self._winrm_port)
|
||||
display.vvv("attempting transport test to %s:%s" % (host, port))
|
||||
sock = socket.create_connection((host, port), connect_timeout)
|
||||
sock.close()
|
||||
|
||||
Reference in New Issue
Block a user