in gce_rescue/tasks/keeper.py [0:0]
def wait_for_os_boot(vm: googleapiclient.discovery.Resource) -> bool:
"""Wait guest OS to complete the boot proccess."""
timeout = 60
wait_time = 2
end_string = f'END:{vm.ts}'
_logger.info('Waiting startup-script to complete.')
while True:
result = vm.compute.instances().getSerialPortOutput(
**vm.project_data,
instance = vm.name
).execute()
if end_string in json.dumps(result):
_logger.info('startup-script has ended.')
return True
sleep(wait_time)
timeout -= wait_time
if not timeout:
return False