Skip to content

Commit

Permalink
update the otn_legacy build and test on virtual machine steps
Browse files Browse the repository at this point in the history
  • Loading branch information
sonic-otn committed Nov 3, 2023
1 parent 9740fdc commit 9d37d9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 49 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@
Following is the instruction on how to build an [(ONIE)](https://github.com/opencomputeproject/onie) compatible network operating system (NOS) installer image for network switches, and also how to build docker images running inside the NOS. Note that SONiC image are build per ASIC platform. Switches using the same ASIC platform share a common image. For a list of supported switches and ASIC, please refer to this [list](https://github.com/Azure/SONiC/wiki/Supported-Devices-and-Platforms)

# Hardware
Any server can be a build image server. We are using a server with 1T hard disk. The OS is Ubuntu 16.04.
Any server can be a build image server. We are using a server with 1T hard disk. The OS is Ubuntu 16.04 and Ubuntu 20.04.

## Prerequisites

Install pip and jinja in host build machine, execute below commands if j2/j2cli is not available:
For Ubuntu 16.04, Install pip and jinja in host build machine, execute below commands if j2/j2cli is not available:

sudo apt-get install -y python-pip
sudo python2 -m pip install -U pip==9.0.3
sudo pip install --force-reinstall --upgrade jinja2>=2.10
sudo pip install j2cli

Configure your system to allow running the 'docker' command without 'sudo':
For Ubuntu 20.04,
```shell
sudo apt install -y python3-pip
pip3 install --user j2cli
```

Install [Docker](https://docs.docker.com/engine/install/) and configure your and configure your system to allow running the 'docker' command without 'sudo':
Add current user to the docker group
`sudo gpasswd -a ${USER} docker`
Log out and log back in so that your group membership is re-evaluated

## Clone or fetch the code repository with all git submodules
To clone the code repository recursively, assuming git version 1.9 or newer:

git clone https://github.com/zhengweitang-zwt/sonic-buildimage.git
git clone -b otn_legacy https://github.com/sonic-otn/sonic-buildimage.git

## Usage

Expand All @@ -101,8 +107,8 @@ To build SONiC installer image and docker images, run the following commands:
# Build SONiC-OTN VS image
BUILD_MULTIASIC_KVM=y make target/sonic-vs.img.gz

# RUN the virtual image
Please refer to the `SONiC-OTN-VM.md` file to run it on virtual machine
## RUN the virtual image
Please refer to the [SONiC-OTN-VM.md](./SONiC-OTN-VM.md) file to run it on a virtual machine

## Usage for ARM Architecture
To build Arm32 bit for (ARMHF) plaform
Expand Down
60 changes: 17 additions & 43 deletions SONiC-OTN-VM.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,38 @@


# How to Build AONOS Virtual Machine


1. Clone sonic-buildimage repo
# Prerequisites
* Install qemu
```
git clone git@github.com:zhengweitang-zwt/sonic-buildimage.git
sudo apt-get install qemu-kvm
```
2. Clone sub-repos
or
```
make init
brew install qemu
```

3. Config platform type

```
BUILD_MULTIASIC_KVM=y BUILD_LINUX_KERNEL=y make configure PLATFORM=vs
```

4. Build kvm image
* download sonic-otn virtual images

1. download ONIE image `onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso`
```shell
curl https://sonicstorage.blob.core.windows.net/packages/onie/onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso\?sv\=2020-04-08\&st\=2021-08-27T22%3A41%3A07Z\&se\=2030-08-28T22%3A41%3A00Z\&sr\=b\&sp\=r\&sig\=zyaX7rHnE5jXldpgrnWq1nvsfmMTrVCSuESZqrIxDLc%3D --output onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso
```
make target/sonic-vs.img.gz
```

5. Get vm binaries

```
ONIE image: onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso
Refer to `platfrom/vs/onie.mk`, you can download it from https://sonicstorage.blob.core.windows.net/packages/onie/onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso?sv=2020-04-08&st=2021-08-27T22%3A41%3A07Z&se=2030-08-28T22%3A41%3A00Z&sr=b&sp=r&sig=zyaX7rHnE5jXldpgrnWq1nvsfmMTrVCSuESZqrIxDLc%3D
AONOS image: sonic-4asic-vs.img, sonic-installer.img
you can find the `sonic-4asic-vs.img` in the root folder of your project, and `sonic-4asic-vs.img` in the `target` folder
```
2. download installer images `sonic-installer.img` and `sonic-4asic-vs.img`
download these images from the github [actions](https://github.com/sonic-otn/sonic-buildimage/actions/workflows/otn-legacy-vs-image-build.yml) artifacts, for example this workflow [build#5](https://github.com/sonic-otn/sonic-buildimage/actions/runs/6740732168)


* (optional) build sonic-otn virtual images
Build these images with steps in [readme](./README.md). Then you can find the `sonic-installer.img` and `sonic-4asic-vs.img` in the root and `target` folder


# How to Start a Virtual Machine

1. Install qemu
```
sudo apt-get install qemu-kvm
1. Start VM via qemu
```
gunzip -k sonic-4asic-vs.img.gz
2. Start VM via qemu
```
sudo qemu-system-x86_64 -m 3072 -name onie -accel hvf -boot order=cd,once=d -cdrom ./onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso -device e1000,netdev=onienet -netdev user,id=onienet,hostfwd=:0.0.0.0:3040-:22 -vnc 0.0.0.0:0 -vga std -drive file=./sonic-4asic-vs.img,media=disk,if=virtio,index=0 -drive file=./sonic-installer.img,if=virtio,index=1 -serial telnet:127.0.0.1:7000,server
sudo qemu-system-x86_64 -m 3072 -name onie -accel hvf -boot order=cd,once=d -cdrom ./onie-recovery-x86_64-kvm_x86_64_4_asic-r0.iso -device e1000,netdev=onienet -netdev user,id=onienet,hostfwd=:0.0.0.0:3040-:22 -vga std -drive file=./sonic-4asic-vs.img,media=disk,if=virtio,index=0 -drive file=./sonic-installer.img,if=virtio,index=1 -serial telnet:127.0.0.1:7000,server
```

3. Open a new terminal, use console to login ONIE.
Expand All @@ -54,10 +41,8 @@ telnet 127.0.0.1 7000
```

4. Choose entry: `ONIE: Embed ONIE`
<img src="ONIE snapshot 1.jpg" alt="ONIE snapshot 1" style="zoom: 50%;" />

5. Choose entry: `ONIE: Install OS`
<img src="ONIE snapshot 2.jpg" alt="ONIE snapshot 2" style="zoom: 50%;" />

6. Wait until AONOS image installed.

Expand All @@ -70,16 +55,11 @@ ONIE:/ # blkid
/dev/vda2: LABEL="ONIE-BOOT" UUID="e0f5d6f2-64aa-4501-8123-62bed94e04ee"
```


7. reboot
```
ONIE:/ # reboot
```

8. Boot from SONiC-OS partition.
<img src="ONIE snapshot 3.jpg" alt="ONIE snapshot 3" style="zoom: 50%;" />


# How to Login Virtual Machine

1. Connect AONOS VM via console
Expand All @@ -103,12 +83,6 @@ telnet 127.0.0.1 7000
ssh root@localhost -p 3040
```

# How does Virtual Machine simulate line-card and driver
<img src="AONOS VM.png" alt="AONOS VM" style="zoom: 50%;" />




# AONOS CLI Demo

1. Show line-cards info
Expand Down

0 comments on commit 9d37d9a

Please sign in to comment.