forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_sonic.py
executable file
·49 lines (36 loc) · 1.03 KB
/
install_sonic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
import argparse
import pexpect
import sys
import time
def main():
parser = argparse.ArgumentParser(description='test_login cmdline parser')
parser.add_argument('-p', type=int, default=9000, help='local port')
args = parser.parse_args()
#KEY_UP = '\x1b[A'
KEY_DOWN = '\x1b[B'
#KEY_RIGHT = '\x1b[C'
#KEY_LEFT = '\x1b[D'
grub_selection = "The highlighted entry will be executed"
i = 0
while True:
try:
p = pexpect.spawn("telnet 127.0.0.1 {}".format(args.p), timeout=1200, logfile=sys.stdout, encoding='utf-8')
break
except Exception as e:
print(str(e))
i += 1
if i == 10:
raise
time.sleep(1)
# select ONIE embed
p.expect(grub_selection)
p.sendline(KEY_DOWN)
# select ONIE install
p.expect(['ONIE: Install OS'])
p.expect([grub_selection])
p.sendline()
# wait for grub, and exit
p.expect([grub_selection])
if __name__ == '__main__':
main()