@@ -132,9 +132,18 @@ def is_url(path):
132
132
"grub2-mkconfig --output=/boot/grub2/grub.cfg" )
133
133
log .debug ("Rebooting after kernel install..." )
134
134
self .console_thread .console_terminate ()
135
+ self .prompt = self .cv_SYSTEM .util .build_prompt ()
136
+ self .console_thread .console_terminate ()
135
137
con .close ()
136
- self .cv_SYSTEM .goto_state (OpSystemState .OFF )
137
- self .cv_SYSTEM .goto_state (OpSystemState .OS )
138
+ for i in range (5 ):
139
+ raw_pty = self .wait_for (self .cv_SYSTEM .console .get_console , timeout = 20 )
140
+ time .sleep (10 )
141
+ if raw_pty is not None :
142
+ raw_pty .sendline ("uname -r" )
143
+ break
144
+ raw_pty .sendline ("reboot" )
145
+ raw_pty .expect ("login:" , timeout = 600 )
146
+ raw_pty .close ()
138
147
else :
139
148
self .console_thread .console_terminate ()
140
149
cmdline = con .run_command ("cat /proc/cmdline" )[- 1 ]
@@ -182,3 +191,24 @@ def is_url(path):
182
191
finally :
183
192
if self .console_thread .isAlive ():
184
193
self .console_thread .console_terminate ()
194
+
195
+ def wait_for (self , func , timeout , first = 0.0 , step = 1.0 , text = None , args = None , kwargs = None ):
196
+ args = args or []
197
+ kwargs = kwargs or {}
198
+
199
+ start_time = time .monotonic ()
200
+ end_time = start_time + timeout
201
+
202
+ time .sleep (first )
203
+
204
+ while time .monotonic () < end_time :
205
+ if text :
206
+ LOG .debug ("%s (%.9f secs)" , text , (time .monotonic () - start_time ))
207
+
208
+ output = func (* args , ** kwargs )
209
+ if output :
210
+ return output
211
+
212
+ time .sleep (step )
213
+
214
+ return None
0 commit comments