mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Give IP address to socket.connect, rather than DNS name
This commit is contained in:
parent
774454e475
commit
344246096d
@ -195,21 +195,25 @@ with open('hostlist.py', 'w') as f:
|
||||
|
||||
|
||||
# For each node in the cluster, check port 22 (ssh) until it's reachable
|
||||
for public_dns_name in public_dns_names:
|
||||
# Create an INET, STREAMing socket
|
||||
for instance in instances_with_tag:
|
||||
ip_address = instance.public_ip_address
|
||||
# Create a socket
|
||||
# Address Family: AF_INET (means IPv4)
|
||||
# Type: SOCK_STREAM (means connection-oriented TCP protocol)
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
print('Attempting to connect to {} on port 22 (ssh)...'.
|
||||
format(public_dns_name))
|
||||
format(ip_address))
|
||||
unreachable = True
|
||||
while unreachable:
|
||||
try:
|
||||
# Open a TCP connection to the remote node on port 22
|
||||
s.connect((public_dns_name, 22))
|
||||
print(' Port 22 is reachable!')
|
||||
s.shutdown(socket.SHUT_WR)
|
||||
s.close()
|
||||
unreachable = False
|
||||
# Open a connection to the remote node on port 22
|
||||
s.connect((ip_address, 22))
|
||||
except socket.error as e:
|
||||
print(' Socket error: {}'.format(e))
|
||||
print(' Trying again in 3 seconds')
|
||||
time.sleep(3.0)
|
||||
else:
|
||||
print(' Port 22 is reachable!')
|
||||
s.shutdown(socket.SHUT_WR)
|
||||
s.close()
|
||||
unreachable = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user