launch: add a probe for ssh after reboot

We do more operations after rebooting the host (getting ssh keys,
etc.).  Put in a small loop to wait for it to reappear.

Change-Id: Ibfaf530bba8f84bc5a6110e3dd7e7c73be7d5f4f
This commit is contained in:
Ian Wienand 2022-12-22 08:55:29 +11:00
parent b5e72b4aa1
commit 04c3e4a0cc
No known key found for this signature in database
1 changed files with 14 additions and 0 deletions

View File

@ -21,6 +21,7 @@
import argparse
import os
import shutil
import socket
import subprocess
import sys
import threading
@ -228,6 +229,19 @@ def bootstrap_server(server, key, name, volume_device, keep,
else:
raise
timeout = 120
start = time.perf_counter()
while True:
try:
print("Waiting for ssh...")
with socket.create_connection((host_ip, 22), timeout=5):
break
except OSError as e:
if time.perf_counter() - start >= timeout:
raise Exception("Host did not reboot within timeout")
time.sleep(10)
print("Host rebooted!")
def build_server(cloud, name, image, flavor,
volume, keep, network, boot_from_volume, config_drive,