From 654bb0eae7c2e17eebda2cf586c3efae8e7d3a03 Mon Sep 17 00:00:00 2001 From: lguohan Date: Tue, 3 Dec 2019 13:54:57 -0800 Subject: [PATCH] [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 --- check_install.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/check_install.py b/check_install.py index 09979f61e4..d95d831daa 100755 --- a/check_install.py +++ b/check_install.py @@ -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)