-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vs]: build sonic vs kvm image (#2269)
Signed-off-by: Guohan Lu <gulv@microsoft.com>
- Loading branch information
Showing
40 changed files
with
1,275 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/sh -ex | ||
|
||
# Copyright (C) 2014 Curt Brune <curt@cumulusnetworks.com> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
MEM=2048 | ||
DISK=$1 | ||
ONIE_RECOVERY_ISO=$2 | ||
INSTALLER=$3 | ||
DISK_SIZE=$4 | ||
|
||
INSTALLER_DISK="./sonic-installer.img" | ||
|
||
# VM will listen on telnet port $KVM_PORT | ||
KVM_PORT=9000 | ||
|
||
on_exit() | ||
{ | ||
rm -f $kvm_log | ||
} | ||
|
||
kvm_log=$(mktemp) | ||
trap on_exit EXIT | ||
|
||
create_disk() | ||
{ | ||
echo "Creating SONiC kvm disk : $DISK of size $DISK_SIZE GB" | ||
qemu-img create -f qcow2 $DISK ${DISK_SIZE}G | ||
} | ||
|
||
prepare_installer_disk() | ||
{ | ||
fallocate -l 1024M $INSTALLER_DISK | ||
|
||
mkfs.vfat $INSTALLER_DISK | ||
|
||
tmpdir=$(mktemp -d) | ||
|
||
mount -o loop $INSTALLER_DISK $tmpdir | ||
|
||
cp $INSTALLER $tmpdir/onie-installer.bin | ||
|
||
umount $tmpdir | ||
} | ||
|
||
create_disk | ||
prepare_installer_disk | ||
|
||
/usr/bin/kvm -m $MEM \ | ||
-name "onie" \ | ||
-boot "order=cd,once=d" -cdrom "$ONIE_RECOVERY_ISO" \ | ||
-device e1000,netdev=onienet \ | ||
-netdev user,id=onienet,hostfwd=:0.0.0.0:3041-:22 \ | ||
-vnc 0.0.0.0:0 \ | ||
-vga std \ | ||
-drive file=$DISK,media=disk,if=virtio,index=0 \ | ||
-drive file=$INSTALLER_DISK,if=virtio,index=1 \ | ||
-serial telnet:localhost:$KVM_PORT,server > $kvm_log 2>&1 & | ||
|
||
kvm_pid=$! | ||
|
||
sleep 2.0 | ||
|
||
[ -d "/proc/$kvm_pid" ] || { | ||
echo "ERROR: kvm died." | ||
cat $kvm_log | ||
exit 1 | ||
} | ||
|
||
echo "to kill kvm: sudo kill $kvm_pid" | ||
|
||
./check_install.py -u $SONIC_USERNAME -P $PASSWD -p $KVM_PORT | ||
|
||
kill $kvm_pid | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python | ||
|
||
import pexpect | ||
import argparse | ||
import sys | ||
import time | ||
|
||
def main(): | ||
|
||
parser = argparse.ArgumentParser(description='test_login cmdline parser') | ||
parser.add_argument('-u', default="admin", help='login user name') | ||
parser.add_argument('-P', default="YourPaSsWoRd", help='login password') | ||
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' | ||
|
||
login_prompt = 'sonic login:' | ||
passwd_prompt = 'Password:' | ||
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) | ||
|
||
# select ONIE embed | ||
p.expect(grub_selection) | ||
p.sendline(KEY_DOWN) | ||
|
||
# install sonic image | ||
while True: | ||
i = p.expect([login_prompt, passwd_prompt, grub_selection, cmd_prompt]) | ||
if i == 0: | ||
# send user name | ||
p.sendline(args.u) | ||
elif i == 1: | ||
# send password | ||
p.sendline(args.P) | ||
elif i == 2: | ||
# select onie install | ||
p.sendline() | ||
else: | ||
break | ||
|
||
# check version | ||
time.sleep(5) | ||
p.sendline('show version') | ||
p.expect([cmd_prompt]) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
device/virtual/x86_64-kvm_x86_64-r0/Force10-S6000/lanemap.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; comment | ||
# comment | ||
eth1:29,30,31,32 | ||
eth2:25,26,27,28 | ||
eth3:37,38,39,40 | ||
eth4:33,34,35,36 | ||
eth5:41,42,43,44 | ||
eth6:45,46,47,48 | ||
eth7:5,6,7,8 | ||
eth8:1,2,3,4 | ||
eth9:9,10,11,12 | ||
eth10:13,14,15,16 | ||
eth11:21,22,23,24 | ||
eth12:17,18,19,20 | ||
eth13:49,50,51,52 | ||
eth14:53,54,55,56 | ||
eth15:61,62,63,64 | ||
eth16:57,58,59,60 | ||
eth17:65,66,67,68 | ||
eth18:69,70,71,72 | ||
eth19:77,78,79,80 | ||
eth20:73,74,75,76 | ||
eth21:105,106,107,108 | ||
eth22:109,110,111,112 | ||
eth23:117,118,119,120 | ||
eth24:113,114,115,116 | ||
eth25:121,122,123,124 | ||
eth26:125,126,127,128 | ||
eth27:85,86,87,88 | ||
eth28:81,82,83,84 | ||
eth29:89,90,91,92 | ||
eth30:93,94,95,96 | ||
eth31:97,98,99,100 | ||
eth32:101,102,103,104 |
33 changes: 33 additions & 0 deletions
33
device/virtual/x86_64-kvm_x86_64-r0/Force10-S6000/port_config.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# name lanes alias | ||
Ethernet0 29,30,31,32 fortyGigE0/0 | ||
Ethernet4 25,26,27,28 fortyGigE0/4 | ||
Ethernet8 37,38,39,40 fortyGigE0/8 | ||
Ethernet12 33,34,35,36 fortyGigE0/12 | ||
Ethernet16 41,42,43,44 fortyGigE0/16 | ||
Ethernet20 45,46,47,48 fortyGigE0/20 | ||
Ethernet24 5,6,7,8 fortyGigE0/24 | ||
Ethernet28 1,2,3,4 fortyGigE0/28 | ||
Ethernet32 9,10,11,12 fortyGigE0/32 | ||
Ethernet36 13,14,15,16 fortyGigE0/36 | ||
Ethernet40 21,22,23,24 fortyGigE0/40 | ||
Ethernet44 17,18,19,20 fortyGigE0/44 | ||
Ethernet48 49,50,51,52 fortyGigE0/48 | ||
Ethernet52 53,54,55,56 fortyGigE0/52 | ||
Ethernet56 61,62,63,64 fortyGigE0/56 | ||
Ethernet60 57,58,59,60 fortyGigE0/60 | ||
Ethernet64 65,66,67,68 fortyGigE0/64 | ||
Ethernet68 69,70,71,72 fortyGigE0/68 | ||
Ethernet72 77,78,79,80 fortyGigE0/72 | ||
Ethernet76 73,74,75,76 fortyGigE0/76 | ||
Ethernet80 105,106,107,108 fortyGigE0/80 | ||
Ethernet84 109,110,111,112 fortyGigE0/84 | ||
Ethernet88 117,118,119,120 fortyGigE0/88 | ||
Ethernet92 113,114,115,116 fortyGigE0/92 | ||
Ethernet96 121,122,123,124 fortyGigE0/96 | ||
Ethernet100 125,126,127,128 fortyGigE0/100 | ||
Ethernet104 85,86,87,88 fortyGigE0/104 | ||
Ethernet108 81,82,83,84 fortyGigE0/108 | ||
Ethernet112 89,90,91,92 fortyGigE0/112 | ||
Ethernet116 93,94,95,96 fortyGigE0/116 | ||
Ethernet120 97,98,99,100 fortyGigE0/120 | ||
Ethernet124 101,102,103,104 fortyGigE0/124 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{%- include 'qos_config.j2' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.