authoravatarclover caruso<git@paperclover.net>2026-11-17 04:16:01-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-22 00:44:02-08:00
log9993eea212ea925b52a7c41f44974a873a6f7e8a
tree9e4e2d9293b8fa9ecd15b2f40b22bab2cc89134c
parente919bac8ce86abf4941d4e27ca5ec20527d82cbc
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Wait for Windows account setup before reporting readiness

Keep console access available while prepared Windows images personalize and sign into their new account. Report setup progress before launching the desktop worker so a temporary template session is not reported as ready. Assisted-by: gpt-6.1-sol

2 files changed, 23 insertions(+), 0 deletions(-)

tools/computer-test.py+18
...@@ -268,6 +268,24 @@ class GuestCancellation(unittest.TestCase):...@@ -268,6 +268,24 @@ class GuestCancellation(unittest.TestCase):
268 self.assertEqual(computer.handle('fixture', {'action':'status'})['readiness'], 'ready')268 self.assertEqual(computer.handle('fixture', {'action':'status'})['readiness'], 'ready')
269 work.assert_called_once_with('fixture', 'macos', {'action':'status'})269 work.assert_called_once_with('fixture', 'macos', {'action':'status'})
270270
271 def test_windows_status_waits_for_personalization_before_using_template_session(self):
272 root = '<domain><metadata><vm xmlns="https://paperclover.net/snowglobe"><platform>windows</platform><setup>windows-v4</setup></vm></metadata></domain>'
273 with patch.object(computer.vms, 'virsh', side_effect=lambda action, *a, **k: 'running' if action == 'domstate' else root), \
274 patch.object(computer, 'qga', return_value={'supported_commands':[{'name':'guest-exec','enabled':True}]}), \
275 patch.object(computer.vms, 'windows_setup') as setup, patch.object(computer, 'worker') as work:
276 for phase in ['starting', 'personalizing', 'signingIn', 'failed']:
277 setup.return_value = phase
278 status = computer.handle('fixture', {'action':'status'})
279 self.assertEqual(status['readiness'], 'setup_failed' if phase == 'failed' else 'personalizing')
280 self.assertEqual(status['setup'], phase)
281 self.assertEqual(status['capabilities'], ['shot', 'input'])
282 work.assert_not_called()
283 setup.return_value = 'ready'
284 work.return_value = {'execution_context':{'user':'fixture'}}
285 status = computer.handle('fixture', {'action':'status'})
286 self.assertEqual(status['readiness'], 'ready')
287 self.assertEqual(status['execution_context']['user'], 'fixture')
288
271 def test_failed_cleanup_keeps_status_available_and_blocks_later_control(self):289 def test_failed_cleanup_keeps_status_available_and_blocks_later_control(self):
272 for platform, identity in [('linux', 'snowglobe-computer-request-' + 'a' * 32), ('windows', 'a' * 32)]:290 for platform, identity in [('linux', 'snowglobe-computer-request-' + 'a' * 32), ('windows', 'a' * 32)]:
273 operation = {'platform': platform, 'id': identity}291 operation = {'platform': platform, 'id': identity}
tools/vm-computer.py+5
...@@ -625,6 +625,11 @@ def handle(name, request, *, active_snapshot=None):...@@ -625,6 +625,11 @@ def handle(name, request, *, active_snapshot=None):
625 if not native_text:625 if not native_text:
626 return {**status, 'readiness': 'agent_unsupported', 'text_encoding': 'ascii',626 return {**status, 'readiness': 'agent_unsupported', 'text_encoding': 'ascii',
627 'worker_error': 'The guest agent does not support commands. Use console input or ask an administrator to update the agent.'}627 'worker_error': 'The guest agent does not support commands. Use console input or ask an administrator to update the agent.'}
628 if platform == 'windows' and root.findtext(f'metadata/{vms.NS}vm/{vms.NS}setup') in {'windows-v3', 'windows-v4'}:
629 setup = vms.windows_setup(name)
630 if setup != 'ready':
631 return {**status, 'readiness': 'setup_failed' if setup == 'failed' else 'personalizing', 'setup': setup,
632 'worker_error': 'Windows account setup failed. Inspect the console and C:\\Snowglobe\\setup.log.' if setup == 'failed' else 'Windows is applying the VM account. Wait for setup to finish.'}
628 status['readiness'] = 'worker_starting'633 status['readiness'] = 'worker_starting'
629 try:634 try:
630 status.update(worker(name,platform,request))635 status.update(worker(name,platform,request))