[kvm]: reconnect during kvm installation process (#3837)

* [kvm]: reconnect during kvm installation process

retry connect every 1 second for 10 maximum times

Signed-off-by: Guohan Lu <gulv@microsoft.com>
This commit is contained in:
lguohan 2019-12-03 13:54:57 -08:00 committed by GitHub
parent 343ad78931
commit 654bb0eae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,17 @@ def main():
cmd_prompt = "%s@sonic:~\$ $" % args.u
grub_selection = "The highlighted entry will be executed"
p = pexpect.spawn("telnet 127.0.0.1 %s" % args.p, timeout=600, logfile=sys.stdout)
i = 0
while True:
try:
p = pexpect.spawn("telnet 127.0.0.1 %s" % args.p, timeout=600, logfile=sys.stdout)
break
except Exception as e:
print str(e)
i += 1
if i == 10:
raise
time.sleep(1)
# select ONIE embed
p.expect(grub_selection)