def print_windows_instructions(instance_name): tail_start = gcloud_utils.tail_serial_console( instance_name, zone=LOCATION, until="Finished running startup scripts") pw = json.loads( gcloud.reset_windows_password(instance_name, format="json", zone=LOCATION).stdout) rdp_file = tempfile.mkstemp(suffix=".rdp")[1] with open(rdp_file, "w") as f: f.write("full address:s:" + pw["ip_address"] + "\n") f.write("username:s:" + pw["username"] + "\n") subprocess.run(["open", rdp_file]) write_to_clipboard(pw["password"]) with gcloud.PRINT_LOCK: print("Use this password to connect to the Windows VM: " + pw["password"]) print( "Please run the setup script C:\\setup.ps1 once you're logged in.") # Wait until the VM reboots once, then open RDP again. tail_start = gcloud_utils.tail_serial_console( instance_name, zone=LOCATION, start=tail_start, until="Finished running startup scripts") print("Connecting via RDP a second time to finish the setup...") write_to_clipboard(pw["password"]) run(["open", rdp_file]) return tail_start
def print_windows_instructions(instance_name): tail_start = gcloud_utils.tail_serial_console( instance_name, zone=LOCATION, until='Finished running startup scripts') pw = json.loads( gcloud.reset_windows_password(instance_name, format='json', zone=LOCATION).stdout) rdp_file = tempfile.mkstemp(suffix='.rdp')[1] with open(rdp_file, 'w') as f: f.write('full address:s:' + pw['ip_address'] + '\n') f.write('username:s:' + pw['username'] + '\n') subprocess.run(['open', rdp_file]) write_to_clipboard(pw['password']) with gcloud.PRINT_LOCK: print('Use this password to connect to the Windows VM: ' + pw['password']) print( 'Please run the setup script C:\\setup.ps1 once you\'re logged in.' ) # Wait until the VM reboots once, then open RDP again. tail_start = gcloud_utils.tail_serial_console( instance_name, zone=LOCATION, start=tail_start, until='Finished running startup scripts') print('Connecting via RDP a second time to finish the setup...') write_to_clipboard(pw['password']) run(['open', rdp_file]) return tail_start